build.xml 46 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="antlib:org.apache.tools.ant"
3
         name="abcl-master" default="abcl.wrapper" basedir=".">
4
    <description>Compiling, testing, and packaging Armed Bear Common Lisp</description>
5

6
    <target name="abcl" depends="abcl.wrapper,abcl-contrib.jar"/>
7
        
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    <target name="help">
      <echo>
Main Ant targets:

 abcl.wrapper 
   -- [default] create executable wrapper for ABCL.
 abcl.compile  
   -- compile ABCL to ${build.classes.dir}.
 abcl.jar      
   -- create packaged ${abcl.jar.path}.
 abcl.source.zip abcl.source.tar
   -- create source distributions in ${dist.dir}.
 abcl.clean 
   -- remove ABCL intermediate files
      </echo>

      <echo>
For help on the automatic tests available, use the Ant target 'help.test'.
      </echo>
    </target>
28

29
    <!-- Behavior of the build system can be customized via setting
30 31
         properties in the 'abcl.properties' file. -->
    <property file="abcl.properties"/>
32 33

    <property name="build.dir" 
34
              value="${basedir}/build"/>
35
    <property name="build.classes.dir" 
36
              value="${build.dir}/classes"/>
37
    <property name="src.dir" 
38
              value="${basedir}/src"/>
39
    <property name="dist.dir" 
40
              value="${basedir}/dist"/>
41
    <property name="abcl.jar.path"
42
              value="${dist.dir}/abcl.jar"/>
43
    <property name="abcl-aio.jar.path"
44
              value="${dist.dir}/abcl-aio.jar"/>
45
    <property name="abcl.ext.dir"
46
              value="${basedir}/ext"/>
47

48 49 50
    <property name="abcl.runtime.jar.path"
              value="${abcl.jar.path}"/>

51
    <!-- TODO verify me -->
52 53 54 55 56 57 58
    <fail message="Please build using Ant 1.7.1 or higher.">
        <condition>
            <not>
                <antversion atleast="1.7.1"/>
            </not>
        </condition>
    </fail>
59

60
    <!-- Deprecated.  Checks if JSR-223 support is available.  Should always be true.  Unused.  D -->
61
    <available property="abcl.jsr-223.p"
62
               classname="javax.script.ScriptEngine"/>
63

64 65 66
    <patternset id="abcl.source.java">
      <include name="org/armedbear/lisp/*.java"/>
      <include name="org/armedbear/lisp/util/*.java"/>
67
      <include name="org/armedbear/lisp/protocol/*.java"/>
68
      <include name="org/armedbear/lisp/java/**/*.java"/>
69 70
      <include name="org/armedbear/lisp/scripting/*.java" />
      <include name="org/armedbear/lisp/scripting/util/*.java" />
71
      <include name="org/armedbear/Main.java"/>
72
      <include name="org/abcl/**/*.java"/>
73
    </patternset>
74

75 76
    <patternset id="abcl.source.lisp">
      <include name="org/armedbear/lisp/*.lisp"/>
77
      <include name="org/armedbear/lisp/java/**/*.lisp"/>
78
      <include name="org/armedbear/lisp/tests/*.lisp"/>
79
      <exclude name="org/armedbear/lisp/j.lisp"/>
80
      <include name="org/armedbear/lisp/scripting/lisp/*.lisp"/>
81
    </patternset>
82
    
83 84 85
    <!-- Lisp files required at runtime -->
    <patternset id="abcl.source.lisp.dist">
      <include name="org/armedbear/lisp/boot.lisp"/>
86
      <include name="org/armedbear/lisp/scripting/lisp/*.lisp" />
87 88
      <include if="abcl.compile.lisp.skip"
               name="**/*.lisp" />
89 90 91
    </patternset>

    <patternset id="abcl.objects">
92
      <!-- "system.lisp" is dynamically created by COMPILE-fSYSTEM -->
93
      <include name="org/armedbear/lisp/system.lisp"/> 
94 95 96
      <include name="org/armedbear/lisp/**/*.class"/>
      <include name="org/armedbear/lisp/**/*.cls"/> 
      <include name="org/armedbear/lisp/**/*.abcl"/>
97
      <include name="org/abcl/util/*.class"/>
98
      <include name="org/armedbear/lisp/version"/>
99 100
      <include name="org/armedbear/lisp/scripting/*.class"/>
      <include name="org/armedbear/lisp/scripting/util/*.class"/>
101
      <patternset refid="abcl.source.lisp.dist"/>
102
      <include name="abcl.rdf"/>
103 104 105 106 107 108
      <include name="abcl.asd"/>
      <include name="README"/>
      <include name="build.xml"/>
      <include name="abcl.properties.in"/>
      <include name="abcl.in"/>
      <include name="abcl.bat.in"/>
109 110 111 112 113 114 115 116 117 118
    </patternset>
    
    <path id="abcl.classpath.dist">
      <pathelement location="${abcl.jar.path}"/>
    </path>
    
    <path id="abcl.classpath.build">
      <pathelement location="${build.classes.dir}"/>
    </path>

119
    <target name="abcl.compile" depends="abcl.clean.maybe,abcl.compile.lisp">
120
      <echo>Compiled ABCL with Java version: ${java.version}</echo>
