source: trunk/abcl/build.xml @ 11570

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

Refactored Ant-based build to decrease compilation time.

<antcall> targets are *always* invoked, so refactoring these out them
enables 'abcl.stamp' to not doubly invoke compile.lisp.

Remove odd references to J.

'abcl.init' replaces 'abcl.pre-compile' for aesthetic reasons.

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