build.xml 8.43 KB
Newer Older
Anders Nilsson's avatar
Anders Nilsson committed
1
2
3
4
5
6
<!--
 Targets for working from terminal window:
       build (default) - generates java files and compiles them
       clean           - removes all generated files and class files
 Targets for working from Eclipse:
       gen             - generates java files
Oscar Olsson's avatar
Oscar Olsson committed
7
       cleanGen        - removes all generated files and their class files
Anders Nilsson's avatar
Anders Nilsson committed
8
-->
9
<project name="LabComm" default="all" basedir=".">
Anders Nilsson's avatar
Anders Nilsson committed
10
11
12
13
14
15
16

<!-- "tools" is the directory where generators and libraries are located. -->
<property name="tools" value="tools"/>
	
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/>
<!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
17
<taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver-ant.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
18
19
<!-- "jastadd" is an ant task class in jastadd2.jar -->
<taskdef name="jastadd" classname="jastadd.JastAddTask"
20
         classpath="tools/jastadd2.jar"/>
Anders Nilsson's avatar
Anders Nilsson committed
21

22
23
24
25
26
27
28
29
30
31
<target name="jastadd.cu">
  <uptodate property="jastadd.u">
    <srcfiles dir='.'>
      <include name="${version}/*.ast"/>
      <include name="${version}/*.jrag"/>
      <include name="${version}/*.jadd"/>
    </srcfiles>
    <mapper type="merge" 
            to="${outdir}/${package_path}/jastadd.uptodate"/>
  </uptodate>
Anders Nilsson's avatar
Anders Nilsson committed
32
</target>
33

34
<target name="jastadd" depends="jastadd.cu" unless="jastadd.u">
35
36
37
38
39
40
41
42
43
  <echo message = "Running JastAdd"/>
  <jastadd package="${package}" rewrite="true" beaver="true" 
           novisitcheck="true" lazyMaps="true" outdir="${outdir}">
    <fileset dir=".">
      <include name="${version}/*.ast"/>
      <include name="${version}/*.jrag"/>
      <include name="${version}/*.jadd"/>
    </fileset>
  </jastadd>
44
45
  <touch file="${outdir}/${package_path}/jastadd.uptodate"/>
</target>
46

47
48
49
50
51
52
53
<target name="scanner.cu">
  <uptodate property="scanner.u">
    <srcfiles dir='.'>
      <include name="${version}/LabCommScanner.flex"/>
      <!--include name="${tools}/JFlex.jar"/-->
    </srcfiles>
    <mapper type="merge" 
Anders Blomdell's avatar
Anders Blomdell committed
54
            to="${outdir}/${package_path}/LabCommScanner.java"/>
55
56
57
58
59
60
  </uptodate>
</target>

<target name="scanner" depends="scanner.cu" unless="scanner.u">
  <echo message = "Generating scanner ${version}"/>
  <echo message = "Running jflex -> ${package} ${outdir}/${package_path}"/>
61
62
  <jflex file="${version}/LabCommScanner.flex" 
         outdir="${outdir}/${package_path}" nobak="yes"/>
63
64
65
66
67
68
69
70
71
72
73
</target>

<target name="parser.1.cu">
  <uptodate property="parser.1.u">
    <srcfiles dir='.'>
      <include name="${version}/*.parser"/>
    </srcfiles>
    <mapper type="merge" 
            to="${outdir}/${package_path}/LabCommParser.all"/>
  </uptodate>
</target>
74

75
<target name="parser.1" depends="parser.1.cu" unless="parser.1.u">
76
77
  <!-- generate the parser phase 1, create a full .lalr specification 
       from fragments-->
78
  <echo message = "Joining parser fragments"/>
79
80
81
82
83
  <concat destfile="${outdir}/${package_path}/LabCommParser.all" binary="true">
    <fileset dir=".">
      <include name="${version}/*.parser"/>
    </fileset>
  </concat>
84
85
86
87
88
89
90
91
92
93
94
</target>

<target name="parser.2.cu">
  <uptodate property="parser.2.u">
    <srcfiles dir='.'>
      <include name="${outdir}/${package_path}/LabCommParser.all"/>
    </srcfiles>
    <mapper type="merge" 
            to="${outdir}/${package_path}/LabCommParser.beaver"/>
  </uptodate>
</target>
95

96
<target name="parser.2" depends="parser.1, parser.2.cu" unless="parser.2.u">
97
98
99
100
101
102
103
  <!-- generate the parser phase 2, translating .lalr to .beaver -->
  <echo message = "translating .lalr to .beaver"/>
  <java fork="true" dir="${basedir}" 
        classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
    <arg line="${outdir}/${package_path}/LabCommParser.all 
               ${outdir}/${package_path}/LabCommParser.beaver"/>
  </java>
104
105
106
107
108
109
110
111
112
113
114
</target>

<target name="parser.3.cu">
  <uptodate property="parser.3.u">
    <srcfiles dir='.'>
      <include name="${outdir}/${package_path}/LabCommParser.beaver"/>
    </srcfiles>
    <mapper type="merge" 
            to="${outdir}/${package_path}/LabCommParser.java"/>
  </uptodate>
</target>
115