121
    </target>
122

123 124 125 126 127
    <target name="abcl.clean.maybe" unless="abcl.build.incremental">
      <echo>Cleaning all intermediate compilation artifacts.</echo>
      <echo>Setting 'abcl.build.incremental' enables incremental compilation.</echo>
      <antcall target="abcl.clean"/>
    </target>
128

129 130
    <target name="abcl.init">
      <tstamp>
131
        <format property="build" pattern="EEE MMM dd yyyy HH:mm:ss zzz"/>
132 133
      </tstamp>

134
      <tstamp>
135
        <format property="build.stamp" pattern="yyyymmdd-HHmm"/>
136 137 138
      </tstamp>

      <property name="abcl.test.log.file"
139
                value="abcl-test-${build.stamp}.log"/>
140

141
      <property name="java.path"
142
                value="${java.home}/bin/java"/>
143

144 145
      <!-- Deprecated. Two main types of build environents: 'unix' or 'windows'. -->
      <condition property="unix"> 
146 147 148 149
        <or>
          <os family="unix"/>
          <os family="mac"/>
        </or>
150 151
      </condition>
      <condition property="windows"> 
152
        <os family="windows"/>
153
      </condition>
154

155 156
      <!-- Deprecated. -->
      <available file="${src.dir}org/armedbear/lisp/Interpreter.java" 
157
                 property="abcl.lisp.p"/>
158

159 160
      <echo>java.version: ${java.version}</echo>
      <condition property="abcl.java.version.p">
161
        <!-- Unsupported as of abcl-1.5.0 due to lack of open jdk
162 163
          <matches string="${java.version}" 
                   pattern="1\.5"/>
164 165
          -->
          <or>
166
          <!-- Don't use 1.6.0_09 or earlier. -->
167 168 169 170
          <matches string="${java.version}" 
                   pattern="1\.6\.0_[1-9][0-9]"/>
          <!-- 1.7.0_04 works much better. -->
          <matches string="${java.version}" 
171
                   pattern="1\.7\.0_(0[4-9])|([1-9][0-9])"/>
172 173
          <matches string="${java.version}" 
                   pattern="1\.8\.0"/>
174
        </or>  
175
      </condition>
176

177 178 179
    </target>
    
    <target name="abcl.java.warning" 
180 181
            depends="abcl.init"
            unless="abcl.java.version.p">
182
      <echo>WARNING: Use of Java version ${java.version} not recommended.</echo>
183
    </target>
184 185

    <!-- Deprecated.  JSR-223 is always present -->
186
    <target name="abcl.jsr-223.notice"
187 188
            depends="abcl.init"
            unless="abcl.jsr-223.p">
189
      <echo>
190 191 192
        Notice: JSR-223 support won't be built since it is not
                supported, neither natively by your JVM nor by 
                libraries in the CLASSPATH.
193
      </echo>
194 195
    </target>

196 197 198 199 200 201 202 203 204 205 206 207
    <!-- The Java compilation options are perhaps underspecified in
         terms of the target JVM in order to support a developer who
         simply wants to compile and run locally with least hassles.
	 
	 When preparing ABCL binaries for wider distribution, the
	 values of the abcl.build.target.javac and
	 abcl.build.source.java become more important.  

         The 'abcl.properties.autoconfigure.*' targets use the
         ci/create-build-properties.bash script to set these options
         for various openjdk platforms.
    -->
208

209
    <target name="abcl.compile.java" 
210
            depends="abcl.init,abcl.java.warning">
211 212
      <mkdir dir="${build.dir}"/>
      <mkdir dir="${build.classes.dir}"/>
213
      <javac destdir="${build.classes.dir}"
214
             debug="true"
215
             includeantruntime="false"
216
             encoding="UTF-8"
217 218 219
             failonerror="true">
        <src path="${src.dir}"/>
        <patternset refid="abcl.source.java"/>
220 221 222
      </javac>
    </target>

223 224
    <!-- Additional artifacts to stage relative to Ant ${basedir} -->
    <patternset id="abcl.stage">
225 226
      <include name="README"/>
      <include name="COPYING"/>
227
      <include name="abcl.rdf"/>
228 229 230
      <include name="abcl.asd"/> 
      <include name="build.xml"/>
      <include name="abcl.properties.in"/> <!--TODO: massage into abcl.properties at build-time -->
231
      <include name="abcl.in"/>
232
      <include name="abcl.bat.in"/>
233
      <include name="etc/ant/*.xml"/>
234 235 236 237
    </patternset>

    <target name="abcl.stage"
	    depends="abcl.copy.lisp">
238 239
      <copy todir="${build.classes.dir}" preservelastmodified="yes"
            verbose="true">
240 241 242 243 244 245
	<fileset dir="${basedir}/">
	  <patternset refid="abcl.stage"/>
	</fileset>
      </copy>
    </target>
    
246 247
    <target name="abcl.copy.lisp">
      <copy todir="${build.classes.dir}" preservelastmodified="yes">
248
        <fileset dir="${src.dir}">
249
          <patternset refid="abcl.source.lisp.dist"/>
250
        </fileset>
251 252 253 254 255
      </copy>
    </target>

    <!-- Adjust the patternset for ABCL source to use the much faster
         Ant 'uptodate' task to check if we need to compile the system
