-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
420 lines (369 loc) · 15.8 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
<?xml version="1.0"?>
<project name="javarifier" default="jarfile">
<description>
Rules for building and testing Javarifier.
For a list of targets, run: ant -projecthelp
</description>
<property environment="env"/>
<!-- wouldn't ${basedir} be better than setting this? -->
<dirname property="ant.file.dir" file="${ant.file}"/>
<property name="tmpdir" value="${java.io.tmpdir}/${user.name}/javarifier-temp" />
<property name="temp-bin" value="${tmpdir}/bin"/>
<property name="distdir" value="${tmpdir}/javarifier"/>
<property name="javari-www"
value="/cse/www2/types/javari/"/>
<property name="javari-www-javarifier"
value="/cse/www2/types/javari/javarifier"/>
<condition property="jdkName" value="jdk8.jar">
<contains string="${java.version}" substring="1.8"/>
</condition>
<condition property="jdkName" value="jdk7.jar">
<and>
<not><isset property="jdkName"/></not>
<contains string="${java.version}" substring="1.7"/>
</and>
</condition>
<condition property="jdkName" value="jdk6.jar">
<not><isset property="jdkName"/></not>
</condition>
<!-- Determine locations of all projects, as per the property files. -->
<target name="init-properties" description="Initialize required properties">
<condition property="exists.build.properties">
<available file="build.properties"/>
</condition>
<fail
unless="exists.build.properties"
message="Local build.properites file is missing."/>
<property name="workspace" location="${ant.file.dir}/.."/>
<property file="build.properties"/>
<fail
unless="global.build.properties"
message="Local build.properties file did not define global buildfile in property global.build.properties"/>
<condition property="exists.global.build.properties">
<available file="${global.build.properties}"/>
</condition>
<fail
unless="exists.global.build.properties"
message="File ${global.build.properties} file not found."/>
<property file="${global.build.properties}"/>
<fail
unless="user.build.properties"
message="Local build.properties file did not define global buildfile in property user.build.properties"/>
<condition property="exists.user.build.properties">
<available file="${user.build.properties}"/>
</condition>
<fail
unless="exists.user.build.properties"
message="File ${user.build.properties} file not found."/>
<property file="${user.build.properties}"/>
<property name="jsr308-javac" location="${annotations-compiler}/dist/bin/javac" />
<property name="checkers-javac" location="${checkerframework}/checker/bin/javac" />
<condition property="javac" value="${jsr308-javac}" else="${checkers-javac}">
<available file="${jsr308-javac}"/>
</condition>
<path id="sourcepath">
<pathelement location="src"/>
</path>
<path id="javadoc-sourcepath">
<pathelement location="src"/>
</path>
<path id="libpath">
<!-- Make our copy of plume.jar override any subsequent ones on the path. -->
<pathelement location="${javarifier}/lib/plume.jar"/>
<!-- <pathelement location="${javari-annotated-jdk}/bin"/> -->
<!-- <pathelement location="${annotations-shared}/bin"/> -->
<pathelement location="${checkerframework}/checker/build"/>
<pathelement location="${checkerframework}/checker/jdk/javari/build"/>
<pathelement location="${annotations-compiler}/dist/lib/javac.jar"/>
<pathelement location="${afu}/annotation-file-utilities.jar"/>
<pathelement location="${javarifier}/bin"/>
<pathelement location="${javarifier}/lib/jasminclasses-2.4.0.jar"/>
<pathelement location="${javarifier}/lib/polyglotclasses-1.3.5.jar"/>
<pathelement location="${javarifier}/lib/sootclasses-2.4.0.jar"/>
</path>
</target>
<target name="build-dependencies" depends="init-properties"
description="Builds all projects this depends on"
unless="build.dependencies.not">
<ant dir="${afu}" target="jarfile" inheritAll="false"/>
<ant dir="${annotations-compiler}" antfile="make/build.xml"
inheritAll="false" target="build"/>
<ant dir="${checkerframework}/checker" target="build" inheritAll="false"/>
</target>
<target name="init" depends="init-properties, build-dependencies"
description="Initialize properties and build required projects">
</target>
<target name="jarfile" depends="init,bin"
description="Build jarfile containing all Javarifier classes.">
<echo message="Using temporary directory: ${temp-bin}"/>
<delete dir="${temp-bin}"/>
<mkdir dir="${temp-bin}"/>
<echo message="Copying over necessary files to ${temp-bin}"/>
<unjar src="${afu}/annotation-file-utilities.jar"
dest="${temp-bin}"/>
<!-- There is also a copy of plume in annotation-file-utilities; make
ours override it. -->
<unjar src="${javarifier}/lib/plume.jar"
dest="${temp-bin}"/>
<unjar src="${javarifier}/lib/jasminclasses-2.4.0.jar"
dest="${temp-bin}"/>
<unjar src="${javarifier}/lib/polyglotclasses-1.3.5.jar"
dest="${temp-bin}"/>
<unjar src="${javarifier}/lib/sootclasses-2.4.0.jar"
dest="${temp-bin}"/>
<copy todir="${temp-bin}">
<fileset dir="${javarifier}/bin" />
</copy>
<!-- Create a single .jar file of all the class files,
scripts, and documentation -->
<echo message="Creating jarfile javarifier.jar"/>
<jar
destfile="${javarifier}/javarifier.jar">
<fileset dir="${temp-bin}"/>
</jar>
<!-- Delete class files copied over -->
<echo message="Deleting temporary directory: ${temp-bin}"/>
<delete includeEmptyDirs="true">
<fileset dir="${temp-bin}"/>
</delete>
</target>
<target name="zipfile" depends="init,jarfile,update-opt-doc"
description="Build zipfile containing Javarifier distribution">
<!-- Create a new directory containing all the files and then zip that
directory, so that when the user unzips they extract exactly one
directory. -->
<exec executable="git" failonerror="true" outputproperty="git-status-output">
<arg value="status"/>
</exec>
<condition property="git-needs-commit">
<not><equals arg1="${git-status-output}" arg2=""/></not>
</condition>
<fail if="git-needs-commit">Uncommitted changes; do "git commit" before "ant zipfile"</fail>
<!-- Not necessary because so long as the changes are committed, they
will show up in the zipfile.
<exec executable="git" resultproperty="git-outgoing-exit-status">
<arg value="outgoing"/>
</exec>
<condition property="git-outgoing-exists">
<equals arg1="${git-outgoing-exit-status}" arg2="0"/>
</condition>
<fail if="git-outgoing-exit-status">push changes before making a zipfile</fail>
-->
<delete dir="${distdir}"/>
<exec executable="git">
<arg value="clone"/>
<arg value="."/>
<arg value="${distdir}"/>
</exec>
<delete dir=".git"/>
<!-- Put symbolic links in place -->
<symlink link="${tmpdir}/annotation-tools"
resource="${ant.file.dir}/../annotation-tools"
overwrite="true" failonerror="true" />
<symlink link="${tmpdir}/checker-framework"
resource="${ant.file.dir}/../checker-framework"
overwrite="true" failonerror="true" />
<symlink link="${tmpdir}/jsr308-langtools"
resource="${ant.file.dir}/../jsr308-langtools"
overwrite="true" failonerror="true" />
<ant dir="${distdir}" target="jarfile" inheritAll="false"/>
<!-- In order for the Unix tools to have the proper execution bit set,
include them specifically with the right permissions. Ant presently
does not use the file's permissions themselves to do this. -->
<zip destfile="javarifier.zip" compress="true">
<fileset dir="${tmpdir}">
<include name="javarifier/**"/>
<exclude name="javarifier/scripts/javarifier"/>
</fileset>
<zipfileset dir="${tmpdir}" filemode="755">
<include name="javarifier/scripts/javarifier"/>
</zipfileset>
</zip>
<!-- Delete temporary files once they have been zipped. -->
<delete includeEmptyDirs="true">
<fileset dir="${distdir}"/>
</delete>
</target>
<!-- Create zipfile and export it and instructions to webpage. -->
<target name="web" depends="export" description="Same as export"/>
<!-- Alternately, if you have no direct access to /cse/www2/types, just run:
scp javarifier.html javarifier.zip [email protected]:/cse/www2/types/javarifier/
-->
<target name="export" depends="clean,zipfile"
description="Build distribution and export it to website">
<echo message="Export location: ${javari-www-javarifier}"/>
<copy todir="${javari-www-javarifier}">
<fileset file="javarifier.zip" />
<fileset file="javarifier.html" />
</copy>
<chmod file="${javari-www-javarifier}/javarifier.zip" perm="g+w" />
<chmod file="${javari-www-javarifier}/javarifier.html" perm="g+w" />
<echo message="Checking HTML links"/>
<exec executable="/homes/gws/mernst/bin/src/plume-lib/bin/checklink">
<arg value="-q"/>
<arg value="-r"/>
<arg value="https://types.cs.washington.edu/javari/"/>
</exec>
</target>
<!-- Remove all generated files. -->
<target name="clean" depends="init-properties"
description="Remove all generated files.">
<delete dir="bin"/>
<echo message="Deleting temporary directories"/>
<delete dir="${temp-bin}" includeEmptyDirs="true"/>
<delete dir="${distdir}" includeEmptyDirs="true"/>
<echo message="Deleting previous distribution: javarifier.zip"/>
<delete file="javarifier.zip"/>
<delete file="javarifier.jar"/>
<exec executable="make"
failonerror="true">
<arg value="-C"/>
<arg value="${javarifier}/tests"/>
<arg value="clean"/>
</exec>
</target>
<target name="bin" depends="init"
description="Compiles Javarifier classes">
<mkdir dir="bin"/>
<copy todir="bin">
<fileset dir="src" excludes="**/*.java"/>
</copy>
<javac destdir="bin"
debug="on"
fork="true"
includeantruntime="false">
<src refid="sourcepath"/>
<classpath refid="libpath"/>
<compilerarg value="-J-Xmx1024M"/>
<!-- <compilerarg value="-Xlint"/> -->
<compilerarg value="-g"/>
</javac>
<!-- let other tasks know when the compilation was last performed -->
<touch file=".compile-timestamp" />
</target>
<target name="javadoc" depends="init"
description="Create Javadoc documentation">
<mkdir dir="doc"/>
<javadoc destdir="doc"
failonerror="true">
<sourcepath refid="javadoc-sourcepath"/>
<classpath refid="libpath"/>
</javadoc>
</target>
<target name="update-opt-doc" depends="init"
description="Update the options documentation in the manual">
<property name="libpath" refid="libpath"/>
<javadoc sourcefiles="src/javarifier/Main.java,src/javarifier/OutputFormat.java" failonerror="true">
<doclet name="plume.OptionsDoclet">
<param name="-docfile" value="javarifier.html"/>
</doclet>
<classpath refid="libpath"/>
<arg value="-quiet"/>
<arg value="-i"/>
<!--
This parameter is a hack. The bootclasspath does not include the classpath
specified on the command-line, hence we prepend it ourselves.
-->
<arg value="-J-Xbootclasspath/p:${libpath}"/>
</javadoc>
</target>
<!-- WARNING: This target does not re-compile! (It does not depend on
"bin" or other similar targets.) -->
<target name="run-tests" depends="init-properties"
description="Runs Javarifier test cases">
<exec executable="make"
failonerror="true">
<arg value="-C"/>
<arg value="${javarifier}/tests"/>
<!-- The Hudson job fails if the JAVAC environment variable is not
set. When Ant is invoked from the command line, the Makefile
can infer a value if the JAVAC environment variable is not set. -->
<env key="JAVAC" file="${javac}" />
<env key="LANGTOOLS" path="${annotations-compiler}"/>
<env key="CLASSPATH" path="${toString:libpath}"/>
<env key="CHECKER_FRAMEWORK" path="${checkerframework}"/>
<env key="AFU" path="${afu}"/>
<env key="JRE_HOME" path="${java.home}"/>
<env key="JDK_NAME" path="${jdkName}"/>
<env key="PATH" path="${afu}/scripts:${env.PATH}"/>
</exec>
</target>
<target name="run-tests-toplevel" depends="init-properties"
description="Runs Javarifier toplevel test cases, including type-checking">
<exec executable="make"
failonerror="true">
<arg value="-k"/>
<arg value="-C"/>
<arg value="${javarifier}/tests"/>
<arg value="showvars"/>
<arg value="clean-toplevel"/>
<arg value="toplevel-all"/>
<env key="JAVAC" file="${javac}" />
<env key="CLASSPATH" path="${checkerframework}/checker/bin/checker.jar"/>
<env key="CHECKER_FRAMEWORK" path="${checkerframework}"/>
<env key="AFU" path="${afu}"/>
<env key="JRE_HOME" path="${java.home}"/>
<env key="PATH" path="${afu}/scripts:${env.PATH}"/>
</exec>
</target>
<!-- There is no
description="Runs Javarifier toplevel test cases with debugging"
so that this does not appear in the standard "ant -projecthelp" output.
-->
<target name="run-tests-toplevel-debug" depends="init-properties">
<exec executable="make"
failonerror="true">
<arg value="-k"/>
<arg value="-C"/>
<arg value="${javarifier}/tests"/>
<arg value="showvars"/>
<arg value="clean-toplevel"/>
<arg value="toplevel-all"/>
<env key="JAVAC" file="${javac}" />
<env key="CLASSPATH" path="${checkerframework}/checker/bin/checker.jar"/>
<env key="CHECKER_FRAMEWORK" path="${checkerframework}"/>
<env key="AFU" path="${afu}"/>
<env key="JRE_HOME" path="${java.home}"/>
<env key="PATH" path="${afu}/scripts:${env.PATH}"/>
<env key="DEBUG_INSERT_ANNOTATIONS" value="--debug"/>
</exec>
</target>
<target name="etags" depends="tags">
</target>
<target name="tags" description="Create Emacs TAGS table">
<exec executable="/bin/sh">
<arg value="-c"/>
<arg value="etags `find src -name '*.java'`"/>
</exec>
</target>
<!-- TODO: fix dependencies so that this task will build Javarifier
as needed. -->
<!-- TODO: this should really run the script, not try to emulate it. -->
<target name="javarify" depends="init-properties"
description="Runs Javarifier. (Arguments: class names to javarify)">
<property name="soot-programs" value="${user-soot-programs}:."/>
<property name="soot-stubs" value="${user-soot-stubs}:${checkerframework}/checker/jdk/javari/build"/>
<property name="soot-worlds" value="${user-soot-worlds}:${jre1.6.0}"/>
<!-- Set classpath of Javarifier to use for running Javarifier, not
the classpath to search when analyzing. -->
<java classname="javarifier.Main" classpathref="libpath" fork="yes">
<assertions>
<enable/>
</assertions>
<!-- Needed to javarify large programs. -->
<jvmarg value="-Xmx512m"/>
<!-- Soot's classpath options. -->
<arg line="-programCPEntries ${soot-programs}"/>
<arg line="-defaultStubCPEntries ${soot-stubs}"/>
<arg line="-defaultWorldCPEntries ${soot-worlds}"/>
<!-- The user's args is just the name of class to javarify. -->
<arg line="${user-args}"/>
</java>
</target>
<!-- Print Ant properties (for debugging) -->
<!-- No "description" element so that it doesn't appear in standard
"ant -projecthelp" output. -->
<target name="echoproperties" depends="init-properties" >
<echoproperties/>
</target>
</project>