root/trunk/ProjectFortress/build.xml

Revision 2879, 46.8 kB (checked in by sukyoungryu, 2 weeks ago)

[build] Use the ProjectFortress?/test-tmp directory for dumping temporary files.

Line 
1 <?xml version="1.0" ?>
2
3 <!--
4     Copyright 2008 Sun Microsystems, Inc.,
5     4150 Network Circle, Santa Clara, California 95054, U.S.A.
6     All rights reserved.
7
8     U.S. Government Rights - Commercial software.
9     Government users are subject to the Sun Microsystems, Inc. standard
10     license agreement and applicable provisions of the FAR and its supplements.
11
12     Use is subject to license terms.
13
14     This distribution may include materials developed by third parties.
15
16     Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
17     trademarks of Sun Microsystems, Inc. in the U.S. and other countries. -->
18
19
20 <project name="Fortress" default="help">
21     <description>
22         The Fortress interpreter, implemented in Java.
23     </description>
24
25     <!-- test -->
26
27 <!-- Set global properties for this build. -->
28  <property name="packagePrefix" value="com/sun/fortress"/>
29  <property name="package.prefix" value="com.sun.fortress"/>
30  <property name="interpreterPrefix" value="com/sun/fortress/interpreter"/>
31  <property name="interpreter.prefix" value="com.sun.fortress.interpreter"/>
32  <!-- Directories in the ${basedir} directory -->
33  <property name="cache0" location="${basedir}/../default_repository/caches"/>
34  <property name="cache1" location="${basedir}/../.fortress_cache"/>
35  <property name="cache2" location="${basedir}/../.interpreter_cache"/>
36  <property name="cache3" location="${basedir}/.interpreter_cache"/>
37  <property name="cache4" location="${basedir}/../.syntax_cache"/>
38  <property name="cache5" location="${basedir}/.syntax_cache"/>
39  <property name="cache6" location="${basedir}/../.analyzed_cache"/>
40  <property name="cache7" location="${basedir}/.analyzed_cache"/>
41  <property name="cache8" location="${basedir}/../.presyntax_cache"/>
42  <property name="cache9" location="${basedir}/.presyntax_cache"/>
43  <property name="cache10" location="${basedir}/../.bytecode_cache"/>
44  <property name="cache11" location="${basedir}/.bytecode_cache"/>
45  <property name="cache12" location="${basedir}/../local_repository/caches"/>
46  <property name="astgen.src" location="${basedir}/astgen"/>
47  <property name="build" location="${basedir}/build"/>
48  <property name="docs" location="${basedir}/docs"/>
49  <property name="src" location="${basedir}/src"/>
50  <property name="library" location="${basedir}/../Library"/>
51  <property name="astgen.generators.src" location="${src}/${packagePrefix}/astgen"/>
52  <!-- Third party jar files -->
53  <property name="asm" location="${basedir}/third_party/asm"/>
54  <!-- property name="astgen.third" location="${basedir}/../../astgen/jar"/ -->
55  <property name="astgen.third" location="${basedir}/third_party/astgen"/>
56  <property name="jsr166y" location="${basedir}/third_party/jsr166y"/>
57  <property name="junit" location="${basedir}/third_party/junit"/>
58  <property name="plt" location="${basedir}/third_party/plt"/>
59  <property name="unicode.third" location="${basedir}/third_party/unicode"/>
60  <property name="xtc" location="${basedir}/third_party/xtc"/>
61  <property name="unsigned" location="${basedir}/third_party/unsigned"/>
62  <!-- astgen -->
63  <property name="generate-sourcefile" value="${astgen.src}/Fortress.ast" />
64  <!-- nodes -->
65  <property name="nodesPackage" value="${packagePrefix}/nodes"/>
66  <property name="nodes"  location="${src}/${nodesPackage}"/>
67  <property name="nodesBuild" location="${build}/${nodesPackage}"/>
68  <!-- nodes_util -->
69  <property name="nodesUtil"  location="${src}/${packagePrefix}/nodes_util"/>
70  <!-- parser -->
71  <property name="parser"  location="${src}/${packagePrefix}/parser"/>
72  <property name="preparser" location="${src}/${packagePrefix}/parser/preparser"/>
73  <property name="templateparser"  location="${src}/${packagePrefix}/parser/templateparser"/>
74  <property name="parserUtil"  location="${src}/${packagePrefix}/parser_util"/>
75  <property name="precedence" location="${parserUtil}/precedence"/>
76  <property name="precedenceResolver" location="${parserUtil}/precedence_resolver"/>
77  <!-- unicode -->
78  <property name="unicodePackage" value="${packagePrefix}/unicode"/>
79  <property name="unicode" location="${src}/${packagePrefix}/unicode"/>
80  <property name="unicodeBuild" location="${build}/${unicodePackage}"/>
81  <!-- useful -->
82  <property name="usefulPackage" value="${packagePrefix}/useful"/>
83  <!-- for fortress installation -->
84  <property name="testFortress" location=".TEST_FORTRESS"/>
85  <property name="installerDir" location=".installer"/>
86  <property name="protofortress" location="${basedir}/fortress/FORTRESS"/>
87  <property name="protofortress.lib" location="${protofortress}/lib"/>
88 <!-- for tests -->
89  <property name="test.results" location="${basedir}/TEST-RESULTS"/>
90 <!-- other setting -->
91  <property name="junitMem" value="768m"/>
92  <property name="junit.dir" value="junit-results"/>
93  <property environment="env"/>
94
95  <path id="astgen.path">
96      <pathelement location="${astgen.third}/astgen.jar" />
97      <pathelement location="${build}" />
98  </path>
99
100  <path id="compile.classpath">
101     <pathelement location="${java.home}/../lib/tools.jar"/>
102     <pathelement location="${build}"/>
103     <pathelement location="${asm}/asm-3.1.jar"/>
104     <pathelement location="${xtc}/xtc.jar"/>
105     <pathelement location ="${unsigned}/unsigned.jar"/>
106     <pathelement location="${jsr166y}/jsr166y.jar"/>
107     <pathelement location="${plt}/plt.jar"/>
108     <pathelement location="${astgen.third}/astgen.jar" />
109     <pathelement location="${junit}/junit.jar"/>
110     <pathelement location="${ant.home}/lib/ant.jar"/>
111 </path>
112
113  <path id="astgen.classpath">
114     <pathelement location="${build}"/>
115     <pathelement location="${astgen.third}/astgen.jar"/>
116 </path>
117
118  <property name="instrumentation.package"
119            value="${package.prefix}.parser_util.instrumentation"/>
120  <property name="instrumentationPackage"
121            value="${packagePrefix}/parser_util/instrumentation"/>
122  <property name="instrumentation.outfile"
123            location="${parserUtil}/instrumentation/coverage-report.txt"/>
124  <property name="instrumentation.transient"
125            location="${parserUtil}/instrumentation/transient.txt"/>
126
127  <path id="instrumentedparser.classpath">
128     <pathelement location="${build}"/>
129     <pathelement location="${xtc}/xtc.jar"/>
130     <pathelement location="${plt}/plt.jar"/>
131  </path>
132
133  <property name="blahblahblah" value="com/sun/fortress"/>
134
135     <target name="help">
136         <echo message="ant checkEnv, checkNodesUptodate, checkOperatorsUptodate,
137 checkParserUptodate, clean, cleanCache, compile, compileCommon, compileCommonLint,
138 compileLint, doc, grammarCoverage, help, init, interpreter-jar, makeAST, operatorsGen,
139 fortressparser, preparser, parser, reportNotPassing, systemProperties,
140 test, testAll, testDemos, testSystem,
141 testOnly -DtestPattern='some pattern', testCruiseControl"/>
142         <echo message="If you are building Fortress, you want ant compile or ant test."/>
143     </target>
144
145     <condition property="correct.environment">
146         <and>
147             <equals arg1="${ant.java.version}" arg2="1.5"/>
148             <equals arg1="${env.ANT_CALLED_FROM_SCRIPT}" arg2='yes'/>
149         </and>
150     </condition>
151
152     <target name="systemProperties">
153         <echo message="Environment variables set correctly? ${correct.environment}"/>
154         <echo message="Ant Java version: ${ant.java.version}"/>
155         <echo message="Ant called from script? ${env.ANT_CALLED_FROM_SCRIPT}"/>
156         <echo message="ANT_ARGS: ${env.ANT_ARGS}"/>
157         <echo message="ANT_OPTS: ${env.ANT_OPTS}"/>
158         <echo message="Java Runtime Environment
159         version: ${java.version}"/>
160         <echo message="Java Runtime Environment
161         vendor: ${java.vendor}"/>
162         <echo message="Java Runtime Environment
163         vendor URL: ${java.vendor.url}"/>
164         <echo message="Java installation
165         directory: ${java.home}"/>
166         <echo message="Java Virtual Machine
167               specification version:
168         ${java.vm.specification.version}"/>
169         <echo message="Java Virtual Machine
170               specification vendor:
171         ${java.vm.specification.vendor}"/>
172         <echo message="Java Virtual Machine
173               specification name:
174         ${java.vm.specification.name}"/>
175         <echo message="Java Virtual Machine
176               implementation version:
177         ${java.vm.version}"/>
178         <echo message="Java Virtual Machine
179               implementation vendor:
180         ${java.vm.vendor}"/>
181         <echo message="Java Virtual Machine
182         implementation name: ${java.vm.name}"/>
183         <echo message="Java Runtime Environment
184               specification version:
185         ${java.specification.version}"/>
186         <echo message="Java Runtime Environment
187               specification vendor:
188         ${java.specification.vendor}"/>
189         <echo message="Java Runtime Environment
190               specification name:
191         ${java.specification.name}"/>
192         <echo message="Java class format version
193         number: ${java.class.version}"/>
194         <echo message="Java class path:
195         ${java.class.path}"/>
196         <echo message="List of paths to search when
197         loading libraries: ${java.library.path}"/>
198         <echo message="Path of extension directory
199         or directories: ${java.ext.dirs}"/>
200         <echo message="Default temp file path:
201         ${java.io.tmpdir}"/>
202         <echo message="Operating system name:
203         ${os.name}"/>
204         <echo message="Operating system
205         architecture: ${os.arch}"/>
206         <echo message="Operating system version:
207         ${os.version}"/>
208     </target>
209
210     <target name="checkEnv">
211         <echo message="Environment variables set correctly? ${correct.environment}"/>
212         <fail unless="correct.environment"
213               message='ERROR: This build script requires specific command-line arguments to Ant. Please call it using the script provided at ${basedir}/ant.'/>
214     </target>
215
216     <target name="init">
217         <echo message="basedir: ${basedir}"/>
218         <!-- Create the time stamp. -->
219         <tstamp/>
220         <!-- Create the build directory structure used by compile. -->
221         <mkdir dir="${build}"/>
222         <mkdir dir="${junit.dir}"/>
223     </target>
224
225     <target name="clean" depends="cleanCache"
226             description="Delete the ${build} directory tree and generated files.">
227         <delete dir="${build}"/>
228         <delete dir="${nodes}"/>
229         <delete dir="${junit.dir}"/>
230
231         <!-- No longer needed, but eases the upgrade-->
232         <delete file="${nodesUtil}/BaseNodeMaker.java"/>
233         <!-- No longer needed, but eases the upgrade-->
234         <delete file="${nodesUtil}/InterfaceMaker.java"/>
235         <delete file="${parser}/Fortress.java"/>
236         <delete file="${parser}/FortressInstrumented.java"/>
237         <delete file="${preparser}/PreFortress.java"/>
238         <delete file="${templateparser}/TemplateParser.java"/>
239         <delete file="${precedenceResolver}/Operators.java"/>
240         <!-- No longer needed, but eases the upgrade-->
241         <delete file="${src}/com/sun/fortress/parser/precedence/resolver/Operators.java"/>
242         <delete file="${instrumentation.outfile}"/>
243         <delete file="${library}/FortressAst.fsi" />
244         <delete file="${library}/FortressAst.fss" />
245         <delete file="FortressLibrary.ast"/>
246         <delete file="FortressLibrary.tfs"/>
247         <delete file="testFile.txt"/>
248         <delete dir="${basedir}/test-tmp" />
249         <delete>
250             <fileset dir="src" includes="**/*.class" />
251         </delete>
252     </target>
253
254     <target name="cleanCache"
255             description="Delete any cached Fortress ASTs in the development tree">
256         <delete dir="${cache0}"/>
257         <delete dir="${cache1}"/>
258         <delete dir="${cache2}"/>
259         <delete dir="${cache3}"/>
260         <delete dir="${cache4}"/>
261         <delete dir="${cache5}"/>
262         <delete dir="${cache6}"/>
263         <delete dir="${cache7}"/>
264         <delete dir="${cache8}"/>
265         <delete dir="${cache9}"/>
266         <delete dir="${cache10}"/>
267         <delete dir="${cache11}"/>
268         <delete dir="${cache12}"/>
269     </target>
270
271     <!-- Generation of Operators.java depends only on the files listed below.
272          Note that there are class files it depends on; if these class files are
273          not up to date with respect to their sources, they are themselves
274          recompiled by the compileCommon target.-->
275     <target name="checkOperatorsUptodate" depends="init, compileCommon">
276         <condition property="operators.uptodate">
277             <and>
278                 <uptodate srcfile="${unicode.third}/UnicodeData.500.txt"
279                           targetfile="${precedenceResolver}/Operators.java"/>
280                 <uptodate srcfile="${precedenceResolver}/operators.txt"
281                           targetfile="${precedenceResolver}/Operators.java"/>
282                 <uptodate srcfile="${unicodeBuild}/OperatorStuffGenerator.class"
283                           targetfile="${precedenceResolver}/Operators.java"/>
284                 <uptodate srcfile="${unicodeBuild}/Element.class"
285                           targetfile="${precedenceResolver}/Operators.java"/>
286             </and>
287         </condition>
288         <echo message="Operators up to date? ${operators.uptodate}"/>
289     </target>
290
291            <target name="operatorsGen"  unless="operators.uptodate"
292                     depends="init, compileCommon, checkOperatorsUptodate"
293              description="Automatically generate visitors for AST nodes.">
294                 <echo message="Regenerating operators"/>
295                 <java classname="${package.prefix}.unicode.OperatorStuffGenerator"
296                       fork="true">
297                     <classpath>
298                         <pathelement location="${build}"/>
299                         <pathelement location="${basedir}/third_party/plt/plt.jar"/>
300                     </classpath>
301                 </java>
302             </target>
303
304            <target name="DumpProperties"
305              description="Dump properties as seen by a Java program.">
306             <java classname="${package.prefix}.repository.DumpProperties"
307                       fork="true">
308                 <sysproperty key="DEBUG" value="true"/>
309                     <classpath>
310                         <pathelement location="${build}"/>
311                     </classpath>
312                 </java>
313             </target>
314
315     <target name="checkAstgen">
316         <condition property="astgenerators.uptodate">
317                 <uptodate targetfile="${basedir}/build/com/sun/fortress/astgen/FortressAstGenerator.class">
318                     <srcfiles dir="${basedir}/src/com/sun/fortress/astgen/" includes="*.java"/>
319                 </uptodate>
320         </condition>
321     </target>
322
323     <target name="astGenerators" unless="astgenerators.uptodate" depends="init,checkAstgen"
324      description="Compile all AstGen custom generators.">
325         <depend srcdir="${astgen.generators.src}"
326          destdir="${build}"
327          closure="yes"
328          cache="${basedir}/.dependencies"/>
329         <javac
330             srcdir="${astgen.generators.src}"
331             destdir="${build}"
332             source="1.5"
333             debug="true"
334             includeantruntime="false"
335             fork="true"
336             memorymaximumsize="256M">
337             <!-- Uncomment the following line to print unchecked warnings
338                  (here and in the 'compileCommon' target. -->
339             <!-- <compilerarg value="-Xlint:unchecked"/> -->
340             <classpath refid="astgen.classpath"/>
341             <include name="**/*.java"/>
342             <exclude name="${usefulPackage}/*.java"/>
343             <exclude name="${unicodePackage}/*.java"/>
344         </javac>
345     </target>
346
347     <target name="checkNodesUptodate" depends="astGenerators">
348         <condition property="nodes.uptodate">
349           <and>
350             <available file="${nodes}/AbstractNode.java"/>
351             <uptodate srcfile="${astgen.src}/Fortress.ast"
352                       targetfile="${nodes}/AbstractNode.java"/>
353             <available file="${library}/FortressAst.fsi" />
354             <uptodate srcfile="${astgen.src}/Fortress.ast"
355                     targetfile="${library}/FortressAst.fsi" />
356             <available file="${library}/FortressAst.fss" />
357             <uptodate srcfile="${astgen.src}/Fortress.ast"
358                     targetfile="${library}/FortressAst.fss" />
359             <uptodate targetfile="${library}/FortressAst.fsi">
360                   <srcfiles dir="${basedir}/src/com/sun/fortress/astgen/" includes="**/*.java"/>
361             </uptodate>
362           </and>
363         </condition>
364         <echo message="Nodes up to date? ${nodes.uptodate}"/>
365     </target>
366
367     <taskdef name="astgen" classpath="${astgen.third}/astgen.jar;${build}"
368              classname="edu.rice.cs.astgen.AntTask"/>
369
370     <target name="makeAST" unless="nodes.uptodate" depends="checkNodesUptodate"
371      description="Automatically generate AST nodes.">
372         <echo message="Processing ${generate-sourcefile}" />
373         <astgen file="${generate-sourcefile}" />
374         <move todir="${nodes}">
375           <fileset dir="${astgen.src}">
376             <include name="**/*.java"/>
377             <exclude name="**/Fortress.ast"/>
378           </fileset>
379         </move>
380         <move todir="${library}">
381           <fileset dir="${astgen.src}">
382             <include name="FortressAst.*" />
383           </fileset>
384         </move>
385     </target>
386
387     <target name="compile" depends="compileCommon, makeAST, parser, operatorsGen"
388      description="Compile all Fortress code.">
389         <depend srcdir="${src}"
390          destdir="${build}"
391          closure="yes"
392          cache="${basedir}/.dependencies"/>
393         <javac
394             srcdir="${src}"
395             destdir="${build}"
396             source="1.5"
397             debug="true"
398             includeantruntime="false"
399             fork="true"
400             memorymaximumsize="256M">
401             <!-- Uncomment the following line to print unchecked warnings
402                  (here and in the 'compileCommon' target. -->
403             <!-- <compilerarg value="-Xlint:unchecked"/> -->
404             <classpath refid="compile.classpath"/>
405             <include name="**/*.java"/>
406             <exclude name="${usefulPackage}/*.java"/>
407             <exclude name="${unicodePackage}/*.java"/>
408         </javac>
409     </target>
410
411     <target name="check.blas" depends="init">
412         <javac destdir="${build}" srcdir="${src}/com/sun/fortress/numerics">
413             <classpath refid="compile.classpath"/>
414         </javac>
415         <java failonerror="true" classname="com.sun.fortress.numerics.CheckBlasEnvironment">
416             <classpath refid="compile.classpath"/>
417         </java>
418     </target>
419
420     <target name="check.linux">
421         <condition property="blas.islinux">
422              <equals arg1="${os.name}" arg2="Linux" />
423         </condition>
424     </target>
425
426     <target name="blas.linux" depends="check.linux" if="blas.islinux">
427             <echo message="Generating C header and stub files." />
428             <javah class="com.sun.fortress.numerics.Blas"
429                    destdir="c"
430                    classpath="build"
431                     />
432             <echo message="Now compiling C stubs for blas on arch linux."/>
433             <exec executable="gcc" failonerror="true">
434                     <arg value="-fPIC" />
435                     <arg value="-Ic" />
436                     <arg value="-I${env.BLAS_INCLUDE}" />
437                     <arg value="-L${env.BLAS_LIB}" />
438                     <arg value="-I${env.JAVA_HOME}/include" />
439                     <arg value="-I${env.JAVA_HOME}/include/linux" />
440                     <arg value="c/blas.c" />
441                     <arg value="-lcblas" />
442                     <arg value="-lblas" />
443                     <arg value="-shared" />
444                     <arg value="-olibblas.so" />
445             </exec>
446     </target>
447
448     <target name="check.osx">
449         <condition property="blas.is.osx">
450              <equals arg1="${os.name}" arg2="Mac OS X" />
451         </condition>
452     </target>
453
454     <target name="blas.osx" depends="check.osx" if="blas.is.osx">
455             <echo message="Generating C header and stub files." />
456             <javah class="com.sun.fortress.numerics.Blas"
457                    destdir="c"
458                    classpath="build"
459                     />
460             <echo message="Now compiling C stubs for blas on arch OS X."/>