-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
470 lines (440 loc) · 19.5 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
<!--
// Copyright 2013 Bill Campbell, Swami Iyer and Bahar Akbal-Delibas
-->
<project default="runCompilerTests">
<property name="APP_FULL_NAME" value="j-- (A Non-trivial Subset of Java)" />
<property name="SRC_DIR" value="src" />
<property name="CLASS_DIR" value="classes" />
<property name="LIB_DIR" value="lib" />
<property name="JAVADOC_DIR" value="javadoc" />
<property name="J2H_DIR" value="java2html" />
<property name="PASS_TESTS_DIR" value="${basedir}/tests/pass" />
<property name="FAIL_TESTS_DIR" value="${basedir}/tests/fail" />
<property name="GEN_CLASS_DIR" value="${basedir}/${CLASS_DIR}" />
<!-- help: Lists main targets -->
<target name="help">
<echo message="package: Creates a distributable for j--"/>
<echo message="runCompilerTests: Compiles and runs j-- (JVM) tests"/>
<echo message="runCompilerTestsJavaCC: Compiles and runs j-- (JVM) tests using JavaCC frontend"/>
<echo message="testScanner: Tokenizes j-- tests"/>
<echo message="testJavaCCScanner: Tokenizes j-- tests using JavaCC scanner"/>
<echo message="testParser: Parses j-- tests"/>
<echo message="testJavaCCParser: Parses j-- tests using JavaCC parser"/>
<echo message="testPreAnalysis: Pre-analyzes j-- tests"/>
<echo message="testAnalysis: Analyzes j-- tests"/>
<echo message="help: Lists main targets"/>
</target>
<!-- javacc: Generates JavaCC scanner and parser. -->
<target name="javacc">
<echo message="Generating JavaCC files..."/>
<javacc target="${SRC_DIR}/jminusminus/j--.jj"
outputdirectory="${SRC_DIR}/jminusminus"
javacchome="${LIB_DIR}"
static="false" />
</target>
<!-- compile: Compiles the jminusminus and SPIM source files. -->
<target name="compile">
<echo message="Compiling j-- source files..."/>
<mkdir dir="${CLASS_DIR}" />
<javac srcdir="${SRC_DIR}"
destdir="${CLASS_DIR}"
includes="jminusminus/**"
excludes="jminusminus/JavaCCMain.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
</javac>
</target>
<!--
compileJavaCC: Compiles the jminusminus source files including
JavaCC frontend.
-->
<target name="compileJavaCC">
<echo message="Compiling j-- source files..."/>
<mkdir dir="${CLASS_DIR}" />
<javac srcdir="${SRC_DIR}"
destdir="${CLASS_DIR}"
includes="jminusminus/**"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
</javac>
</target>
<!-- compile: Compiles the SPIM runtime files. -->
<target name="compileSPIM">
<echo message="Compiling j-- source files..."/>
<mkdir dir="${CLASS_DIR}" />
<javac srcdir="${SRC_DIR}"
destdir="${CLASS_DIR}"
includes="spim/**"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
</javac>
</target>
<!--
jar: Bundles the jminusminus classes and SPIM runtime
classes into respective jar files.
-->
<target name="jar">
<echo message="Bundling class files into jar files..."/>
<jar destfile="${LIB_DIR}/j--.jar" basedir="${CLASS_DIR}" includes="jminusminus/**"/>
<jar destfile="${LIB_DIR}/spim.jar" basedir="${CLASS_DIR}" includes="spim/**"/>
</target>
<!-- javadoc: Generates javadoc for jminusminus and spim runtime classes. -->
<target name="javadoc">
<echo message="Generating javadoc for j-- classes..."/>
<mkdir dir="${JAVADOC_DIR}" />
<javadoc overview="${SRC_DIR}/overview.html"
package="Yes"
sourcepath="${SRC_DIR}" destdir="${JAVADOC_DIR}"
packagenames="jminusminus.*,spim.*"
windowtitle="${APP_FULL_NAME}"
doctitle="${APP_FULL_NAME}">
<link href="http://java.sun.com/javase/6/docs/api/" />
</javadoc>
</target>
<!-- j2h: Generates browsable code using java2html. -->
<target name="j2h">
<echo message="Generating browsable code for j--..."/>
<mkdir dir="${J2H_DIR}" />
<java jar="${LIB_DIR}/j2h.jar"
fork="true"
failonerror="true"
maxmemory="128m">
<arg value="-m"/>
<arg value="4"/>
<arg value="-d"/>
<arg value="${J2H_DIR}"/>
<arg value="-js"/>
<arg value="${SRC_DIR}"/>
</java>
</target>
<!--
package: Makes a distributable package for the compiler which includes the
sources, binaries, documentation and junit test framework.
-->
<target name="package"
depends="clean,javacc,compileJavaCC,compileSPIM,jar,javadoc,j2h">
<echo message="Making a distributable j--.zip..."/>
<zip destfile="j--.zip"
basedir="../"
includes="j--/**"
excludes="j--/${CLASS_DIR}/**,j--/*.zip" />
</target>
<!--
runCompilerTests: We first compile the tests in tests/pass and
tests/fail directories using the jminusminus compiler. We
use a JUnit test JMinusMinusTest.java to run the jminusminus
compiler on each of the tests. We then run the
JMinusMinusTestRunner JUnit test suite, which includes a JUnit test
case for each jminusminus test file under tests/pass directory.
For example, there is a GCDTest.java test case under tests/junit
corresponding to the jminusminus test GCD.java under tests/pass.
-->
<target name="runCompilerTests" depends="compile,compileSPIM,jar">
<echo message="Compiling and running j-- (JVM) programs..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/JMinusMinusTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<sysproperty key="FAIL_TESTS_DIR" value="${FAIL_TESTS_DIR}" />
<sysproperty key="GEN_CLASS_DIR" value="${GEN_CLASS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JMinusMinusTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
<javac srcdir="${basedir}/tests"
sourcepath=""
destdir="${CLASS_DIR}"
includes="junit/**"
excludes="junit/JavaCCScannerTest.java,junit/JavaCCParserTest.java,junit/JMinusMinusTestJavaCC.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JMinusMinusTestRunner"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
runCompilerTestsJavaCC: Same as run compilerTests, but using
JavaCC frontend.
-->
<target name="runCompilerTestsJavaCC"
depends="javacc,compileJavaCC,compileSPIM,jar">
<echo message=
"Compiling and running j-- (JVM) programs using JavaCC frontend..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/JMinusMinusTestJavaCC.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<sysproperty key="FAIL_TESTS_DIR" value="${FAIL_TESTS_DIR}" />
<sysproperty key="GEN_CLASS_DIR" value="${GEN_CLASS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JMinusMinusTestJavaCC"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
<javac srcdir="${basedir}/tests"
sourcepath=""
destdir="${CLASS_DIR}"
includes="junit/**"
excludes="clemitter/**,pass/**,fail/**"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JMinusMinusTestRunner"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testScanner: Tests handwritten scanner by running it on all tests under
tests/pass directory.
-->
<target name="testScanner" depends="compile,jar">
<echo message="Running handwritten scanner on the j-- programs..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/ScannerTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.ScannerTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testJavaCCScanner: Tests JavaCC scanner by running it on all tests
under tests/pass directory.
-->
<target name="testJavaCCScanner" depends="javacc,compileJavaCC,jar">
<echo message="Running JavaCC scanner on the j-- programs..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/JavaCCScannerTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JavaCCScannerTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testParser: Tests hand-written parser by running it on all tests
under tests/pass directory.
-->
<target name="testParser" depends="compile,jar">
<echo message="Running handwritten parser on the j-- programs..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/ParserTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.ParserTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testJavaCCParser: Tests JavaCC parser by running it on all tests
under tests/pass directory.
-->
<target name="testJavaCCParser" depends="javacc,compileJavaCC,jar">
<echo message="Running JavaCC parser on the j-- programs..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/JavaCCParserTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.JavaCCParserTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testPreAnalysis: Runs the jminusminus compiler on each test under
tests/pass up to the stage where the AST has been pre-analyzed.
-->
<target name="testPreAnalysis" depends="compile,jar">
<echo message="Running compiler on j-- programs up to pre-analysis..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/PreAnalysisTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.PreAnalysisTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!--
testAnalysis: Runs the jminusminus compiler on each test under
tests/pass up to the stage where the AST has been analyzed.
-->
<target name="testAnalysis" depends="compile,jar">
<echo message="Running compiler on j-- programs up to analysis..."/>
<javac srcdir="${basedir}/tests/"
destdir="${CLASS_DIR}"
includes="junit/AnalysisTest.java"
includeantruntime="false"
debug="on">
<!-- Uncomment the following to see compiler warnings. -->
<!-- <compilerarg value="-Xlint" /> -->
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
</classpath>
</javac>
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<sysproperty key="PASS_TESTS_DIR" value="${PASS_TESTS_DIR}" />
<classpath>
<pathelement location="${LIB_DIR}/junit.jar" />
<pathelement location="${basedir}/${CLASS_DIR}" />
</classpath>
<test name="junit.AnalysisTest"
haltonfailure="no">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</target>
<!-- clean: Removes generated files and folders. -->
<target name="clean">
<echo message="Removing generated files and folders..."/>
<delete file="${SRC_DIR}/jminusminus/Token.java" />
<delete file="${SRC_DIR}/jminusminus/TokenMgrError.java" />
<delete file="${SRC_DIR}/jminusminus/ParseException.java" />
<delete file="${SRC_DIR}/jminusminus/JavaCCParser.java" />
<delete file="${SRC_DIR}/jminusminus/JavaCCParserTokenManager.java" />
<delete file="${SRC_DIR}/jminusminus/JavaCCParserConstants.java" />
<delete file="${SRC_DIR}/jminusminus/SimpleCharStream.java" />
<delete>
<fileset dir="${basedir}" includes="**/*.class"/>
</delete>
<delete file="j--.zip" />
<delete file="${LIB_DIR}/j--.jar" />
<delete file="${LIB_DIR}/spim.jar" />
<delete dir="${CLASS_DIR}" />
<delete dir="${JAVADOC_DIR}" />
<delete dir="${J2H_DIR}" />
</target>
</project>