forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.examples.xml
283 lines (265 loc) · 9.1 KB
/
build.examples.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="scala-examples" default="build">
<description>
I am SABBUS for ${ant.project.name}, the build system for the Scala compiler
and core library. Please check the 'docs/README' file for more information
about me.
</description>
<echo level="info" message="Running SABBUS for ${ant.project.name}..."/>
<!-- ===========================================================================
PROPERTIES
============================================================================ -->
<property environment="env"/>
<!-- Prevents system classpath from being used -->
<property name="build.sysclasspath" value="ignore"/>
<!-- Base properties -->
<property name="src.dir" value="${basedir}/docs"/>
<property name="src.examples.dir" value="${src.dir}/examples"/>
<property name="lib.dir" value="${basedir}/lib"/>
<!-- User properties -->
<property file="${basedir}/build.examples.properties"/>
<!-- Location of pre-compiled libraries properties -->
<property name="scala.lib.jar" value="${lib.dir}/scala-library.jar"/>
<property name="scala.comp.jar" value="${lib.dir}/scala-compiler.jar"/>
<property name="fjbg.name" value="fjbg.jar"/>
<property name="fjbg.jar" value="${lib.dir}/${fjbg.name}"/>
<property name="msil.name" value="msil.jar"/>
<property name="msil.jar" value="${lib.dir}/${msil.name}"/>
<property name="ant.jar" value="${ant.home}/lib/ant.jar"/>
<property name="ant-contrib.jar" value="${lib.dir}/ant/ant-contrib.jar"/>
<!-- -->
<property name="build.dir" value="${basedir}/build"/>
<property name="build.examples.dir" value="${build.dir}/examples"/>
<!-- tbd -->
<property name="excludes.compile"
value="**/*current.*,**/parsers2.*,**/typeinf.*"/>
<property name="excludes.run"
value="**/Parsers.*"/>
<!-- ===========================================================================
INITIALISATION
============================================================================ -->
<target name="init" unless="init.avail">
<tstamp prefix="start">
<format
property="human-time"
pattern="EEEE, d MMMM yyyy, HH:mm:ss (zz)"
/>
</tstamp>
<!-- Testing if everything is in place -->
<echo level="verbose" message="scala.lib.jar=${scala.lib.jar}"/>
<fail message="Scala library in '${lib.dir}/' is not available">
<condition><not><and>
<available
classname="scala.Predef"
classpath="${scala.lib.jar}"
/>
<available
classname="scala.collection.immutable.List"
classpath="${scala.lib.jar}"
/>
<available
classname="scala.runtime.ObjectRef"
classpath="${scala.lib.jar}"
/>
</and></not></condition>
</fail>
<echo level="verbose" message="scala.comp.jar=${scala.comp.jar}"/>
<fail message="Scala compiler in '${lib.dir}/' is not available">
<condition><not>
<available
classname="scala.tools.ant.Scalac"
classpath="${scala.comp.jar}:${scala.lib.jar}"
/>
</not></condition>
</fail>
<echo level="verbose" message="fjbg.jar=${fjbg.jar}"/>
<fail message="FJBG library in '${lib.dir}/' is not available">
<condition><not>
<available
classname="ch.epfl.lamp.fjbg.JCode"
classpath="${fjbg.jar}"
/>
</not></condition>
</fail>
<echo level="verbose" message="msil.jar=${msil.jar}"/>
<fail message="MSIL library in '${lib.dir}/' is not available">
<condition><not>
<available
classname="ch.epfl.lamp.compiler.msil.MemberInfo"
classpath="${msil.jar}"
/>
</not></condition>
</fail>
<echo level="verbose" message="ant.jar=${ant.jar}"/>
<echo level="verbose" message="ant-contrib.jar=${ant-contrib.jar}"/>
<fail message="Additional Ant tasks in '${lib.dir}/' is not available">
<condition><not>
<available
classname="net.sf.antcontrib.AntContribVersion"
classpath="${ant-contrib.jar}"
/>
</not></condition>
</fail>
<!-- Creating class-pathes -->
<path id="common.classpath">
<pathelement location="${fjbg.jar}"/>
<pathelement location="${msil.jar}"/>
</path>
<path id="scala.classpath">
<pathelement location="${scala.lib.jar}"/>
<pathelement location="${scala.comp.jar}"/>
<path refid="common.classpath"/>
</path>
<!-- Creating boot-level tasks -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${ant-contrib.jar}"/>
</classpath>
</taskdef>
<!-- Finding out what system architecture is being used -->
<condition property="os.win">
<os family="windows"/>
</condition>
<if><isset property="os.win"/>
<then>
<exec
executable="cygpath"
vmlauncher="no"
errorproperty="cygpath.err"
outputproperty="cygpath.out"
>
<arg value="--windir"/>
</exec>
<condition property="os.cygwin">
<equals arg1="${cygpath.err}" arg2=""/>
</condition>
</then>
</if>
<condition property="os.unix">
<or>
<os family="unix"/>
<os family="mac"/>
<isset property="os.cygwin"/>
</or>
</condition>
<if><isset property="os.cygwin"/>
<then><property name="os.type" value="Cygwin"/></then>
<elseif><isset property="os.win"/>
<then><property name="os.type" value="Windows"/></then>
</elseif>
<elseif><isset property="os.unix"/>
<then><property name="os.type" value="UNIX"/></then>
</elseif>
<else>
<fail>System environment could not be determined</fail>
</else>
</if>
<echo
level="info"
message="OS: ${os.type} (${os.name} ${os.arch} ${os.version});"
/>
<echo
level="info"
message="Java: ${java.version} ('${java.home}');"
/>
<echo
level="info"
message="JVM: ${java.vm.name} ${java.vm.version};"
/>
<echo
level="info"
message="Ant: ${ant.version}."
/>
<property name="init.avail" value="yes"/>
</target>
<target name="setup" depends="init">
<!-- Creating boot-level tasks -->
<taskdef
name="scalac"
classname="scala.tools.ant.Scalac"
classpathref="scala.classpath"
/>
<property name="init.avail" value="yes"/>
</target>
<!-- ===========================================================================
BUILD
============================================================================ -->
<target name="build" depends="setup">
<mkdir dir="${build.dir}"/>
<echo level="verbose">src.dir=${src.dir}</echo>
<pathconvert property="list" pathsep=",">
<path>
<fileset
dir="${src.dir}"
includes="examples/*.scala"
excludes="${excludes.compile}"
/>
</path>
<mapper>
<globmapper from="${src.dir}/*" to="*"/>
</mapper>
</pathconvert>
<for list="${list}" param="file">
<sequential>
<scalac srcdir="${src.dir}"
destdir="${build.dir}" deprecation="true">
<classpath>
<pathelement location="${scala.lib.jar}"/>
<pathelement location="${build.dir}"/>
</classpath>
<include name="@{file}"/>
</scalac>
</sequential>
</for>
</target>
<!-- ===========================================================================
RUN
============================================================================ -->
<target name="run" depends="build">
<pathconvert property="list" pathsep=",">
<path>
<fileset
dir="${src.dir}"
includes="examples/*.scala"
excludes="${excludes.run}"
/>
</path>
<mapper>
<globmapper from="${src.dir}/*" to="*"/>
</mapper>
</pathconvert>
<for list="${list}" param="file">
<sequential>
<var name="classname" unset="true"/>
<basename property="classname" file="@{file}" suffix=".scala"/>
<echo>Executing Scala program examples.${classname}..</echo>
<java classname="examples.${classname}" fork="true"
output="${build.examples.dir}/${classname}.log"
error="${build.examples.dir}/${classname}.log"
append="true">
<classpath>
<pathelement location="${scala.lib.jar}"/>
<pathelement location="${build.dir}"/>
</classpath>
</java>
</sequential>
</for>
</target>
<!-- ===========================================================================
CLEAN
============================================================================ -->
<macrodef name="remove">
<attribute name="dir"/>
<sequential>
<delete
dir="@{dir}"
includeemptydirs="yes"
quiet="yes"
failonerror="no"
/>
</sequential>
</macrodef>
<target name="clean" description="Removes all build examples">
<remove dir="${build.examples.dir}"/>
</target>
</project>