source: trunk/abcl/build.xml @ 11653

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

If the either the Lisp or Java compilation fails, halt the Ant based build process.

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