256
         fasls.  Highly inter-dependent with the behavior specified in
257 258
         'compile-system.lisp', i.e. files not listed in
         there should NOT occur here. -->
259 260
    <patternset id="abcl.source.lisp.fasls">
      <patternset refid="abcl.source.lisp"/>
261
      <exclude name="org/armedbear/lisp/scripting/**/*.lisp"/>
262 263 264 265 266 267 268
      <exclude name="org/armedbear/lisp/boot.lisp"/>
      <exclude name="org/armedbear/lisp/emacs.lisp"/>
      <exclude name="org/armedbear/lisp/run-benchmarks.lisp"/>
    </patternset>

    <target name="abcl.fasls.uptodate">
      <uptodate property="abcl.fasls.uptodate.p" value="true">
269 270 271 272
        <srcfiles dir="${src.dir}">
          <patternset refid="abcl.source.lisp.fasls"/>
        </srcfiles>
        <mapper type="glob" from="*.lisp" to="${build.classes.dir}/*.abcl"/>
273 274
      </uptodate>
    </target>
275 276 277

    <path id="abcl.home.dir.path">
        <path location="${src.dir}/org/armedbear/lisp/"/>
278
    </path>         
279 280 281 282
    <pathconvert property="abcl.home.dir" refid="abcl.home.dir.path"/>

    <path id="abcl.lisp.output.path"
          location="${build.classes.dir}/org/armedbear/lisp/"/>
283
    <pathconvert dirsep="/" property="abcl.lisp.output" refid="abcl.lisp.output.path"/>
284 285 286

    <property name="system.lisp.file" 
              value="${build.classes.dir}/org/armedbear/lisp/system.lisp"/>
287

288
    <target name="abcl.compile.lisp" 
289
            depends="abcl.stage,abcl.compile.java,abcl.system.update.maybe,abcl.fasls.uptodate"
290
            unless="abcl.fasls.uptodate.p">
291 292 293 294 295 296 297
      <abcl.compile.lisp/>
    </target>

    <macrodef name="abcl.compile.lisp">
      <element name="additional.jvmarg" optional="true"/>
      <sequential>
        <echo>
298 299
Compiling Lisp system 
from ${abcl.home.dir}
300 301 302 303 304 305 306
 to  ${abcl.lisp.output}</echo>
 
     <!-- Not good if ${abcl.home.dir} == ${abcl.lisp.output} -->
     <delete>
       <fileset dir="${abcl.home.dir}" includes="**/*.abcl **/*.cls **/*._"/>
     </delete>
     <java classpath="${build.classes.dir}" 
307 308
            fork="true"
            failonerror="true"
309
            inputstring="(handler-case (compile-system :zip nil :quit t :output-path &quot;${abcl.lisp.output}/&quot;) (t (x) (progn (format t &quot;~A: ~A~%&quot; (type-of x) x) (exit :status -1))))"
310
            classname="org.armedbear.lisp.Main">
311
        <jvmarg value="-Dabcl.home=${abcl.home.dir}${file.separator}"/>
312
        <jvmarg value="-Dabcl.autoload.verbose=Y"/>
313
        <additional.jvmarg/>
314
        <arg value="--noinit"/>
315
        <arg value="--nosystem"/>
316 317
        <arg value="--eval"/>
        <arg value="(setf *load-verbose* t)"/>
318
      </java>
319 320 321
      <concat destfile="${system.lisp.file}" append="true">
        <fileset file="${abcl.startup.file}"/>
      </concat>
322 323 324 325 326 327
        </sequential>
    </macrodef>

    <property name="abcl.compile.lisp.debug.jvmarg"
              value="-agentlib:jdwp=transport=dt_socket,server=y,address=6789,suspend=y"/>
    <target name="abcl.compile.lisp.debug" 
328
            depends="abcl.stage,abcl.compile.java,abcl.system.update.maybe,abcl.fasls.uptodate"
329 330 331 332 333 334 335
            unless="abcl.fasls.uptodate.p">
      <echo>Debugging with jvmarg ${abcl.compile.lisp.debug.jvmarg}</echo>
      <abcl.compile.lisp> 
          <additional.jvmarg>
            <jvmarg value="${abcl.compile.lisp.debug.jvmarg}"/>
          </additional.jvmarg>
      </abcl.compile.lisp>
336 337
    </target>

338
    <property name="abcl.build.path"
339
              value="${build.classes.dir}/org/armedbear/lisp/build"/>
340 341
    <target name="abcl.stamp" 
            depends="abcl.compile,abcl.stamp.version,abcl.stamp.hostname">
342
      <mkdir dir="${abcl.build.path}/.."/>
343 344
      <loadfile property="abcl.version"
                srcFile="${abcl.version.path}"/>
345 346 347
      <echo message="${build}" file="${abcl.build.path}"/>    
    </target>

348 349 350 351 352 353 354 355 356 357

    <!-- Environment variables may be accessed as ${env.NAME} -->
    <property environment="env"/>

    <!-- Can we derive an SVN version from the current build tree? -->
    <condition property="abcl.version.svn.p">
      <and>
        <available
            file="${basedir}/.svn"
            type="dir"/>
