-
Notifications
You must be signed in to change notification settings - Fork 30
/
build.xml
570 lines (512 loc) · 20.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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
<?xml version="1.0" ?>
<project name="boa" default="package">
<!-- paths -->
<property name="src.proto" location="src/proto" />
<property name="dst.proto" location="src/compiled-proto" />
<!-- Java version -->
<property name="ant.build.javac.source" value="1.8" />
<property name="ant.build.javac.target" value="1.8" />
<!-- ANTLR version -->
<property name="antlr.version" value="4.5" />
<!-- CheckStyle path -->
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="lib/checkstyle-6.19-all.jar"/>
<!-- debug properties -->
<property name="debug.enabled" value="on" />
<property name="debug.level" value="lines,vars,source" />
<!-- paths -->
<path id="project.class.path">
<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="checkstyle-6.19-all.jar"/>
</fileset>
<fileset dir="rtlib">
<include name="**/*.jar"/>
</fileset>
<dirset dir="build/classes">
<include name="**"/>
</dirset>
</path>
<path id="test.class.path">
<path refid="project.class.path" />
<dirset dir="build/tests">
<include name="**"/>
</dirset>
<dirset dir="./compile" />
</path>
<path id="src.paths">
<pathelement location="src/java" />
</path>
<property name="src.paths" refid="src.paths" />
<path id="src.parser.paths">
<pathelement location="build/java" />
<path refid="src.paths" />
</path>
<property name="src.parser.paths" refid="src.parser.paths" />
<!-- ensure target dirs exist -->
<target name="-init">
<mkdir dir="build/java/boa/parser" />
<mkdir dir="build/classes" />
<mkdir dir="build/depcache" />
<mkdir dir="build/tests" />
<mkdir dir="dist" />
<mkdir dir="./compile" />
</target>
<!-- do a dependency check -->
<target name="-check-deps">
<depend srcdir="src/test;src/compiled-proto;${src.paths};${src.parser.paths}" destdir="build/classes" cache="build/depcache" closure="yes" />
</target>
<!-- Protocol Buffers schemas -->
<target name="-check-protobuf">
<condition property="protobuf.uptodate">
<and>
<uptodate srcfile="src/proto/ast.proto" targetfile="src/compiled-proto/boa/types/Ast.java" />
<uptodate srcfile="src/proto/code.proto" targetfile="src/compiled-proto/boa/types/Code.java" />
<uptodate srcfile="src/proto/diff.proto" targetfile="src/compiled-proto/boa/types/Diff.java" />
<uptodate srcfile="src/proto/issues.proto" targetfile="src/compiled-proto/boa/types/Issues.java" />
<uptodate srcfile="src/proto/shared.proto" targetfile="src/compiled-proto/boa/types/Shared.java" />
<uptodate srcfile="src/proto/toplevel.proto" targetfile="src/compiled-proto/boa/types/Toplevel.java" />
<uptodate srcfile="src/proto/control.proto" targetfile="src/compiled-proto/boa/types/Control.java" />
</and>
</condition>
</target>
<target name="-translate-protobuf" depends="-check-protobuf" unless="protobuf.uptodate">
<echo level="error" message="Translating Protocol Buffer files to Java" />
<apply executable="protoc" parallel="true">
<arg value="--proto_path=${src.proto}" />
<arg value="--java_out=src/compiled-proto" />
<srcfile />
<fileset dir="${src.proto}" includes="*.proto" />
</apply>
</target>
<target name="compile-protobuf" depends="-init,-translate-protobuf,-check-deps" description="Compiles the generated protobuf code.">
<javac includeantruntime="true" srcdir="src/compiled-proto" destdir="build/classes" debug="${debug.enabled}" debuglevel="${debug.level}">
<classpath refid="project.class.path" />
</javac>
</target>
<target name="clean-proto" description="Clean the compiled protobuf files.">
<delete>
<fileset dir="build/classes">
<patternset>
<include name="boa/types/" />
<exclude name="boa/types/Boa*" />
<exclude name="boa/types/proto/*" />
</patternset>
</fileset>
</delete>
</target>
<!-- parser -->
<target name="-check-parser" depends="-init">
<condition property="parser.uptodate">
<and>
<uptodate srcfile="src/antlr/Boa.g4" targetfile="build/java/boa/parser/BoaParser.java" />
<uptodate srcfile="src/antlr/Boa.g4" targetfile="build/java/boa/parser/BoaLexer.java" />
<uptodate srcfile="src/antlr/Boa.g4" targetfile="build/java/boa/parser/BoaListener.java" />
</and>
</condition>
</target>
<target name="-parser" depends="-check-parser" unless="parser.uptodate">
<echo level="error" message="Generating parser code" />
<java jar="lib/antlr-${antlr.version}-complete.jar" dir="src/antlr/" fork="true" failonerror="true">
<arg value="-o" />
<arg value="../../build/java/boa/parser/" />
<arg value="-package" />
<arg value="boa.parser" />
<arg value="Boa.g4" />
</java>
</target>
<target name="compile-parser" depends="-parser,-check-deps" description="Compile the parser.">
<javac includeantruntime="true" srcdir="${src.parser.paths}" destdir="build/classes" debug="${debug.enabled}" debuglevel="${debug.level}">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<classpath refid="project.class.path" />
</javac>
</target>
<target name="clean-parser" description="Clean all generated/compiled parser files.">
<delete dir="build/java" />
<delete dir="build/classes/boa/parser" />
</target>
<!-- main compilation targets -->
<target name="compile" depends="compile-protobuf,compile-parser,-check-deps" description="Compile the compiler.">
<javac includeantruntime="true" srcdir="${src.paths}" destdir="build/classes" debug="${debug.enabled}" debuglevel="${debug.level}">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<classpath refid="project.class.path" />
</javac>
</target>
<target name="clean-src" description="Clean the compiled files (excluding protobuf and parser).">
<delete>
<fileset dir="build/classes">
<patternset>
<include name="boa/**" />
<exclude name="boa/parser/**" />
<exclude name="boa/types/**" />
</patternset>
</fileset>
<fileset dir="build/classes/boa/types">
<patternset>
<include name="Boa*" />
<include name="proto/**" />
</patternset>
</fileset>
</delete>
</target>
<!-- test targets -->
<target name="test" depends="test-compiler,test-functions,test-datagen" description="Run all unit tests.">
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen" depends="test-datagen-java,test-datagen-js,test-datagen-php" description="Run datagen unit tests.">
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen-general" depends="-compile-tests" description="Run non-language-specific datagen unit tests.">
<parallel>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.datagen.TestBuildSnapshot1">
<formatter type="plain" usefile="false" />
</test>
</junit>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.datagen.TestBuildSnapshot2">
<formatter type="plain" usefile="false" />
</test>
</junit>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.datagen.TestBuildSnapshot3">
<formatter type="plain" usefile="false" />
</test>
</junit>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.datagen.TestBuildSnapshot4">
<formatter type="plain" usefile="false" />
</test>
</junit>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/datagen/Test*.class" />
<exclude name="**/*$*.class" />
<exclude name="**/TestBuildSnapshot?.class" />
</fileset>
</batchtest>
</junit>
</parallel>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen-queries" depends="package,-compile-tests" description="Run non-language-specific datagen query unit tests.">
<parallel>
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/datagen/queries/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
</parallel>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen-java" depends="-compile-tests" description="Run Java datagen unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/datagen/java/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen-js" depends="-compile-tests" description="Run JavaScript datagen unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/datagen/js/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-datagen-php" depends="-compile-tests" description="Run PHP datagen unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/datagen/php/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-compiler" depends="-compile-tests" description="Run all compiler unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/compiler/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-lexer" depends="-compile-tests" description="Run lexer unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestLexerBad">
<formatter type="plain" usefile="false" />
</test>
<test name="boa.test.compiler.TestLexerGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-parser" depends="-compile-tests" description="Run parser unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestParserBad">
<formatter type="plain" usefile="false" />
</test>
<test name="boa.test.compiler.TestParserGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-typecheck" depends="-compile-tests" description="Run typechecker unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestTypecheckBad">
<formatter type="plain" usefile="false" />
</test>
<test name="boa.test.compiler.TestTypecheckGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-inhattr" depends="-compile-tests" description="Run inherited attribute unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestInhAttr">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-codegen" depends="-compile-tests" description="Run code generation unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestCodegenGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-traversal" depends="-compile-tests" description="Run traversal unit tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestTraversalGood">
<formatter type="plain" usefile="false" />
</test>
<test name="boa.test.compiler.TestTraversalBad">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-program-analysis" depends="-compile-tests" description="Run program analysis programs.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.ProgramAnalysisGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-knowngood" depends="-compile-tests" description="Run known good tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<test name="boa.test.compiler.TestGood">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-functions" depends="-compile-tests" description="Run intrinsic functions tests.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<classpath refid="test.class.path" />
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="build/tests">
<include name="boa/test/functions/Test*.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="test-specific" depends="-compile-tests" description="Run a specific test case.">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed">
<sysproperty key="test.args" value="${test.args}" />
<classpath refid="test.class.path" />
<test name="${test.case}">
<formatter type="plain" usefile="false" />
</test>
</junit>
<delete file="SecurityAuth.audit" />
<fail message="Test failure detected." if="test.failed" />
</target>
<target name="-compile-tests" depends="compile,-check-deps">
<javac includeantruntime="true" srcdir="src/test" destdir="build/tests" debug="${debug.enabled}" debuglevel="${debug.level}">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<classpath refid="project.class.path" />
</javac>
</target>
<target name="clean-tests" description="Clean the compiled test files.">
<delete dir="build/tests" />
</target>
<!-- debug targets -->
<target name="java-to-boa" depends="-compile-tests" description="Convert Java code to Boa AST.">
<java classname="boa.test.datagen.java.JavaToBoa" fork="true" failonerror="true">
<classpath refid="test.class.path" />
<arg value="${java.code}" />
</java>
</target>
<target name="dump-java" depends="-compile-tests" description="Parse and dump Java AST.">
<java classname="boa.test.datagen.java.DumpJava" fork="true" failonerror="true">
<classpath refid="test.class.path" />
<arg value="${java.code}" />
</java>
</target>
<!-- style checking -->
<target name="checkstyle">
<checkstyle config="checkstyle.xml">
<fileset dir="src/java/boa" includes="**/*.java"/>
<fileset dir="src/test" includes="**/*.java"/>
<formatter type="plain"/>
</checkstyle>
</target>
<!-- packaging -->
<target name="git.revision" description="Store git revision in ${repository.version}">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="log" />
<arg value="-1" />
<arg value="--pretty=format:%H" />
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater" />
</and>
</condition>
</target>
<target name="git.branch" description="Store git branch in ${repository.branch}">
<exec executable="git" outputproperty="git.branch" failifexecutionfails="false" errorproperty="">
<arg value="branch" />
<arg value="--show-current" />
</exec>
<condition property="repository.branch" value="${git.branch}" else="unknown">
<and>
<isset property="git.branch"/>
<length string="${git.branch}" trim="yes" length="0" when="greater" />
</and>
</condition>
</target>
<target name="package" depends="package-runtime,package-compiler" description="Package both the compiler and runtime JARs."/>
<target name="package-runtime" depends="compile,git.branch,git.revision" description="Package the runtime JAR.">
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HH:mm:ss"/>
</tstamp>
<jar destfile="dist/boa-runtime.jar">
<manifest>
<section name="boa">
<attribute name="Boa-Compiler-Branch" value="${repository.branch}" />
<attribute name="Boa-Compiler-Commit" value="${repository.version}" />
<attribute name="Boa-Compiler-CompiledDate" value="${time.stamp}" />
</section>
</manifest>
<fileset dir="build/classes">
<patternset>
<include name="boa/" />
<include name="com/" />
<exclude name="**/compiler/" />
<exclude name="**/parser/" />
<exclude name="**/boa/types/proto/" />
<exclude name="**/boa/types/Boa*" />
</patternset>
</fileset>
</jar>
</target>
<target name="package-compiler" depends="compile,git.branch,git.revision" description="Package the compiler JAR.">
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HH:mm:ss"/>
</tstamp>
<jar destfile="dist/boa-compiler.jar">
<manifest>
<attribute name="Main-Class" value="boa.BoaMain" />
<section name="boa">
<attribute name="Boa-Compiler-Branch" value="${repository.branch}" />
<attribute name="Boa-Compiler-Commit" value="${repository.version}" />
<attribute name="Boa-Compiler-CompiledDate" value="${time.stamp}" />
</section>
</manifest>
<fileset dir="build/classes" />
<fileset dir="conf" />
<fileset dir="templates" />
<fileset dir=".">
<patternset>
<include name="templates/" />
</patternset>
</fileset>
<zipfileset excludes="META-INF/" src="rtlib/antlr-runtime-${antlr.version}.jar" />
<zipfileset excludes="META-INF/" src="rtlib/commons-cli-1.2.jar" />
<zipfileset excludes="META-INF/" src="rtlib/log4j-1.2.15.jar" />
<zipfileset excludes="META-INF/" src="rtlib/protobuf-java-2.5.0.jar" />
<zipfileset excludes="META-INF/" src="rtlib/scannotation-1.0.3.jar" />
<zipfileset excludes="META-INF/" src="rtlib/ST-4.0.8.jar" />
</jar>
</target>
<target name="clean-dist" description="Clean all JAR files.">
<delete dir="dist" />
</target>
<!-- project cleanup -->
<target name="clean" description="Clean all generated/compiled files.">
<delete dir="build" />
<delete dir="dist" />
</target>
</project>