116
<target name="parser.3" depends="parser.2, parser.3.cu" unless="parser.3.u">
117
118
119
  <echo message = "translating .beaver to .java"/>
  <beaver file="${outdir}/${package_path}/LabCommParser.beaver"
          terminalNames="yes" compress="yes" useSwitch="yes"/>
120
</target>
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<target name="all.version" depends="jastadd, scanner, parser.3">
</target>

<target name="compile.cu">
  <uptodate property="compile.u">
    <srcfiles dir='.'>
      <include name="*.java"/>
      <include name="2006/*.java"/>
      <include name="2014/*.java"/>
      <include name="${outdir}/**/*.java"/>
    </srcfiles>
    <mapper type="merge" 
            to="${outdir}/compile.uptodate"/>
  </uptodate>
</target>

<target name="compile" depends="compile.cu" unless="compile.u">
  <echo message = "compiling"/>
Anders Blomdell's avatar
Anders Blomdell committed
140
  <javac debug="true" srcdir="." destdir="${outdir}"
141
         includes="*.java 2006/*.java 2014/*.java gen/**/*.java" 
Anders Blomdell's avatar
Anders Blomdell committed
142
         classpath="${outdir}:${tools}/beaver-rt.jar:${tools}/junit.jar"
143
144
         includeantruntime="false"
         fork="true" memoryMaximumSize="128M">
145
    <!--compilerarg value="-Xlint"/-->
146
  </javac>
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  <touch file="${outdir}/compile.uptodate"/>
</target>

<target name="jar.version.cu">
  <uptodate property="jar.version.u">
    <srcfiles dir=".">
      <include name="${outdir}/${package_path}/*.class"/>
    </srcfiles>
    <mapper type="merge" 
            to="labcomm${version}_compiler.jar"/>
  </uptodate>
</target>

<target name="jar.version" depends="jar.version.cu" unless="jar.version.u">
  <echo message = "Generating labcomm${version}_compiler.jar"/>
  <jar destfile="labcomm${version}_compiler.jar">
    <fileset dir="${outdir}" 
             includes="${package_path}/*.class"/>
    <zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
    <manifest>
      <attribute name="Main-Class" 
                 value="${package}.LabComm"/>
    </manifest>
  </jar>
171
172
</target>

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<target name="jar.all.cu">
  <uptodate property="jar.all.u">
    <srcfiles dir=".">
      <include name="${outdir}/**/*.class"/>
    </srcfiles>
    <mapper type="merge" 
            to="labcomm_compiler.jar"/>
  </uptodate>
</target>

<target name="jar.all" depends="jar.all.cu" unless="jar.all.u">
  <echo message = "Generating labcomm_compiler.jar"/>
  <jar destfile="labcomm_compiler.jar">
    <fileset dir="${outdir}" 
             includes="**/*.class"/>
    <zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
    <manifest>
      <attribute name="Main-Class" 
                 value="LabComm"/>
    </manifest>
  </jar>
</target>

<target name="do.version">
  <!-- Wrapper that sets up package and package_path based on ${version} -->
  <local name="package"/>
  <local name="package_path"/>
  <property name="package" value="se.lth.control.labcomm${version}.compiler"/>
  <loadresource property="package_path">
    <propertyresource name="package"/>
    <filterchain>
      <tokenfilter>
        <filetokenizer/>
        <replacestring from="." to="/"/>
      </tokenfilter>
    </filterchain>
  </loadresource>  
  <echo>${do} ${version} ${outdir}</echo>
  <mkdir dir="${outdir}"/>
  <antcall target="${do}">
    <param name="version" value="${version}"/>
    <param name="outdir" value="${outdir}"/>
    <param name="package" value="${package}"/>
    <param name="package_path" value="${package_path}"/>
  </antcall>
</target>

<target name="all">
  <antcall target="do.version">
    <param name="do" value="all.version"/>
223
224
225
    <param name="version" value="2006"/>
    <param name="outdir" value="gen"/>
  </antcall>
226
227
  <antcall target="do.version">
    <param name="do" value="all.version"/>
228
229
230
    <param name="version" value="2014"/>
    <param name="outdir" value="gen"/>
  </antcall>
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
  <antcall target="compile">
    <param name="outdir" value="gen"/>
  </antcall>
  <antcall target="do.version">
    <param name="do" value="jar.version"/>
    <param name="version" value="2006"/>
    <param name="outdir" value="gen"/>
  </antcall>
  <antcall target="do.version">
    <param name="do" value="jar.version"/>
    <param name="version" value="2014"/>
    <param name="outdir" value="gen"/>
  </antcall>
  <antcall target="jar.all">
    <param name="outdir" value="gen"/>
  </antcall>
247
</target>
Anders Nilsson's avatar
Anders Nilsson committed
248

249
250
251
252
253
254
255
256
257
258
259
260
261
262
<target name="clean">
  <delete dir="gen"/>
</target>
  
<target name="distclean" depends="clean">
  <delete>
    <fileset dir="." includes="labcomm*_compiler.jar"/>
  </delete>
</target>

<target name="test">
  <echo>No tests defined yet</echo>
</target>
  
Anders Nilsson's avatar
Anders Nilsson committed
263
264
265
</project>