358 359 360 361 362 363 364 365 366 367 368 369 370 371
        <or>
            <available
                file="svnversion.exe"
                filepath="${env.Path}"/>
            <available
                file="svnversion.exe"
                filepath="${env.PATH}"/>
             <available
                file="svnversion"
                filepath="${env.Path}"/>
            <available
                file="svnversion"
                filepath="${env.PATH}"/>
        </or>
372 373 374 375 376
      </and>
    </condition>

    <target name="abcl.version.src" depends="abcl.version.src.3"/>

377 378 379
    <target name="abcl.version.src.0" if="windows">
      <exec
          executable="svnversion.exe"
380
          outputproperty="abcl.version.svn.raw"
381 382 383 384 385
          failifexecutionfails="false"
          searchpath="true" />
    </target>

    <target name="abcl.version.src.1" depends="abcl.version.src.0">
386 387
      <exec 
          executable="svnversion"
388
          outputproperty="abcl.version.svn.raw"
389 390
          failifexecutionfails="false"
          searchpath="true" />
391 392 393 394 395
    </target>

    <target name="abcl.version.src.2" 
            depends="abcl.version.src.1"
            if="abcl.version.svn.p">
396 397 398 399 400 401 402 403 404 405

      <!-- Transform all occurances of ":" ==> "-" in the version string -->
      <tempfile property="version-tmp.path"/>
      <echo message="${abcl.version.svn.raw}"
            file="${version-tmp.path}"/>
      <replace file="${version-tmp.path}"
               token=":" value="-"/>
      <loadfile property="abcl.version.svn" srcFile="${version-tmp.path}"/>
      <delete file="${version-tmp.path}"/>

406 407 408 409 410 411 412 413 414 415 416 417
      <echo>abcl.version.svn: ${abcl.version.svn}</echo>
      <property name="abcl.version.src"
                value="svn-${abcl.version.svn}"/>
    </target>

    <target name="abcl.version.src.3"
            depends="abcl.version.src.2"
            unless="abcl.version.svn.p">
      <property name="abcl.version.src"
                value=""/>
    </target>

418 419
    <property name="abcl.home.dir"
              value="${src.dir}/org/armedbear/lisp/"/>
420
    <property name="abcl.version.path"
421
              value="${build.classes.dir}/org/armedbear/lisp/version"/>
422

423 424 425 426
    <target name="abcl.clean.version">
      <delete file="${abcl.version.path}"/>
    </target>

427 428 429 430 431 432
    <target name="abcl.stamp.version.uptodate">
      <uptodate property="abcl.stamp.version.uptodate.p" 
                targetfile="${abcl.version.path}"
                srcfile="${build.classes.dir}/org/armedbear/lisp/Version.class"/>
    </target>

433
    <target name="abcl.stamp.version" 
434 435
            depends="abcl.version.src,abcl.stamp.version.1,abcl.stamp.version.2"
            unless="abcl.stamp.version.uptodate.p">
436 437 438 439 440
      <mkdir dir="${abcl.version.path}/.."/>
      <echo>ABCL implementation version: ${abcl.implementation.version}</echo>
      <echo file="${abcl.version.path}">${abcl.implementation.version}</echo>
    </target>
    
441 442 443
    <target name="abcl.stamp.version.generate" 
            depends="abcl.compile.java"
            unless="abcl.stamp.version.uptodate.p">
444
      <java fork="true"
445 446 447
            classpath="${build.classes.dir}"
            outputproperty="abcl.version"
            classname="org.armedbear.lisp.Version"
448
            logerror="yes"/> <!-- Don't catch stderr output -->
449
    </target>
450

451
    <target name="abcl.stamp.version.0" 
452 453
            depends="abcl.stamp.version.uptodate,abcl.stamp.version.generate">
    </target>
454

455 456 457 458 459 460 461 462 463 464 465 466
    <target name="abcl.stamp.version.1"
            depends="abcl.stamp.version.0"
            unless="abcl.version.svn.p">
      <property name="abcl.implementation.version"
                value="${abcl.version}"/>
    </target>

    <target name="abcl.stamp.version.2" 
            depends="abcl.stamp.version.0"
            if="abcl.version.svn.p">
      <property name="abcl.implementation.version"
                value="${abcl.version}-${abcl.version.src}"/>
467 468 469 470 471 472 473
    </target>

    <target name="abcl.stamp.hostname" if="unix">
      <exec executable="hostname" outputproperty="abcl.hostname"/>
      <echo>abcl.hostname: ${abcl.hostname}</echo>
    </target>

474
    <target name="abcl.system.uptodate">
475 476 477 478 479
      <condition property="abcl.system.needs-update.p">
        <and>
          <available file="${system.lisp.file}"/>
          <available file="${abcl.startup.file}"/>
          <uptodate
480 481
                srcfile="${system.lisp.file}"
                targetfile="${abcl.startup.file}"/>
482 483
        </and>
      </condition>
484 485
    </target>
    
486 487
    <target name="abcl.system.update.maybe" depends="abcl.system.uptodate" 
            if="abcl.system.needs-update.p">
488 489 490
      <touch file="${src.dir}/org/armedbear/lisp/compile-system.lisp"/>
    </target>

