summaryrefslogtreecommitdiff
path: root/build.xml
blob: 1df166e6e3e9bc5c37bac6d592b00c625ffe4471 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<project name="nsc" default="build">

    <description>
      This build-file builds the Scala NSC compiler as well as various related
      tools. The 'build.TEMPLATE.properties' file must be customised for your
      own particular system, no other customisation should be required. The
      build file expects the file structure of a Scala CVS distribution.
    </description>

    <!-- The system classpath should not be used -->
    <property name="build.sysclasspath" value="ignore" />

    <!-- Properties in 'build.${user.name}.properties' take precedence over
         properties in 'build.default.properties'.
    -->
    <echo level="verbose">Loading properties from '${basedir}/build.support/build.base.properties'</echo>
    <property file="${basedir}/build.support/build.base.properties" />
    <echo level="verbose">Loading properties from '${build.support.dir}/build.${user.name}.properties'</echo>
    <property file="${build.support.dir}/build.${user.name}.properties" />
    <echo level="verbose">Loading properties from '${build.support.dir}/build.default.properties'</echo>
    <property file="${build.support.dir}/build.default.properties" />
    
    <!-- A path containing pre-compiled Scala libraries found typically
         in a Scala distribution. -->
    <path id="osc.classpath">
        <pathelement location="${oslib.jar}" />
        <pathelement location="${oslib.src}" />
        <pathelement location="${ostools.jar}" />
        <pathelement location="${fjbg.jar}" />
        <pathelement location="${msil.jar}" />
    </path>

    <!-- A path containing the Pico library -->
    <path id="pico.classpath">
        <pathelement location="${jaco.jar}" />
    </path>

    <!-- A path containing the new Scala library -->
    <path id="nsc.classpath">
        <pathelement location="${build.osc-nstools.dir}" />
        <pathelement location="${build.nslib.dir}" />
        <pathelement location="${oslib.jar}" />
        <pathelement location="${fjbg.jar}" />
        <pathelement location="${msil.jar}" />
    </path>

    <!-- The current Scala version -->
    <loadfile srcfile="${basedir}/VERSION" property="scala.version">
        <filterchain>
            <tailfilter lines="1" />
        </filterchain>
    </loadfile>

    <target name="all"
            description="Builds and tests everything; creates a distribution." />

    <!--
    #####################################################################
    INIT
    #####################################################################
    -->
    
    <target name="init.osc">
        <echo level="verbose">oslib.jar=${oslib.jar}</echo>
        <echo level="verbose">oslib.src=${oslib.src}</echo>
        <echo level="verbose">ostools.jar=${ostools.jar}</echo>
        <echo level="verbose">fjbg.jar=${fjbg.jar}</echo>
        <echo level="verbose">msil.jar=${msil.jar}</echo>
        <fail message="Required classes for OSC are missing; check the 'oslib.jar', 'ostools.jar' properties in 'build.${user.name}.properties'.">
            <condition><not><and>
                <available classname="scala.List" classpathref="osc.classpath" />
                <available classname="scala.runtime.RunTime" classpathref="osc.classpath" />
                <available classname="scala.tools.scalac.Main" classpathref="osc.classpath" />
                <available classname="scala.tools.scalac.ant.Scalac" classpathref="osc.classpath" />
            </and></not></condition>
        </fail>
        <fail message="Required classes for FJBG are missing; check the 'fjbg.jar' property in 'build.${user.name}.properties'.">
            <condition><not><and>
                <available classname="ch.epfl.lamp.fjbg.JField" classpathref="osc.classpath"/>
                <available classname="ch.epfl.lamp.util.ByteArray" classpathref="osc.classpath"/>
            </and></not></condition>
        </fail>
        <fail message="Required classes for MSIL are missing; check the 'msil.jar' property in 'build.${user.name}.properties'.">
            <condition><not><and>
                <available classname="ch.epfl.lamp.compiler.msil.Module" classpathref="osc.classpath"/>
                <available classname="ch.epfl.lamp.compiler.msil.Type" classpathref="osc.classpath"/>
            </and></not></condition>
        </fail>
        <taskdef name="osc" classname="scala.tools.scalac.ant.Scalac"
                 classpathref="osc.classpath" />
    </target>

    <target name="init.nsc" depends="build.osc.nstools, build.pico.nslib">
        <taskdef name="nsc" classname="scala.tools.nsc.ant.NSC$class"
                 classpathref="nsc.classpath" />
    </target>

    <target name="init.pico">
        <echo level="verbose">jaco.jar=${jaco.jar}</echo>
        <fail message="Required classes for PiCo are missing; check the 'jaco.jar' property in 'build.properties'.">
            <condition><not><and>
                <available classname="jaco.pizza.Main" classpathref="pico.classpath"/>
                <available classname="jaco.pizza.ant.Pico" classpathref="pico.classpath"/>
            </and></not></condition>
        </fail>
        <taskdef name="pico" classname="jaco.pizza.ant.Pico" classpathref="pico.classpath"/>
    </target>
    
    <!--
    #####################################################################
    BUILD
    #####################################################################
    -->
    
    <target name="build" depends="build.nsc.nstools"
            description="Builds new Scala (compiler and library)." />
    
    <target name="build.pico.nslib" depends="init.pico"
            description="Builds the runtime and pico libraries of the new Scala library.">
        <mkdir dir="${build.nslib.dir}"/>
        <pico srcdir="${sources.dir}" destdir="${build.nslib.dir}"
              scalahack="true">
            <classpath>
                <pathelement location="${build.nslib.dir}" />
            </classpath>
            <include name="scala/runtime/*.java" />
            <include name="scala/runtime/**/*.java" />
            <include name="scala/tools/util/*.java" />
            <include name="scala/*.java" />
            <not>
                <present targetdir="${newsources.dir}" present="both">
                    <mapper type="glob" from="*.scala" to="*.java" />
                </present>
            </not>
        </pico>
        <delete>
            <fileset dir="${build.nslib.dir}">
                <present targetdir="${newsources.dir}" present="both">
                    <mapper type="glob" from="*.class" to="*.scala" />
                </present>
            </fileset>
        </delete>
    </target>

    <target name="build.osc.nstools" depends="init.osc"
            description="Builds the new Scala compiler.">
        <mkdir dir="${build.osc-nstools.dir}" />
        <osc srcdir="${sources.dir}" destdir="${build.osc-nstools.dir}"
             force="changed">
            <classpath>
                <pathelement location="${build.osc-nstools.dir}" />
                <pathelement location="${oslib.jar}" />
                <pathelement location="${fjbg.jar}" />
                <pathelement location="${ant.jar}" />
            </classpath>
            <include name="scala/tools/nsc/**/*.scala" />
            <include name="scala/runtime/*.scala" />
            <include name="scala/runtime/**/*.scala" />
        </osc>
    </target>
    
    <target name="build.nsc.nslib" depends="init.nsc, build.pico.nslib"
            description="Builds the Scala library with the new Scala compiler.">
        <mkdir dir="${build.nslib.dir}" />
        <nsc srcdir="${sources.dir}" destdir="${build.nslib.dir}"
             usepredefs="false"
             stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}"
             logging="${nsc.logging}">
            <classpath>
                <pathelement location="${build.nslib.dir}" />
                <pathelement location="${sources.dir}" />
                <pathelement location="${newsources.dir}" />
                <pathelement location="${fjbg.jar}" />
            </classpath>
            <include name="scala/Predef.scala" />
            <include name="scala/runtime/ScalaRunTime.scala" />
        </nsc>
        <nsc srcdir="${sources.dir}" destdir="${build.nslib.dir}"
             excludesfile="${nsc.nslib.excludes}"
             stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}"
             logging="${nsc.logging}">
            <classpath>
                <pathelement location="${build.nslib.dir}" />
                <pathelement location="${sources.dir}" />
                <pathelement location="${newsources.dir}" />
                <pathelement location="${fjbg.jar}" />
            </classpath>
            <include name="scala/**/*.scala" />
            <exclude name="scala/Predef.scala" />
            <exclude name="scala/runtime/ScalaRunTime.scala" />
            <exclude name="scala/tools/**" />
        </nsc>
    </target>
    
    <target name="build.nsc.nstools" depends="init.nsc, build.nsc.nslib"
            description="Builds the Scala tools (NSC and Scalap) with the new Scala compiler.">
        <mkdir dir="${build.nstools.dir}" />
        <nsc srcdir="${sources.dir}" destdir="${build.nstools.dir}"
             excludesfile="${nsc.nstools.excludes}"
             stop="${nsc.stop}" skip="${nsc.skip}" check="${nsc.check}"
             logging="${nsc.logging}">
            <classpath>
                <pathelement location="${build.nslib.dir}" />
                <pathelement location="${build.nstools.dir}" />
                <pathelement location="${fjbg.jar}" />
                <pathelement location="${ant.jar}" />
            </classpath>
            <include name="scala/tools/nsc/**/*.scala" />
            <exclude name="scala/tools/nsc/ant/*.scala" />
        </nsc>
    </target>

    <!--
    #####################################################################
    DISTRIB
    #####################################################################
    -->

    <condition property="os.unix">
        <or>
            <os family="unix" />
            <os family="mac" />
        </or>
    </condition>

    <condition property="os.mac">
        <os family="mac" />
    </condition>

    <condition property="os.win">
        <os family="windows" />
    </condition>

    <target name="distrib"
            depends="distrib.unix, distrib.mac, distrib.win"
            description="Creates a (simplified) Scala distribution." />

    <target name="distrib.unix" depends="build" if="os.unix">
        <tstamp prefix="start" />
        <property name="distrib.current.dir"
                  value="${distrib.dir}/${distrib.current.prefix}-${start.DSTAMP}-${start.TSTAMP}" />
        <property name="distrib.scala.dir"
                  value="${distrib.current.dir}/share/scala" />
        <property name="distrib.doc.dir"
                  value="${distrib.current.dir}/share/doc/${distrib.current.prefix}-${start.DSTAMP}-${start.TSTAMP}" />
        <mkdir dir="${distrib.scala.dir}" />
        <mkdir dir="${distrib.scala.dir}/lib" />
        <symlink resource="${distrib.scala.dir}/lib"
                 link="${distrib.current.dir}/lib" />
        <jar destfile="${distrib.scala.dir}/lib/${distrib.osc-nstools.jar}"
             basedir="${build.osc-nstools.dir}">
            <include name="**" />
            <manifest>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Main-Class" value="scala.tools.nsc.Main$class"/>
            </manifest>
        </jar>
        <jar destfile="${distrib.scala.dir}/lib/${distrib.nstools.jar}"
             basedir="${build.nstools.dir}">
            <include name="**" />
            <manifest>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Main-Class" value="scala.tools.nsc.Main$class"/>
            </manifest>
        </jar>
        <jar destfile="${distrib.scala.dir}/lib/${distrib.nslib.jar}"
             basedir="${build.nslib.dir}">
            <include name="**" />
            <manifest>
                <attribute name="Built-By" value="${user.name}" />
            </manifest>
        </jar>
        <!-- Set up bin -->
        <mkdir dir="${distrib.scala.dir}/bin" />
        <symlink resource="${distrib.scala.dir}/bin"
                 link="${distrib.current.dir}/bin" />
        <!-- Set up man -->
        <mkdir dir="${distrib.scala.dir}/man" />
        <copy todir="${distrib.scala.dir}/man">
            <fileset dir="${support.dir}/man" includes="**/*.1" />
        </copy>
        <!-- Set up doc -->
        <mkdir dir="${distrib.doc.dir}" />
        <copy todir="${distrib.doc.dir}">
            <fileset dir="${basedir}" includes="README,LICENSE,VERSION" />
            <fileset dir="${basedir}/sources" includes="examples/**/*.scala" />
        </copy>
        <copy todir="${distrib.doc.dir}">
            <fileset dir="${doc.dir}/reference" includes="ScalaReference.pdf" />
            <fileset dir="${doc.dir}/tutorial" includes="*.pdf" />
        </copy>
        <!-- Set up latest -->
        <symlink resource="${distrib.current.dir}"
                 link="${distrib.dir}/latest" />
    </target>

    <target name="distrib.mac" depends="distrib.unix, build" if="os.mac" />

    <target name="distrib.win" depends="build" if="os.win">
        <tstamp prefix="start" />
        <fail>Windows distribution is not supported yet.</fail>
    </target>

    <!--
    #####################################################################
    TEST
    #####################################################################
    -->

    <target name="test" description="Runs the Scala test suite.">
        <fail>'test' is not implemented yet.</fail>
    </target>

    <!--
    #####################################################################
    DOCS
    #####################################################################
    -->
    
    <target name="docs" description="Generates all documentation.">
        <echo level="verbose">oslib.jar=${oslib.jar}</echo>
        <echo level="verbose">oslib.src=${oslib.src}</echo>
        <echo level="verbose">ostools.jar=${ostools.jar}</echo>
        <fileset id="oslib.src.files" dir="${oslib.src}">
            <include name="scala/**/*.scala" />
            <exclude name="scala/tools/**" />
        </fileset>
        <pathconvert pathsep=" " property="docs.sources" refid="oslib.src.files" />
        <mkdir dir="${build.dir}/doc/api" />
        <java classname="scala.tools.scaladoc.Main" fork="true">
            <jvmarg value="-Dscala.library.source.path=${oslib.src}" />
            <jvmarg value="-Dscala.library.class.path=${oslib.jar}" />
            <classpath>
                <pathelement location="${oslib.jar}" />
                <pathelement location="${ostools.jar}" />
            </classpath>
            <arg line="-windowtitle 'Scala Library Documentation'" />
            <arg line="-doctitle 'Scala&lt;br/&gt;${scala.version}'" />
            <arg line="-d ${build.dir}/doc/api" />
            <arg line="${docs.sources}" />
            <arg line="-- scala" />
        </java>
    </target>
    
    <!--
    #####################################################################
    CLEAN
    #####################################################################
    -->
    
    <target name="clean"
            depends="clean.build, clean.distrib"
            description="Deletes all generated files, both build and distribution files." />

    <target name="clean.build"
            description="Deletes all generated build files.">
        <delete dir="${build.dir}" includeemptydirs="true"
                quiet="true" failonerror="false" />
    </target>
    
    <target name="clean.distrib"
            description="Deletes all generated distribution files.">
        <delete dir="${distrib.dir}" includeemptydirs="true"
                quiet="true" failonerror="false">
            <fileset>
                <include name="${distrib.current.prefix}-*" />
            </fileset>
        </delete>
    </target>

    <!--
    #####################################################################
    HELP
    #####################################################################
    -->

    <target name="help" depends="usage" />

    <target name="usage" description="Display usage information.">
        <echo>Execute 'ant -projecthelp' for build file help.</echo>
        <echo>Execute 'ant -help' for Ant help.</echo>
    </target>

</project>