source: trunk/abcl/build.xml @ 11596

Last change on this file since 11596 was 11596, checked in by Mark Evenson, 13 years ago

Invocation of ASDF tests from Lisp via instructions at top of 'abcl.asd' works.

Optimized 'build.xml' run time for typical (repeated) usage scenarios:

o downloading of 'junit.jar' based on presence on filesystem.
o rebuilding of 'abcl.jar' based on explicit check via Ant

Removed automatic execution of ABCL-TESTS based on load.

Ant 'abcl.test' target not working in all situations. Needs further
debugging. Workaround: use the Lisp-based ASDF test entry point for now.

ANSI-TESTS-COMPILED ANSI-TESTS-INTERPRETED need a sibling directory
containing the GCL ANSI tests from
<svn://common-lisp.net/project/ansi-test/svn/trunk/ansi-tests>. They
complain semi-intellibly if not found.

  • Property svn:eol-style set to LF
File size: 18.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project xmlns="antlib:org.apache.tools.ant"
3   name="abcl-master" default="help" basedir=".">
4    <description>Compiling, testing, and packaging Armed Bear Common Lisp</description>
5
6    <target name="abcl" depends="abcl.wrapper"/>
7
8    <property file="build.properties"/>
9
10    <property name="build.dir" 
11        value="${basedir}/build"/>
12    <property name="build.classes.dir" 
13        value="${build.dir}/classes"/>
14    <property name="src.dir" 
15        value="${basedir}/src"/>
16    <property name="dist.dir" 
17        value="${basedir}/dist"/>
18    <property name="abcl.jar.path"
19        value="${dist.dir}/abcl.jar"/>
20    <property name="abcl.ext.dir"
21        value="${basedir}/ext"/>
22 
23    <target name="help">
24      <echo>Main Ant targets:
25 abcl.compile 
26   -- compile ABCL to ${build.classes.dir}.
27 abcl.jar     
28   -- create packaged ${abcl.jar.path}.
29 abcl.wrapper 
30   -- create executable wrapper for ABCL.
31 abcl.source.zip abcl.source.tar
32   -- create source distributions in ${dist.dir}.
33 acbl.test.java
34   -- Run junit tests under ${abcl.test.src.dir}.
35 abcl.clean
36   -- remove ABCL intermediate files</echo>
37      <echo>Corresponding targets for J have been removed.</echo>
38    </target>
39
40    <!-- Checks if JSR-223 support is available - thanks to Mark Everson -->
41    <available property="abcl.jsr-223.p"
42         classname="javax.script.ScriptEngine"/>
43
44    <patternset id="abcl.source.java">
45      <include name="org/armedbear/lisp/*.java"/>
46      <include name="org/armedbear/lisp/util/*.java"/>
47      <include name="org/armedbear/lisp/scripting/*.java" if="abcl.jsr-223.p"/>
48      <include name="org/armedbear/lisp/scripting/util/*.java" if="abcl.jsr-223.p"/>
49      <include name="org/armedbear/Main.java"/>
50    </patternset>
51
52    <patternset id="abcl.source.lisp">
53      <include name="org/armedbear/lisp/*.lisp"/>
54      <include name="org/armedbear/lisp/tests/*.lisp"/>
55      <exclude name="org/armedbear/lisp/j.lisp"/>
56      <include name="org/armedbear/lisp/scripting/lisp/*.lisp" if="abcl.jsr-223.p"/>
57    </patternset>
58
59    <patternset id="abcl.scripting.source.java">
60      <include name="org/armedbear/lisp/scripting/*.java"/>
61      <include name="org/armedbear/lisp/scripting/util/*.java"/>
62    </patternset>
63
64    <patternset id="abcl.scripting.source.lisp">
65      <include name="org/armedbear/lisp/scripting/lisp/*.lisp"/>
66    </patternset>
67
68    <!-- Lisp files required at runtime -->
69    <patternset id="abcl.source.lisp.dist">
70      <include name="org/armedbear/lisp/boot.lisp"/>
71    <include name="org/armedbear/lisp/scripting/lisp/*.lisp" if="abcl.jsr-223.p"/>
72    </patternset>
73
74    <patternset id="abcl.objects">
75      <include name="org/armedbear/lisp/*.class"/>
76      <include name="org/armedbear/lisp/util/*.class"/>
77      <include name="org/armedbear/lisp/*.cls"/> 
78      <include name="org/armedbear/lisp/*.abcl"/>
79      <include name="org/armedbear/lisp/scripting/*.class" if="abcl.jsr-223.p"/>
80      <include name="org/armedbear/lisp/scripting/util/*.class" if="abcl.jsr-223.p"/>
81      <patternset refid="abcl.source.lisp.dist"/>
82    </patternset>
83   
84    <path id="abcl.classpath.dist">
85      <pathelement location="${abcl.jar.path}"/>
86    </path>
87   
88    <path id="abcl.classpath.build">
89      <pathelement location="${build.classes.dir}"/>
90    </path>
91
92    <target name="abcl.compile" depends="abcl.compile.lisp">
93      <echo>Compiled ABCL with Java version: ${java.version}</echo>
94    </target>
95
96    <target name="abcl.init">
97      <tstamp>
98  <format property="build" pattern="EEE MMM dd yyyy HH:mm:ss zzz"/>
99      </tstamp>
100
101      <!--- antversion fails in ant 1.7.1 <antversion property="ant.version"
102                                                atleast="1.7"/> -->
103      <property name="java.path"
104    value="${java.home}/bin/java"/>
105
106      <!-- Deprecated. Two main types of build environents: 'unix' or 'windows'. -->
107      <condition property="unix"> 
108  <or>
109    <os family="unix"/>
110    <os family="mac"/>
111  </or>
112      </condition>
113      <condition property="windows"> 
114  <os family="windows"/>
115      </condition>
116
117      <!-- Deprecated. -->
118      <available file="${src.dir}org/armedbear/lisp/Interpreter.java" 
119     property="abcl.lisp.p"/>
120
121      <echo>java.version: ${java.version}</echo>
122      <condition property="abcl.java.version.p">
123  <or>
124    <matches string="${java.version}" pattern="1\.5"/>
125    <matches string="${java.version}" pattern="1\.6\.0_1[0-9]"/>
126  </or> 
127      </condition>
128
129      <!-- Set from commandline via -D or in 'build.properties' -->
130      <property name="build.version" value="abcl.svn"/>
131      <echo>Implementation-Source: ${version.src}</echo>
132
133    </target>
134   
135    <target name="abcl.java.warning" 
136      depends="abcl.init"
137      unless="abcl.java.version.p">
138      <echo>WARNING: Use of Java version ${java.version} not recommended.</echo>
139    </target>
140 
141    <target name="abcl.jsr-223.notice"
142      depends="abcl.init"
143      unless="abcl.jsr-223.p">
144      <echo>
145  Notice: JSR-223 support won't be built since it is not
146          supported, neither natively by your JVM nor by
147    libraries in the CLASSPATH.
148      </echo>
149    </target>
150
151    <target name="abcl.compile.java" 
152      depends="abcl.init,abcl.java.warning,abcl.jsr-223.notice">
153      <mkdir dir="${build.dir}"/>
154      <mkdir dir="${build.classes.dir}"/>
155      <javac destdir="${build.classes.dir}"
156       debug="true"
157       target="1.5">
158  <src path="${src.dir}"/>
159  <patternset refid="abcl.source.java"/>
160      </javac>
161      <echo message="${build}" 
162      file="${build.classes.dir}/org/armedbear/lisp/build"/>
163    </target>
164
165    <target name="abcl.copy.lisp">
166      <copy todir="${build.classes.dir}" preservelastmodified="yes">
167  <fileset dir="${src.dir}">
168    <patternset refid="abcl.source.lisp"/>
169  </fileset>
170      </copy>
171    </target>
172
173    <!-- Adjust the patternset for ABCL source to use the much faster
174         Ant 'uptodate' task to check if we need to compile the system
175         fasls.  Highly inter-dependent with the behavior specified in
176         'compile-system.lisp'.-->
177    <patternset id="abcl.source.lisp.fasls">
178      <patternset refid="abcl.source.lisp"/>
179      <exclude name="org/armedbear/lisp/tests/*.lisp"/>
180      <exclude name="org/armedbear/lisp/boot.lisp"/>
181      <exclude name="org/armedbear/lisp/emacs.lisp"/>
182      <exclude name="org/armedbear/lisp/runtime-class.lisp"/>
183      <exclude name="org/armedbear/lisp/run-benchmarks.lisp"/>
184    </patternset>
185
186    <target name="abcl.fasls.uptodate">
187      <uptodate property="abcl.fasls.uptodate.p" value="true">
188  <srcfiles dir="${build.classes.dir}">
189    <patternset refid="abcl.source.lisp.fasls"/>
190  </srcfiles>
191  <mapper type="glob" from="*.lisp" to="*.abcl"/>
192      </uptodate>
193    </target>
194   
195    <target name="abcl.compile.lisp" 
196      depends="abcl.copy.lisp,abcl.compile.java,abcl.fasls.uptodate"
197      unless="abcl.fasls.uptodate.p">
198      <java classpath="${build.classes.dir}"
199      fork="true"
200      classname="org.armedbear.lisp.Main">
201  <arg value="--noinit"/>
202  <arg value="--eval"/>
203  <arg value="(compile-system :zip nil :quit t)"/>
204      </java>
205    </target>
206
207    <property name="abcl.build.path"
208        value="${build.classes.dir}/org/armedbear/lisp/build"/>
209    <target name="abcl.stamp" depends="abcl.compile,abcl.stamp.version,abcl.stamp.hostname">
210      <mkdir dir="${abcl.build.path}/.."/>
211      <echo message="${build}" file="${abcl.build.path}"/>   
212    </target>
213
214    <property name="abcl.version.path"
215        value="${build.classes.dir}/org/armedbear/lisp/version"/>
216    <target name="abcl.stamp.version" depends="abcl.compile">
217      <!-- Determine which ABCL version we have just built by parsing
218           the output of LISP-IMPLEMENTATION-VERSION. -->
219      <java fork="true"
220      classpath="${build.classes.dir}"
221      outputproperty="abcl.version"
222      classname="org.armedbear.lisp.Main">
223  <arg value="--noinit"/>
224  <arg value="--noinform"/>
225  <arg value="--eval"/>
226  <arg value="(progn (format t (lisp-implementation-version)) (finish-output) (quit))"/>
227      </java>
228
229      <echo>Built ABCL version: ${abcl.version}</echo>
230      <mkdir dir="${abcl.version.path}/.."/>
231      <echo message="${abcl.version}" file="${abcl.version.path}"/> 
232    </target>
233
234    <target name="abcl.stamp.hostname" if="unix">
235      <exec executable="hostname" outputproperty="abcl.hostname"/>
236      <echo>abcl.hostname: ${abcl.hostname}</echo>
237    </target>
238
239    <target name="abcl.jar.uptodate" depends="abcl.compile">
240      <uptodate property="abcl.jar.uptodate.p" targetfile="${abcl.jar.path}">
241  <srcfiles dir="${build.classes.dir}">
242    <patternset refid="abcl.objects"/>
243  </srcfiles>
244      </uptodate>
245    </target>
246
247    <target name="abcl.jar" depends="abcl.stamp,abcl.jar.uptodate"
248      unless="abcl.jar.uptodate.p">
249      <mkdir dir="${dist.dir}"/>
250      <loadfile property="abcl.version"
251      srcFile="${abcl.version.path}"/>
252      <jar destfile="${abcl.jar.path}"
253     compress="true"
254     basedir="${build.classes.dir}">
255  <patternset refid="abcl.objects"/>
256  <manifest>
257    <attribute name="Main-Class" value="org.armedbear.lisp.Main"/>
258    <section name="org/armedbear/lisp">
259      <attribute name="Implementation-Title" 
260           value="ABCL"/>
261      <attribute name="Implementation-Version" 
262           value="${abcl.version}"/>
263      <attribute name="Implementation-Build" 
264           value="${build}"/>
265      <attribute name="Implementation-Source" 
266           value="${version.src}"/>
267    </section>
268  </manifest>
269        <metainf dir="${src.dir}/META-INF">
270        </metainf>
271      </jar>
272    </target>
273   
274    <target name="abcl.wrapper" 
275      depends="abcl.jar,abcl.wrapper.unix,abcl.wrapper.windows">
276      <description>
277  Creates in-place exectuable shell wrapper in '${abcl.wrapper.file}'
278      </description>
279      <!-- Set from commandline or in 'build.properties' -->
280      <property name="additional.jars" value=""/>
281      <path id="abcl.runtime.classpath">
282  <pathelement location="${abcl.jar.path}"/>
283  <pathelement path="${additional.jars}"/>
284      </path>
285      <!-- set via '-Djava.options=JAVA_OPTIONS' or in 'build.properties -->
286      <property name="java.options" value=""/>
287
288      <copy file="${abcl.wrapper.in.file}" toFile="${abcl.wrapper.file}" overwrite="yes">
289  <filterset>
290    <filter token="JAVA" 
291      value="${java.path}"/>
292    <filter token="ABCL_JAVA_OPTIONS" 
293      value= "${java.options}"/>
294    <filter token="ABCL_LIBPATH" 
295      value="${basedir}/src/org/armedbear/lisp/libabcl.so"/>
296    <filter token="ABCL_CLASSPATH" 
297      value="${toString:abcl.runtime.classpath}"/>
298  </filterset>
299      </copy>
300      <chmod file="${abcl.wrapper.file}" perm="a+x"/>
301
302      <echo>Created executable ABCL wrapper in '${abcl.wrapper.file}'</echo>
303      <echo>N.B. This wrapper requires '${abcl.jar.path}' not be moved.</echo>
304    </target>
305
306    <target name="abcl.wrapper.unix" if="unix">
307      <property name="abcl.wrapper.file" value="abcl"/>
308      <property name="abcl.wrapper.in.file" value="abcl.in"/>
309    </target>
310
311    <target name="abcl.wrapper.windows" if="windows">
312      <property name="abcl.wrapper.file" value="abcl.bat"/>
313      <property name="abcl.wrapper.in.file" value="abcl.bat.in"/>
314    </target>
315
316    <target name="abcl.debug.jpda" depends="abcl.jar">
317      <description>Invoke ABCL with JPDA listener on port 6789</description>
318      <java fork="true"
319      classpathref="abcl.classpath.dist"
320      classname="org.armedbear.lisp.Main">
321  <jvmarg 
322      value="-agentlib:jdwp=transport=dt_socket,address=6789,server=y"/>
323      </java>
324    </target>
325
326    <target name="abcl.run" depends="abcl.jar">
327      <java fork="true"
328      classpathref="abcl.classpath.dist"
329      classname="org.armedbear.lisp.Main">
330      </java>
331    </target>
332
333    <target name="abcl.clean">
334      <delete dir="${build.dir}"/>
335      <delete file="${abcl.jar.path}"/>
336      <delete file="abcl"/>
337      <delete file="abcl.bat"/>
338    </target>
339
340    <target name="abcl.dist" depends="abcl.jar">
341      <copy file="${abcl.jar.path}"
342      toFile="${dist.dir}/abcl-${abcl.version}.jar"/>
343    </target>
344
345    <target name="abcl.distclean" depends="abcl.clean">
346      <delete dir="${dist.dir}"/>
347      <delete file="abcl"/>
348      <delete file="abcl.bat"/>
349    </target>
350
351    <target name="TAGS">
352      <apply executable="etags" parallel="true" verbose="true">
353  <fileset dir="${src.dir}">
354    <patternset refid="abcl.source.java"/>
355    <patternset refid="abcl.source.lisp"/>
356  </fileset>
357      </apply>
358    </target>
359
360    <patternset id="abcl.dist.misc"
361    description="Additional includes in the source distributions relative to basedir">
362      <include name="build.xml"/>
363      <include name="build.properties.in"/>
364      <include name="COPYING"/>
365      <include name="README"/>
366      <include name="abcl.in"/>
367      <include name="abcl.bat.in"/>
368     
369      <!-- The remainder of these files are used by the Lisp hosted
370           build in 'build-abcl.lisp' but not used by Ant, so include
371           them in the source distribution. -->
372      <include name="make-jar.in"/>
373      <include name="make-jar.bat.in"/>
374
375      <include name="build-abcl.lisp"/>
376      <include name="customizations.lisp.in"/>
377
378      <include name="test-abcl.asd"/>
379      <include name="build-abcl.asd"/>
380    </patternset>
381
382    <patternset id="abcl.source.misc"
383    description="Additional includes in the source distribution relative to source root">
384      <include name="org/armedbear/lisp/LICENSE"/>
385      <include name="manifest-abcl"/>
386    </patternset>
387   
388    <target name="abcl.source.prepare" depends="abcl.stamp.version">
389      <property name="abcl.source.eol" value="asis"/>
390      <echo>Using abcl.source.eol='${abcl.source.eol}' to drive
391      source code line-ending transformations.</echo>
392      <property name="abcl.build.src.dir"
393    value="${build.dir}/abcl-src-${abcl.version}"/>
394      <mkdir dir="${abcl.build.src.dir}/src"/>
395      <fixcrlf srcdir="${src.dir}" 
396         eol="${abcl.source.eol}"
397         destdir="${abcl.build.src.dir}/src"
398         preservelastmodified="true">
399  <patternset refid="abcl.source.java"/>
400  <patternset refid="abcl.source.lisp"/>
401  <patternset refid="abcl.source.misc"/>
402      </fixcrlf>
403      <fixcrlf srcdir="${basedir}" 
404         eol="${abcl.source.eol}"
405         destdir="${abcl.build.src.dir}"
406         preservelastmodified="true">
407  <patternset refid="abcl.dist.misc"/>
408      </fixcrlf>
409    </target>
410
411    <target name="abcl.source.tar" depends="abcl.source.prepare">
412      <mkdir dir="${dist.dir}"/>
413      <tar destfile="${dist.dir}/abcl-src-${abcl.version}.tar.gz"
414     compression="gzip">
415  <tarfileset dir="${build.dir}">
416    <include name="abcl-src-${abcl.version}/**"/>
417  </tarfileset>
418      </tar>
419    </target>
420
421    <target name="abcl.source.zip" depends="abcl.source.prepare">
422      <mkdir dir="${dist.dir}"/>
423      <zip destfile="${dist.dir}/abcl-src-${abcl.version}.zip"
424     compress="true">
425  <zipfileset dir="${abcl.build.src.dir}" prefix="abcl-src-${abcl.version}"/>
426      </zip>
427    </target>
428
429    <property name="abcl.test.classes.dir"
430        value="${build.dir}/classes-test"/>
431
432    <property name="abcl.test.src.dir"
433        value="${basedir}/test/src"/>
434
435    <patternset id="abcl.test.source.java">
436      <!-- For now, we list tests explicitly, because we have to
437           enumerate them later to the JUnit test runner. -->
438      <include name="org/armedbear/lisp/FastStringBufferTest.java"/>
439    </patternset>
440
441    <property name="junit-4.5.path"
442        value="${abcl.ext.dir}/junit-4.5.jar"/>
443
444    <path id="abcl.test.compile.classpath">
445      <pathelement location="${junit-4.5.path}"/>
446      <pathelement location="${build.classes.dir}"/>
447    </path>
448
449    <target name="abcl.test.pre-compile" depends="abcl.ext"/>
450
451    <target name="abcl.ext.p">
452      <!--XXX generalize over enumeration of all contributions to abcl.ext -->
453      <available file="${junit-4.5.path}" property="abcl.ext.p"/>
454    </target>
455    <target name="abcl.ext" depends="abcl.ext.p" unless="abcl.ext.p">
456
457      <mkdir dir="${abcl.ext.dir}"/>
458      <get src="http://downloads.sourceforge.net/junit/junit-4.5.jar?modtime=1218209625"
459     usetimestamp="true"
460     dest="${junit-4.5.path}"/>
461    </target>
462 
463    <target name="abcl.test.compile" 
464      depends="abcl.test.pre-compile,abcl.compile">
465      <mkdir dir="${abcl.test.classes.dir}"/>
466      <javac destdir="${abcl.test.classes.dir}"
467       classpathref="abcl.test.compile.classpath"
468       debug="true"
469       target="1.5">
470  <src path="${abcl.test.src.dir}"/>
471  <patternset refid="abcl.test.source.java"/>
472      </javac>
473    </target>
474
475    <path id="abcl.test.run.classpath">
476      <path refid="abcl.test.compile.classpath"/>
477      <pathelement location="${abcl.test.classes.dir}"/>
478    </path>
479
480    <target name="abcl.test" 
481      depends="abcl.test.java,abcl.test.lisp"/>
482 
483    <target name="abcl.test.java" depends="abcl.test.compile">
484      <java fork="true"
485      classpathref="abcl.test.run.classpath"
486      classname="org.junit.runner.JUnitCore">
487  <arg value="org.armedbear.lisp.FastStringBufferTest"/>
488      </java>
489    </target>
490
491    <target name="abcl.test.lisp" 
492      depends="abcl.test.lisp.asdf"/>
493
494    <target name="abcl.test.lisp.asdf" 
495      depends="abcl.jar,abcl.test.ansi.compiled">
496    </target>
497
498    <target name="abcl.test.ansi.interpreted">
499      <java fork="true" dir="${basedir}"
500      classpathref="abcl.classpath.dist"
501      classname="org.armedbear.lisp.Main">
502  <arg value="--noinit"/> 
503  <arg value="--load"/>
504  <arg line="${basedir}/test/lisp/ansi/ansi-tests-interpreted.lisp"/>
505      </java>
506    </target>
507
508    <property name="abcl.test.log.file"
509        value="abcl.test.ansi.compiled.${version.src}"/>
510
511    <target name="abcl.test.ansi.compiled">
512      <echo>Recording test output in ${abcl.test.log.file}.</echo>
513      <record name="${abcl.test.log.file}" emacsmode="true" action="start"/>
514      <java fork="true" dir="${basedir}"
515      classpathref="abcl.classpath.dist"
516      classname="org.armedbear.lisp.Main">
517  <arg value="--noinit"/> 
518  <arg value="--load"/>
519  <arg line="${basedir}/test/lisp/ansi/ansi-tests-compiled.lisp "/> 
520      </java>
521      <record name="${abcl.test.log.file}" emacsmode="true" action="stop"/>
522      <echo>Finished ecording test output in ${abcl.test.log.file}.</echo>
523
524    </target>
525
526    <import file="netbeans-build.xml" optional="true"/> 
527<!--    <import file="j-build.xml" optional="true"/>  -->
528    <import file="not.org-build.xml" optional="true"/> 
529</project>
530
Note: See TracBrowser for help on using the repository browser.