491
    <target name="abcl.jar.uptodate" depends="abcl.compile,abcl.stamp">
492
      <uptodate property="abcl.jar.uptodate.p" targetfile="${abcl.jar.path}">
493 494 495
        <srcfiles dir="${build.classes.dir}">
          <patternset refid="abcl.objects"/>
        </srcfiles>
496 497 498
      </uptodate>
    </target>

499
    <target name="abcl.jar" depends="abcl.jar.uptodate,abcl-contrib.jar"
500
            unless="abcl.jar.uptodate.p">
501 502
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${abcl.jar.path}"
503
           compress="true"
504
           update="true"
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
           basedir="${build.classes.dir}">
        <patternset refid="abcl.objects"/>
        <manifest>
          <attribute name="Main-Class" value="org.armedbear.lisp.Main"/>
          <section name="org/armedbear/lisp">
            <attribute name="Implementation-Title" 
                       value="ABCL"/>
            <attribute name="Implementation-Version"  
                       value="${abcl.implementation.version}"/>
            <attribute name="Implementation-Build" 
                       value="${build}"/>
          </section>
        </manifest>
        <metainf dir="${src.dir}/META-INF"> 
        </metainf>
520 521
      </jar>
    </target>
522

523
    <target name="abcl-aio.jar" depends="abcl.compile,abcl.stamp">
524
      <mkdir dir="${dist.dir}"/>
525
      <jar destfile="${abcl-aio.jar.path}"
526 527 528 529 530 531 532 533 534 535 536
           compress="true"
           update="true"
           basedir="${build.classes.dir}">
	<fileset dir="${src.dir}">
          <patternset refid="abcl.objects"/>
	  <patternset refid="abcl.source.java"/>
	  <patternset refid="abcl.source.lisp"/>
	</fileset>
	<fileset dir="${basedir}">
	  <patternset refid="abcl.contrib.source"/>
	</fileset>
537 538 539
        <!-- According to <http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html>
             any attributes not specified are ignored, so we are free to make up new attributes if necessary.  For now we just overload Implementation-Title and Implementation-Version.
            -->
540 541 542 543 544 545 546 547 548 549
        <manifest>
          <attribute name="Main-Class" value="org.armedbear.lisp.Main"/>
          <section name="org/armedbear/lisp">
            <attribute name="Implementation-Title" 
                       value="ABCL"/>
            <attribute name="Implementation-Version"  
                       value="${abcl.implementation.version}"/>
            <attribute name="Implementation-Build" 
                       value="${build}"/>
          </section>
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
          <section name="contrib">
            <attribute name="Implementation-Title" 
                       value="org.abcl-contrib"/>
            <!-- FIXME: declare separate abcl-contrib version? -->
            <attribute name="Implementation-Version"  
                       value="${abcl.implementation.version}"/>
          </section>
          <section name="tools">
            <attribute name="Implementation-Title" 
                       value="org.abcl-tools"/>
          </section>
          <section name="src">
            <attribute name="Implementation-Title" 
                       value="org.abcl-source"/>
            <attribute name="Implementation-Version"  
                       value="${abcl.implementation.version}"/>
          </section>
567 568 569 570 571 572
        </manifest>
        <metainf dir="${src.dir}/META-INF"> 
        </metainf>
      </jar>
    </target>

573 574
    
    <target name="abcl.wrapper" 
575
            depends="abcl.jar,abcl.contrib,abcl.wrapper.unix,abcl.wrapper.windows">
576
      <description>
577 578
        Creates in-place executable shell wrapper in
        '${abcl.wrapper.file}'
579 580 581 582
      </description>
      <!-- Set from commandline or in 'build.properties' -->
      <property name="additional.jars" value=""/>
      <path id="abcl.runtime.classpath">
583
        <pathelement location="${abcl.runtime.jar.path}"/>
584
        <pathelement path="${additional.jars}"/>
585 586 587 588 589
      </path>
      <!-- set via '-Djava.options=JAVA_OPTIONS' or in 'build.properties -->
      <property name="java.options" value=""/>

      <copy file="${abcl.wrapper.in.file}" toFile="${abcl.wrapper.file}" overwrite="yes">
590 591 592 593 594 595 596 597
        <filterset>
          <filter token="JAVA" 
                  value="${java.path}"/>
          <filter token="ABCL_JAVA_OPTIONS" 
                  value="${java.options}"/>
          <filter token="ABCL_CLASSPATH"
                  value="${toString:abcl.runtime.classpath}"/>
        </filterset>
598 599
      </copy>
      <chmod file="${abcl.wrapper.file}" perm="a+x"/>
600 601

      <echo>Created executable ABCL wrapper in '${abcl.wrapper.file}'</echo>
602 603 604 605 606 607 608 609 610 611 612 613
      <echo>N.B. This wrapper requires '${abcl.jar.path}' not be moved.</echo>
    </target>

    <target name="abcl.wrapper.unix" if="unix">
      <property name="abcl.wrapper.file" value="abcl"/>
      <property name="abcl.wrapper.in.file" value="abcl.in"/>
    </target>

    <target name="abcl.wrapper.windows" if="windows">
      <property name="abcl.wrapper.file" value="abcl.bat"/>
      <property name="abcl.wrapper.in.file" value="abcl.bat.in"/>
    </target>
