forked from javapathfinder/jpf-core
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.xml
456 lines (367 loc) · 17.9 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
<?xml version="1.0" ?>
<!--
build.xml - the JPF core build script
using Ant (http://jakarta.apache.org/ant)
public targets:
build (default) compile classes and build JPF jar files
compile compile JPF and its specific (modeled) environment libraries
test run all JPF tests
clean remove the files that have been generated by the build process
buildinfo create buildinfo properties file
-->
<project name="jpf-core" default="build" basedir=".">
<!-- ===================== ===== COMMON SECTION ========================== -->
<!--
local props have to come first, because Ant properties are immutable
NOTE: this file is local - it is never in the repository!
-->
<property file="local.properties"/>
<property environment="env"/>
<!-- compiler settings -->
<property name="debug" value="on"/>
<property name="deprecation" value="on"/>
<uptodate property="build_uptodate" targetfile="build/main/gov/nasa/jpf/build.properties" srcfile="build.properties"/>
<!-- generic classpath settings -->
<path id="lib.path">
<pathelement location="build/main"/>
<pathelement location="build/peers"/>
<pathelement location="build/annotations"/>
<fileset dir=".">
<include name="lib/*.jar"/>
</fileset>
</path>
<!-- init: common initialization -->
<target name="-init">
<tstamp/>
<mkdir dir="build"/> <!-- the build root -->
<!-- the things that have to be in the classpath of whatever runs Ant -->
<available property="have_javac" classname="com.sun.tools.javac.Main"/>
<fail unless="have_javac">no javac was found __or__ check http://babelfish.arc.nasa.gov/trac/jpf/wiki/install/build for possible solutions</fail>
<available file="src/main" type="dir" property="have_main"/>
<available file="src/annotations" type="dir" property="have_annotations"/>
<available file="src/peers" type="dir" property="have_peers"/>
<available file="src/classes" type="dir" property="have_classes"/>
<available file="src/tests" type="dir" property="have_tests"/>
<available file="src/examples" type="dir" property="have_examples"/>
<available file=".hg" type="dir" property="have_hg"/>
<!-- for the core, it's a fail if any of these is missing -->
<fail unless="have_main">no src/main</fail>
<fail unless="have_annotations">no src/annotations</fail>
<fail unless="have_peers">no src/peers</fail>
<fail unless="have_classes">no src/classes</fail>
<fail unless="have_tests">no src/tests</fail>
<fail unless="have_examples">no src/examples</fail>
<condition property="have_java8">
<equals arg1="${ant.java.version}" arg2="1.8"/>
</condition>
</target>
<!-- ======================= COMPILE SECTION ============================= -->
<!-- public compile -->
<target name="compile" depends="-init,-compile-annotations,-compile-main,-compile-peers,-compile-classes,-compile-tests,-compile-examples"
description="compile all JPF core sources" >
<copy file="build.properties" todir="build/main/gov/nasa/jpf" failonerror="false"/>
</target>
<target name="-compile-annotations" if="have_annotations">
<mkdir dir="build/annotations"/>
<javac srcdir="src/annotations" destdir="build/annotations" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}" classpath=""/>
</target>
<target name="-compile-main" if="have_main">
<mkdir dir="build/main"/>
<javac srcdir="src/main" destdir="build/main" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
<!--
<compilerarg value="-XDenableSunApiLintControl"/>
<compilerarg value="-Xlint:all"/>
-->
</javac>
</target>
<target name="-compile-peers" if="have_peers" depends="-compile-main" >
<mkdir dir="build/peers"/>
<javac srcdir="src/peers" destdir="build/peers" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
<compilerarg value="-XDenableSunApiLintControl"/>
<compilerarg value="-Xlint:all,-sunapi,-serial"/>
</javac>
</target>
<target name="-compile-classes" if="have_classes" depends="-compile-annotations,-compile-main" >
<mkdir dir="build/classes"/>
<javac srcdir="src/classes" destdir="build/classes" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}">
<compilerarg value="-XDenableSunApiLintControl"/>
<compilerarg value="-Xlint:all,-sunapi"/>
<classpath>
<path refid="lib.path"/>
<pathelement location="build/annotations"/>
</classpath>
</javac>
</target>
<target name="-compile-tests" if="have_tests" depends="-compile-annotations,-compile-main,-compile-classes">
<mkdir dir="build/tests"/>
<javac sourcepath="" srcdir="src/tests" destdir="build/tests" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}"
includes="*,gov/nasa/jpf/**,classloader_specific_tests/**">
<compilerarg value="-XDenableSunApiLintControl"/>
<compilerarg value="-Xlint:all,-sunapi,-serial,-rawtypes,-unchecked"/>
<include name="*gov/nasa/jpf/**"/>
<include name="classloader_specific_tests/**"/>
<include name="java8/**" if="have_java8"/>
<classpath>
<path refid="lib.path"/>
<pathelement location="build/annotations"/>
<pathelement location="build/classes"/>
</classpath>
</javac>
</target>
<target name="-compile-examples" if="have_examples" depends="-compile-annotations,-compile-main">
<mkdir dir="build/examples" />
<javac srcdir="src/examples" destdir="build/examples" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}"
classpathref="lib.path"/>
</target>
<!-- ======================= MISC SECTION ================================ -->
<target name="-version" if="have_hg">
<exec executable="hg" outputproperty="version" searchpath="true" failonerror="false" failifexecutionfails="false">
<arg value="identify"/>
<arg value="-n"/>
</exec>
<!-- .version is in .hgignore -->
<echo message="${version}${line.separator}" file=".version"/>
</target>
<!-- build jars -->
<target name="build" depends="-cond-clean,compile,-version"
description="generate the core JPF jar files" >
<copy file=".version" todir="build/main/gov/nasa/jpf" failonerror="false"/>
<jar jarfile="build/jpf-classes.jar">
<fileset dir="build/classes"/>
<fileset dir="build/annotations"/>
<fileset dir="build/main">
<!-- we need this one in case a SUT uses the Verify API -->
<include name="gov/nasa/jpf/vm/Verify.class"/>
<!-- these are required if we run TestJPF derived test classes -->
<include name="gov/nasa/jpf/JPFShell.class"/>
<include name="gov/nasa/jpf/util/TypeRef.class"/>
<include name="gov/nasa/jpf/util/test/TestJPF.class"/>
<include name="gov/nasa/jpf/util/test/TestMultiProcessJPF.class"/>
<include name="gov/nasa/jpf/util/test/TestJPFHelper.class"/>
</fileset>
</jar>
<jar jarfile="build/jpf.jar" index="true">
<fileset dir="build/main"/>
<fileset dir="build/peers"/>
<!-- this is redundant, but if JPF is executed from java.class.path it wouldn't find annotations -->
<fileset dir="build/annotations"/>
<!-- this is for annotations used by JPF regression tests, which can also be executed outside of junit -->
<fileset dir="build/classes">
<include name="org/junit/*.class"/>
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
<attribute name="Implementation-Title" value="Java Pathfinder core system"/>
<attribute name="Implementation-Version" value="${jpf.version}"/>
</manifest>
</jar>
<!-- optional jar that contains annotations to be used in non-JPF dependent apps -->
<jar jarfile="build/jpf-annotations.jar">
<fileset dir="build/annotations"/>
</jar>
<!-- this jar is needed to test classloaders, it is used by URLClassLoaderTest -->
<jar jarfile="build/classloader_specific_tests.jar">
<fileset dir="build/tests">
<include name="classloader_specific_tests/*.class"/>
</fileset>
</jar>
<jar jarfile="build/RunJPF.jar">
<fileset dir="build/main">
<include name="gov/nasa/jpf/tool/Run.class"/>
<include name="gov/nasa/jpf/tool/RunJPF.class"/>
<include name="gov/nasa/jpf/Config.class"/>
<include name="gov/nasa/jpf/ConfigChangeListener.class"/>
<include name="gov/nasa/jpf/Config$MissingRequiredKeyException.class"/>
<include name="gov/nasa/jpf/JPFClassLoader.class"/>
<include name="gov/nasa/jpf/JPFShell.class"/>
<include name="gov/nasa/jpf/JPFException.class"/>
<include name="gov/nasa/jpf/JPFConfigException.class"/>
<include name="gov/nasa/jpf/JPFTargetException.class"/>
<include name="gov/nasa/jpf/util/JPFSiteUtils.class"/>
<include name="gov/nasa/jpf/util/FileUtils.class"/>
<include name="gov/nasa/jpf/util/StringMatcher.class"/>
<include name="gov/nasa/jpf/util/Pair.class"/>
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
<attribute name="Implementation-Title" value="Java Pathfinder core launch system"/>
<attribute name="Implementation-Version" value="${jpf.version}"/>
<attribute name="Main-Class" value="gov.nasa.jpf.tool.RunJPF"/>
</manifest>
</jar>
<jar jarfile="build/RunTest.jar">
<fileset dir="build/main">
<include name="gov/nasa/jpf/tool/Run.class"/>
<include name="gov/nasa/jpf/tool/RunTest.class"/>
<include name="gov/nasa/jpf/tool/RunTest$Failed.class"/>
<include name="gov/nasa/jpf/Config.class"/>
<include name="gov/nasa/jpf/ConfigChangeListener.class"/>
<include name="gov/nasa/jpf/Config$MissingRequiredKeyException.class"/>
<include name="gov/nasa/jpf/JPFClassLoader.class"/>
<include name="gov/nasa/jpf/JPFException.class"/>
<include name="gov/nasa/jpf/JPFConfigException.class"/>
<include name="gov/nasa/jpf/util/JPFSiteUtils.class"/>
<include name="gov/nasa/jpf/util/FileUtils.class"/>
<include name="gov/nasa/jpf/util/StringMatcher.class"/>
<include name="gov/nasa/jpf/util/DevNullPrintStream.class"/>
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
<attribute name="Implementation-Title" value="Java Pathfinder test launch system"/>
<attribute name="Implementation-Version" value="${jpf.version}"/>
<attribute name="Main-Class" value="gov.nasa.jpf.tool.RunTest"/>
</manifest>
</jar>
</target>
<!-- public clean: cleanup from previous tasks/builds -->
<target name="clean"
description="remove all build artifacts and temporary files">
<delete dir="build" failonerror="false"/>
<delete dir="tmp" failonerror="false"/>
<delete>
<fileset dir="." includes="**/*~" defaultexcludes="no" />
<fileset dir="." includes="**/*.bak" defaultexcludes="no" />
<fileset dir="." includes="**/error.xml" />
</delete>
</target>
<target name="-cond-clean" unless="build_uptodate"
description="remove all build artifacts and temporaries if build.properties has been changed">
<antcall target="clean"/>
</target>
<!-- generate buildinfo file -->
<target name="buildinfo" description="create buildinfo properties">
<!-- make this fail if there are uncommitted changes -->
<exec executable="hg" outputproperty="uncommitted_changes" failifexecutionfails="true">
<arg value="status"/>
</exec>
<condition property="have_uncommitted_changes">
<length string="${uncommitted_changes}" trim="true" when="greater" length="0"/>
</condition>
<!--
<fail if="have_uncommitted_changes">hg status shows uncommitted changes:
${uncommitted_changes}
</fail>
-->
<exec executable="hg" outputproperty="hg.tip.id" failifexecutionfails="false">
<arg value="tip"/>
<arg value="--template"/>
<arg value="{rev}:{node|short}\n"/>
</exec>
<exec executable="hg" outputproperty="hg.author" failifexecutionfails="false">
<arg value="tip"/>
<arg value="--template"/>
<arg value="{author}\n"/>
</exec>
<exec executable="hg" outputproperty="hg.tip.date" failifexecutionfails="false">
<arg value="tip"/>
<arg value="--template"/>
<arg value="{date|isodate}\n"/>
</exec>
<exec executable="hg" outputproperty="hg.paths.default" failifexecutionfails="false">
<arg value="showconfig"/>
<arg value="paths.default"/>
</exec>
<exec executable="hostname" failifexecutionfails="false" outputproperty="env.COMPUTERNAME"/>
<property name="hostname" value="${env.COMPUTERNAME}"/> <!-- Windows doesn't have hostname -->
<!-- it seems the 'propertyfile' task just appends -->
<delete file="build.properties" failonerror="false"/>
<propertyfile file="build.properties" comment="JPF core build info">
<entry key="revision" value="${hg.tip.id}"/>
<entry key="date.tip" value="${hg.tip.date}"/>
<entry key="author" value="${hg.author}"/>
<entry key="repository" value="file://${hostname}${basedir}"/>
<entry key="upstream" value="${hg.paths.default}"/>
<entry key="java.version" value="${java.version}"/>
<entry key="os.arch" value="${os.arch}"/>
<entry key="os.name" value="${os.name}"/>
<entry key="os.version" value="${os.version}"/>
<entry key="user.country" value="${user.country}"/>
</propertyfile>
</target>
<target name="dist" description="build binary distribution">
<delete file="build/${ant.project.name}*.zip"/>
<exec executable="hg" outputproperty="hg.tip.rev" failifexecutionfails="false">
<arg value="tip"/>
<arg value="--template"/>
<arg value="-r{rev}"/>
</exec>
<!-- 2do this seems stupid - there needs to be a better way to re-base (zip basedir fails miserably) -->
<zip destfile="build/${ant.project.name}${hg.tip.rev}.zip" update="false" excludes="*">
<zipfileset file="jpf.properties" prefix="${ant.project.name}"/>
<zipfileset file="build.properties" prefix="${ant.project.name}"/>
<zipfileset dir="lib" prefix="${ant.project.name}/lib"/>
<zipfileset dir="bin" prefix="${ant.project.name}/bin" filemode="754"/>
<zipfileset dir="build" includes="*.jar" prefix="${ant.project.name}/build"/>
</zip>
</target>
<target name="src-dist" description="build source distribution">
<delete file="build/${ant.project.name}*-src.zip"/>
<exec executable="hg" outputproperty="hg.tip.rev" failifexecutionfails="false">
<arg value="tip"/>
<arg value="--template"/>
<arg value="-r{rev}"/>
</exec>
<zip destfile="build/${ant.project.name}${hg.tip.rev}-src.zip" update="false" excludes="*" whenempty="skip">
<zipfileset file="jpf.properties" prefix="${ant.project.name}"/>
<zipfileset file="build.properties" prefix="${ant.project.name}"/>
<zipfileset file="build.xml" prefix="${ant.project.name}"/>
<zipfileset file="LICENSE-2.0.txt" prefix="${ant.project.name}"/>
<zipfileset file="README" prefix="${ant.project.name}"/>
<zipfileset dir="src" prefix="${ant.project.name}/src"/>
<zipfileset dir="lib" prefix="${ant.project.name}/lib" erroronmissingdir="false"/>
<zipfileset dir="bin" prefix="${ant.project.name}/bin" filemode="754"/>
<zipfileset dir="tools" prefix="${ant.project.name}/tools" erroronmissingdir="false"/>
<!-- IDE related configuration files -->
<zipfileset file=".project" prefix="${ant.project.name}"/>
<zipfileset file=".classpath" prefix="${ant.project.name}"/>
<zipfileset dir="eclipse" prefix="${ant.project.name}/eclipse"/>
<zipfileset dir="nbproject" prefix="${ant.project.name}/nbproject"/>
</zip>
</target>
<!-- ======================= TEST SECTION ================================ -->
<target name="test" depends="build"
description="run core regression tests" if="have_tests">
<!-- note this can be directly set in local.properties, which overrides this setting -->
<property name="junit.home" value="${env.JUNIT_HOME}"/>
<condition property="junit.usefile">
<!-- don't set if this is running from within an IDE that collects output -->
<not>
<isset property="netbeans.home"/>
</not>
</condition>
<junit printsummary="on" showoutput="off"
haltonfailure="no" logfailedtests="true" failureproperty="test.failed"
dir="${basedir}" fork="yes" forkmode="perTest" maxmemory="1024m" outputtoformatters="true">
<formatter type="plain" usefile="${junit.usefile}"/>
<assertions>
<enable/>
</assertions>
<classpath>
<path refid="lib.path"/>
<pathelement location="build/tests"/>
<pathelement location="build/classes"/>
<pathelement location="build/annotations"/>
<fileset dir="${junit.home}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<batchtest todir="build/tests">
<fileset dir="build/tests">
<exclude name="**/JPF_*.class"/>
<include name="**/*Test.class"/>
<exclude name="**/SplitInputStreamTest.class"/>
</fileset>
</batchtest>
</junit>
<fail if="test.failed" />
</target>
</project>