1 | <project name="JFlex" default="help">
|
---|
2 |
|
---|
3 | <!-- ==================== properties ============================== -->
|
---|
4 |
|
---|
5 | <!-- use any of these files to override properties -->
|
---|
6 | <property file="build.properties" />
|
---|
7 | <property file="${user.home}/.jflex.properties" />
|
---|
8 |
|
---|
9 | <!-- location of development tools necessary for the build -->
|
---|
10 | <property name="tools.dir" value="../tools"/>
|
---|
11 |
|
---|
12 | <!-- override these if you want to use your own versions -->
|
---|
13 | <property name="jflex.jar" value="${tools.dir}/JFlex.jar" />
|
---|
14 | <property name="cup.jar" value="${tools.dir}/java_cup.jar" />
|
---|
15 | <property name="junit.jar" value="${tools.dir}/junit.jar" />
|
---|
16 |
|
---|
17 | <!-- where to get tool jars from -->
|
---|
18 | <property name="jflex.jar.url"
|
---|
19 | value="http://jflex.sourceforge.net/jar/stable/JFlex.jar" />
|
---|
20 | <property name="cup.jar.url"
|
---|
21 | value="http://jflex.sourceforge.net/jar/stable/java_cup.jar" />
|
---|
22 | <property name="junit.jar.url"
|
---|
23 | value="http://jflex.sourceforge.net/jar/stable/junit.jar" />
|
---|
24 |
|
---|
25 |
|
---|
26 | <!-- ==================== targets ================================= -->
|
---|
27 |
|
---|
28 | <target name="help" description="show help message">
|
---|
29 | <echo message="Ant build file for JFlex. Useful targets:"/>
|
---|
30 | <echo message=""/>
|
---|
31 | <echo message="gettools: download development tools for the build"/>
|
---|
32 | <echo message="realclean: remove all compiled and generated files"/>
|
---|
33 | <echo message="jar: make JFlex.jar"/>
|
---|
34 | <echo message=""/>
|
---|
35 | <echo message="Use the gettool target or override the *.jar properties"/>
|
---|
36 | <echo message="before you do the first build."/>
|
---|
37 | </target>
|
---|
38 |
|
---|
39 | <target name="declare" description="define tasks for jflex and cup">
|
---|
40 | <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" classpath="${jflex.jar}"/>
|
---|
41 | <taskdef classname="java_cup.anttask.CUPTask" name="cup" classpath="${cup.jar}"/>
|
---|
42 | </target>
|
---|
43 |
|
---|
44 | <target name="gettools" description="download development tools">
|
---|
45 | <mkdir dir="${tools.dir}"/>
|
---|
46 | <get src="${jflex.jar.url}" dest="${jflex.jar}"/>
|
---|
47 | <get src="${cup.jar.url}" dest="${cup.jar}"/>
|
---|
48 | <get src="${junit.jar.url}" dest="${junit.jar}"/>
|
---|
49 | </target>
|
---|
50 |
|
---|
51 | <target name="dist" description="build distribution">
|
---|
52 | <antcall target="gettools" />
|
---|
53 | <antcall target="build" />
|
---|
54 | <antcall target="libclean" />
|
---|
55 | </target>
|
---|
56 |
|
---|
57 | <target name="build" depends="realclean,jar"
|
---|
58 | description="complete build from scratch"/>
|
---|
59 |
|
---|
60 | <target name="cbuild" depends="libclean,compile,jar"
|
---|
61 | description="recompile and pack all classes"/>
|
---|
62 |
|
---|
63 | <target name="compile" depends="jflex,cup"
|
---|
64 | description="compile all classes">
|
---|
65 | <javac srcdir="."
|
---|
66 | destdir="../lib"
|
---|
67 | target="1.1"
|
---|
68 | source="1.2"
|
---|
69 | classpath=".:${junit.jar}"
|
---|
70 | debug="on" />
|
---|
71 | </target>
|
---|
72 |
|
---|
73 | <target name="jflex" depends="declare" description="generate scanner">
|
---|
74 | <jflex file="JFlex/LexScan.flex" skeleton="skeleton.nested"/>
|
---|
75 | </target>
|
---|
76 |
|
---|
77 | <target name="cup" depends="declare" description="generate parser">
|
---|
78 | <cup srcfile="JFlex/LexParse.cup" interface="true" parser="LexParse" />
|
---|
79 | </target>
|
---|
80 |
|
---|
81 | <target name="copy" description="copy resources to build dir">
|
---|
82 | <copy file="skeleton.default" todir="../lib/JFlex" />
|
---|
83 | <copy file="JFlex/Messages.properties" todir="../lib/JFlex/" />
|
---|
84 | </target>
|
---|
85 |
|
---|
86 | <target name="jar" depends="compile,copy" description="make JFlex.jar">
|
---|
87 | <jar basedir="../lib"
|
---|
88 | includes="JFlex/**,java_cup/**,skeleton"
|
---|
89 | jarfile="../lib/JFlex.jar"
|
---|
90 | manifest="manifest"/>
|
---|
91 | </target>
|
---|
92 |
|
---|
93 | <target name="libclean" description="remove compiled classes">
|
---|
94 | <delete dir="../lib/JFlex" />
|
---|
95 | <delete dir="../lib/java_cup" />
|
---|
96 | </target>
|
---|
97 |
|
---|
98 | <target name="jarclean" description="remove JFlex.jar">
|
---|
99 | <delete file="../lib/JFlex.jar" />
|
---|
100 | </target>
|
---|
101 |
|
---|
102 | <target name="genclean" description="remove genrated classes">
|
---|
103 | <delete file="JFlex/LexScan.java" />
|
---|
104 | <delete file="JFlex/LexParse.java" />
|
---|
105 | <delete file="JFlex/sym.java" />
|
---|
106 | </target>
|
---|
107 |
|
---|
108 | <target name="clean" description="remove backup files">
|
---|
109 | <delete> <fileset dir="." includes="**/*~"/> </delete>
|
---|
110 | </target>
|
---|
111 |
|
---|
112 | <target name="realclean" depends="clean,genclean,libclean,jarclean"
|
---|
113 | description="clean up extra tidily"/>
|
---|
114 | </project>
|
---|