614

615 616 617 618 619 620
    <patternset id="abcl.contrib.source">
          <include name="**/*.asd"/>
          <include name="**/*.lisp"/>
          <include name="**/README.markdown"/>
    </patternset>

621 622 623 624
    <patternset id="abcl.contrib.docs">
          <include name="**/README.markdown"/>
    </patternset>

625 626 627 628 629
    <property name="abcl-contrib.jar"
              value="${dist.dir}/abcl-contrib.jar"/>
    <condition property="abcl.contrib.uptodate.p">
      <uptodate targetfile="${abcl-contrib.jar}">
        <srcfiles dir="contrib">
630
          <patternset refid="abcl.contrib.source"/>
631 632 633 634
        </srcfiles>
      </uptodate>
    </condition>

635
    <target name="abcl-contrib.jar" depends="abcl.contrib"/>
636 637
    <target name="abcl.contrib" unless="abcl.contrib.uptodate.p">
      <jar destfile="${abcl-contrib.jar}"
638 639
           compress="true"
           basedir="contrib">
640
        <patternset refid="abcl.contrib.source"/>
641 642
      </jar>
      <echo>
643 644
Packaged contribs in ${abcl-contrib.jar}. To use contribs, ensure that
this file is in the same directory as 'abcl.jar', and then
645 646

  CL-USER> (require 'abcl-contrib)
647

648
will place all the contribs in the ASDF registry. 
649

650
To load a contrib, something like
651

652
  CL-USER> (require 'jss) 
653

654
will compile (if necessary) and load JSS.
655 656
</echo>
    </target>
657

658 659 660 661 662 663 664 665 666 667 668 669 670 671
    <target name="abcl.contrib.javadoc.jar">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-contrib-javadoc.jar" basedir="contrib">
        <patternset refid="abcl.contrib.docs" />
      </jar>
    </target>

    <target name="abcl.contrib.source.jar">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-contrib-sources.jar" basedir="contrib">
        <patternset refid="abcl.contrib.source" />
      </jar>
    </target>

672 673 674
    <target name="abcl.debug.jpda" depends="abcl.jar">
      <description>Invoke ABCL with JPDA listener on port 6789</description>
      <java fork="true"
675 676 677 678
            classpathref="abcl.classpath.dist"
            classname="org.armedbear.lisp.Main">
        <jvmarg 
            value="-agentlib:jdwp=transport=dt_socket,address=6789,server=y"/>
679
      </java>
680
      <echo>JPDA listening on localhost:6789</echo>
681 682
    </target>

683 684 685
    <target name="abcl.build.debug.jpda" depends="abcl.compile.java">
      <description>Invoke ABCL with JPDA listener on port 6789</description>
      <java fork="true"
686 687 688 689
            classpathref="abcl.classpath.build"
            classname="org.armedbear.lisp.Main">
        <jvmarg
            value="-agentlib:jdwp=transport=dt_socket,address=6789,server=y"/>
690 691 692 693 694
        <jvmarg value="-Dabcl.home=${abcl.home.dir}${file.separator}"/>
      </java>
      <echo>JPDA listening on localhost:6789</echo>
    </target>

695 696
    <target name="abcl.run" depends="abcl.jar">
      <java fork="true"
697 698
            classpathref="abcl.classpath.dist"
            classname="org.armedbear.lisp.Main">
699 700 701
      </java>
    </target>

702 703
    <target name="abcl.clean">
      <delete dir="${build.dir}"/>
704
      <delete file="${abcl.jar.path}"/>
705
      <delete file="abcl"/>
706
      <delete file="abcl.bat"/>
707 708
    </target>

709 710 711 712 713
    <property name="slime.fasls" 
              value="${user.home}/.slime/"/>
    <property name="quicklisp.common-lisp.fasls"
              value="${user.home}/.cache/common-lisp/"/>
    <target name="abcl.clean.application.fasls">
714 715 716 717 718 719 720 721
      <echo>Deleting ABCL SLIME fasls under ${slime.fasls}</echo>
      <delete>
        <fileset dir="${slime.fasls}" includes="**/*.abcl"/>
      </delete>
      <echo>Deleting ABCL Quicklisp fasls under ${quicklisp.common-lisp.fasls}</echo>
      <delete>
        <fileset dir="${quicklisp.common-lisp.fasls}" includes="**/*.abcl"/>
      </delete>
722 723
    </target>

724 725
    <target name="abcl.dist" depends="abcl.jar">
      <copy file="${abcl.jar.path}"
726
            toFile="${dist.dir}/abcl-${abcl.version}.jar"/>
727 728 729 730 731
    </target>

    <target name="abcl.distclean" depends="abcl.clean">
      <delete dir="${dist.dir}"/>
      <delete file="abcl"/>
732
      <delete file="abcl.bat"/>
733 734
    </target>

735 736 737 738 739 740 741 742
    <condition property="etags.executable"
               value="etags"
               else="c:/cygwin64/bin/ctags.exe">
      <not>
        <os family="windows"/>
      </not>
    </condition>
      
743
    <target name="TAGS">
744
      <delete file="TAGS"/>
745
      <apply executable="${etags.executable}" parallel="true" verbose="true" maxparallel="300">
746
        <arg value="--append"/>
747
        <arg value="--regex=|[ \t]+//[ \t]+###[ \t]+\([^ \t]+\)|\1|"/>
748
        <arg value='--regex=|[ \t]*@DocString([ \n\r\t]*name=\"\([^\"]*\)|\1|m'/>
749 750 751 752
        <fileset dir="${src.dir}">
          <patternset refid="abcl.source.java"/>
          <patternset refid="abcl.source.lisp"/>
        </fileset>
753 754 755 756
      </apply>
    </target>

    <patternset id="abcl.dist.misc"
757
                description="Additional includes in the source distributions relative to basedir">
758
      <include name="abcl.rdf"/>
759
      <include name="build.xml"/>
760
      <include name="abcl.properties.in"/>
761 762
      <include name="COPYING"/>
      <include name="README"/>
763
      <include name="CHANGES"/>
764 765
      <include name="abcl.in"/>
      <include name="abcl.bat.in"/>
766 767

      <include name="abcl.asd"/>
768
      
769
      <include name="examples/**"/>
770 771

      <include name="contrib/**"/>
772 773
      
      <include name="test/**"/>
774

775
      <include name="build-from-lisp.bash"/>
776
      
777 778 779
      <include name="build-abcl.lisp"/>
      <include name="customizations.lisp.in"/>

780 781
      <include name="etc/ant/*.xml"/>

782 783
      <include name="doc/**/*"/>

784 785
      <include name="ci/**/*"/>

786 787
      <!-- FIXME:  currently necessary to build from our source archives -->
      <include name="nbproject/**/*"/>
788 789
    </patternset>

790
    <!-- TODO merge with artifacts from 'abcl.stage' -->
791 792 793
    <patternset 
        id="abcl.source.misc"
        description="Additional includes in the source distribution relative to source root">
794 795
      <include name="org/armedbear/lisp/LICENSE"/>
      <include name="manifest-abcl"/>
796
      <include name="META-INF/services/javax.script.ScriptEngineFactory"/>
797
    </patternset>
798

799
    <target name="abcl.source.prepare" depends="abcl.stamp">
800
      <property name="abcl.build.src.dir"
801
                value="${build.dir}/abcl-src-${abcl.version}"/>
802
      <mkdir dir="${abcl.build.src.dir}/src"/>
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
      <copy todir="${abcl.build.src.dir}/src"
            preservelastmodified="true">
        <fileset dir="${src.dir}"
                 id="abcl.source.src">
            <patternset refid="abcl.source.java"/>
            <patternset refid="abcl.source.lisp"/>
            <patternset refid="abcl.source.misc"/>
        </fileset>
      </copy>
      <copy todir="${abcl.build.src.dir}"
            preservelastmodified="true">
        <fileset dir="${basedir}">
            <patternset refid="abcl.dist.misc"/>
        </fileset>
      </copy>
818 819
    </target>

820 821
    <!--  Files in source distribution that always get LF EOL (aka
         'unix') -->    
822
    <patternset id="abcl.dist.lf">
823 824 825 826 827 828 829 830 831
      <include name="abcl.in"/>
    </patternset>

    <!--  Files in source distribution that always get CRLF EOL (aka
         'dos') -->    
    <patternset id="abcl.dist.crlf">
      <include name="abcl.bat.in"/>
    </patternset>

832
    <target name="abcl.source.unix" depends="abcl.source.prepare">
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
          <patternset refid="abcl.dist.crlf"/>
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
          <patternset refid="abcl.dist.lf"/>
      </fixcrlf>
849
    </target>
850

851
    <target name="abcl.source.tar" depends="abcl.source.unix">
852 853
      <mkdir dir="${dist.dir}"/>
      <tar destfile="${dist.dir}/abcl-src-${abcl.version}.tar.gz"
854 855 856 857
           compression="gzip">
        <tarfileset dir="${build.dir}">
          <include name="abcl-src-${abcl.version}/**"/>
        </tarfileset>
858 859 860
      </tar>
    </target>

861
    <target name="abcl.source.windows" depends="abcl.source.prepare">
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
          <patternset refid="abcl.dist.crlf"/>
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
          <patternset refid="abcl.dist.lf"/>
      </fixcrlf>
878
    </target>
879

880
    <target name="abcl.source.zip" depends="abcl.stamp,abcl.source.windows">
881 882
      <mkdir dir="${dist.dir}"/>
      <zip destfile="${dist.dir}/abcl-src-${abcl.version}.zip"
883 884
           compress="true">
        <zipfileset dir="${abcl.build.src.dir}" prefix="abcl-src-${abcl.version}"/>
885 886
      </zip>
    </target>
887

888
    <target name="abcl.source.jar" depends="abcl.stamp,abcl.source.unix">
889 890 891 892 893 894 895 896 897 898 899 900
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-${abcl.version}-sources.jar">
        <metainf dir="${abcl.build.src.dir}">
          <include name="COPYING"/>
        </metainf>
        <fileset dir="${abcl.build.src.dir}/src">
          <include name="**/*.java"/>
          <include name="**/*.lisp"/>
        </fileset>
      </jar>
    </target>

901 902
    <property name="abcl.javadoc.dir" value="${build.dir}/javadoc"/>

903
    <target name="abcl.javadoc" depends="abcl.stamp">
904 905 906 907 908 909 910 911 912 913 914 915
      <mkdir dir="${abcl.javadoc.dir}"/>
      <javadoc destdir="${abcl.javadoc.dir}"
               sourcepath="${src.dir}"/>
    </target>
    
    <target name="abcl.javadoc.jar" depends="abcl.stamp.version,abcl.javadoc">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-${abcl.version}-javadoc.jar">
        <fileset dir="${abcl.javadoc.dir}"/>
      </jar>
    </target>

916
    <target name="abcl.binary.prepare" depends="abcl.jar,abcl.contrib,abcl.documentation,abcl.stamp.version">
917 918 919 920 921 922 923 924
      <property name="abcl.build.binary.dir"
                value="${build.dir}/abcl-bin-${abcl.version}"/>
      <mkdir dir="${abcl.build.binary.dir}"/>
      <copy todir="${abcl.build.binary.dir}"
            preservelastmodified="true">
        <fileset dir="${basedir}/dist">
          <patternset>
            <include name="abcl.jar"/>
925
            <include name="abcl-contrib.jar"/>
926
            <include name="*.pdf"/>
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
          </patternset>
        </fileset>
        <fileset dir="${basedir}">
          <patternset>
            <include name="README"/>
            <include name="CHANGES"/>
          </patternset>
        </fileset>
      </copy>
    </target>

    <target name="abcl.binary.tar" depends="abcl.binary.prepare">
      <tar destfile="${dist.dir}/abcl-bin-${abcl.version}.tar.gz"
           compression="gzip">
        <tarfileset dir="${build.dir}">
          <include name="abcl-bin-${abcl.version}/**"/>
          </tarfileset>
      </tar>
    </target>

    <target name="abcl.binary.zip" depends="abcl.binary.prepare">
      <zip destfile="${dist.dir}/abcl-bin-${abcl.version}.zip"
           compress="true">
        <zipfileset dir="${abcl.build.binary.dir}" prefix="abcl-bin-${abcl.version}"/>
      </zip>
    </target>
953

954 955 956 957 958 959 960
    <target name="help.test">
      <echo>
The following Ant targets run various test suites:
  
  abcl.test
    --  Run all available tests.
  abcl.test.java
961
    --  Run the ABCL junit Java tests under ${basedir}/test/src/
962 963 964 965 966
  abcl.test.lisp
    --  Run the 'test.ansi.compiled', 'test.abcl', 'test.cl-bench' targets
  test.ansi.compiled
    --  Run the compiled version of the ANSI test suite
  test.abcl
967
    --  Run the Lisp RT tests collected in ${basedir}/test/lisp/abcl/
968 969 970 971 972 973
  test.cl-bench 
    --  Run the cl-bench test suite.

The ANSI tests require that the [ansi-tests][1] be manually installed in 
${basedir}/../ansi-tests.

974
[1]: git+https://gitlab.common-lisp.net/ansi-test/ansi-test.git
975

976
The CL-BENCH tests require that [cl-bench][2] be manually installed in
977 978 979 980 981 982
${basedir}/../cl-bench

[2]: http://www.chez.com/emarsden/downloads/cl-bench.tar.gz
      </echo>
    </target>

983
    <property name="abcl.test.classes.dir"
984
              value="${build.dir}/classes-test"/>
985 986

    <property name="abcl.test.src.dir"
987
              value="${basedir}/test/src"/>
988 989

    <patternset id="abcl.test.source.java">
990
      <include name="org/armedbear/lisp/**/*.java"/>
991 992
    </patternset>

993
    <property name="junit.path"
994
              value="${abcl.ext.dir}/junit-4.8.1.jar"/>
995 996 997 998 999 1000
    <property name="maven.dist.name"
              value="apache-maven-3.3.9-bin.zip"/>
    <property name="maven.dist.uri"
              value="http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/${maven.dist.name}"/>
    <property name="maven.local.path"
              value="${abcl.ext.dir}/${maven.dist.name}"/>
1001 1002

    <path id="abcl.test.compile.classpath">
1003
      <pathelement location="${junit.path}"/>
1004 1005 1006
      <pathelement location="${build.classes.dir}"/>
    </path>

1007 1008 1009
    <target name="abcl.test.pre-compile" depends="abcl.ext"/>

    <target name="abcl.ext.p">
1010
      <!--XXX generalize over enumeration of all contributions to
1011 1012 1013 1014 1015 1016 1017
          abcl.ext if we get more of them.  -->
      <condition property="abcl.ext.p">
        <and>
          <available file="${junit.path}"/>
          <available file="${maven.local.path}"/>
        </and>
      </condition>
1018 1019
    </target>

1020
    <target name="abcl.ext" depends="abcl.ext.p" unless="abcl.ext.p">
1021
      <mkdir dir="${abcl.ext.dir}"/>
Mark's avatar
Mark committed
1022 1023
      <get
          src="https://repo1.maven.org/maven2/junit/junit/4.8.1/junit-4.8.1.jar"
1024 1025
          usetimestamp="true"
          dest="${junit.path}"/>
1026 1027 1028 1029 1030