-
Notifications
You must be signed in to change notification settings - Fork 62
/
build.xml
executable file
·351 lines (309 loc) · 12.8 KB
/
build.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
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
<?xml version="1.0"?>
<project name="erjang" default="all">
<property name="erjang.version" value="0.2" />
<property file="erjang_cfg.properties" />
<path id="erjang.classpath">
<pathelement location="target/classes/" />
<pathelement location="lib/js.jar" />
<pathelement location="lib/kilim.jar" />
<pathelement location="lib/OtpErlang.jar" />
<pathelement location="lib/junit.jar" />
<pathelement location="lib/clj-ds.jar" />
<pathelement location="lib/antlr-3.2.jar" />
<pathelement path="${java.class.path}" />
</path>
<path id="erjang.testwovenclasspath">
<pathelement location="target/classes/" />
<pathelement location="target/test-classes/" />
<pathelement location="lib/kilim.jar" />
<pathelement location="lib/OtpErlang.jar" />
<pathelement location="lib/clj-ds.jar" />
<pathelement location="lib/junit.jar" />
<pathelement location="lib/antlr-3.2.jar" />
<pathelement path="${java.class.path}" />
</path>
<!-- set the operating system test properties -->
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isLinux">
<and>
<os family="unix" />
<not>
<os family="mac"/>
</not>
</and>
</condition>
<target name="all" depends="clean,weave,jar,preloaded_files" />
<target name="all_with_test" depends="all,weavetest" />
<target name="test" depends="all_with_test,testwoven,perf_test" />
<target name="gen-interpreter">
<echo message="generating interpreter code ===================" />
<exec dir="src/main/java/erjang/beam/interpreter"
executable="perl"
input="src/main/java/erjang/beam/interpreter/ops.spec" failonerror="yes">
<arg value="-W"/>
<arg value="ErjIG_Main.pl"/>
</exec>
</target>
<target name="create-dirs">
<mkdir dir="target" />
<mkdir dir="target/classes" />
<mkdir dir="target/test-classes" />
<mkdir dir="target/test-beam" />
<mkdir dir="target/compiled" />
</target>
<target name="untar_mini_release">
<untar src="erl-r16b01-mini.tgz2" dest="." compression="bzip2" overwrite="false" />
</target>
<target name="gen-test-classes" description="generate test classes based on a generic one" depends="create-dirs,ensure_otp">
<echo message="generating test classes ===================" />
<java classname="erjang.AllTests"
failonerror="true"
fork="true">
<jvmarg value="-Derjang.otp.root=${erjang.otp.root}" />
<arg value="src/test/java/erjang/"/>
<classpath>
<pathelement location="target/test-classes" />
</classpath>
<classpath refid="erjang.classpath" />
</java>
</target>
<target name="compile" depends="gen-interpreter,create-dirs">
<echo message="Compiling src ===================" />
<javac includeantruntime="false" debug="true" srcdir="src/main/java" destdir="target/classes" classpathref="erjang.classpath" deprecation="off" debuglevel="lines,vars,source" target="1.7" source="1.7" fork="true">
<compilerarg value="-XDignore.symbol.file"/>
</javac>
</target>
<target name="testcompile" depends="compile">
<echo message="Compiling test ===================" />
<javac includeantruntime="false" debug="true" srcdir="src/test/java" destdir="target/test-classes" debuglevel="lines,vars,source" target="1.7" source="1.7">
<classpath>
<pathelement location="target/test-classes" />
</classpath>
<classpath refid="erjang.classpath" />
</javac>
</target>
<target name="gen-test-compile" depends="testcompile,gen-test-classes">
<echo message="Compiling generated test classes ===================" />
<javac includeantruntime="false" debug="true" srcdir="src/test/java" destdir="target/test-classes" debuglevel="lines,vars,source" target="1.7" source="1.7">
<classpath>
<pathelement location="target/test-classes" />
</classpath>
<classpath refid="erjang.classpath" />
</javac>
</target>
<target name="weave" depends="compile">
<echo message="Weaving files ===================" />
<java classname="kilim.tools.Weaver" fork="yes">
<classpath refid="erjang.classpath" />
<assertions>
<enable />
</assertions>
<jvmarg value="-Dkilim.optimize_codesize=true" />
<arg value="-q" />
<arg value="-d" />
<arg value="./target/classes" />
<arg line="./target/classes" />
</java>
</target>
<target name="weavetest" depends="gen-test-compile">
<echo message="Weaving test classes ==============" />
<java classname="kilim.tools.Weaver" fork="yes">
<classpath refid="erjang.classpath" />
<assertions>
<enable />
</assertions>
<jvmarg value="-Dkilim.optimize_codesize=true" />
<arg value="-q" />
<arg value="-d" />
<arg value="./target/test-classes" />
<arg line="./target/test-classes" />
</java>
</target>
<target name="clean">
<echo message="deleting files ===================" />
<delete>
<fileset defaultexcludes="no" dir="." includes="*~,#*,foo,bar,x,y" />
</delete>
<delete dir="./target" />
<delete dir="./.erj" />
<delete>
<fileset dir="src/test/java/erjang" includes="**/*_TEST.java" />
</delete>
</target>
<!-- This runs those tests depend on generated classes in testclasses-->
<target name="testwoven" depends="weavetest,ensure_otp,justtestwoven"/>
<target name="justtestwoven" depends="weavetest,ensure_otp">
<echo message="Testing Tasks ======================" />
<mkdir dir="test-outputs" />
<junit fork="yes" showoutput="yes" printsummary="true">
<formatter type="brief" usefile="false" />
<formatter type="xml"/> <!-- For CI server use. -->
<!-- <formatter type="brief" usefile="false"/> -->
<classpath>
<pathelement location="target/test-classes" />
<pathelement location="target/test-classes/generated/classes" />
</classpath>
<classpath refid="erjang.classpath" />
<assertions><enable /></assertions>
<env key="OTPROOT" file="${erjang.otp.root}"/>
<jvmarg value="-Xmx700m"/>
<jvmarg value="-Xss50m"/>
<jvmarg value="-XX:PermSize=128m"/>
<jvmarg value="-XX:MaxPermSize=700m"/>
<jvmarg value="-Dkilim.optimize_codesize=true" />
<jvmarg value="-Derjang.otp.root=${erjang.otp.root}"/>
<jvmarg value="-Derjang.triq.root=${erjang.triq.root}"/>
<batchtest todir="test-outputs">
<fileset dir="target/test-classes" includes="**/*_TEST.class">
<exclude name="**/arith_tests_erl_TEST.class" />
<exclude name="**/arith_guard_tests_erl_TEST.class" />
<exclude name="**/utf_tests_erl_TEST.class" />
<exclude name="**/ets_test_erl_TEST.class" />
<exclude name="**/erjang_test_erl_TEST.class" />
</fileset>
<!-- <fileset dir="target/test-classes" includes="**/float_tests_erl_TEST.class" />-->
</batchtest>
</junit>
</target>
<target name="arch_linux" if="isLinux">
<property name="otp_arch" value="x86_64-unknown-linux-gnu" />
</target>
<target name="arch_macos" if="isMac">
<property name="otp_arch" value="x86_64-apple-darwin12.4.0" />
</target>
<target name="arch" depends="arch_linux,arch_macos" />
<target name="test_otp">
<available property="has_otp" value="true"
file="${erjang.otp.root}"
type="dir" />
<available property="otp_downloaded"
file="otp_r16b01.tgz"
type="file" />
<property name="erjang.triq.root" value="${basedir}/triq" />
</target>
<target name="download_otp_unix" if="isLinux" depends="test_otp" unless="otp_downloaded">
<echo message="Downloading Erlang/OTP for Linux..."/>
<exec dir="." executable="curl">
<arg value="-s"/>
<arg value="-o"/>
<arg value="otp_r16b01.tgz"/>
<arg value="https://dl.dropboxusercontent.com/u/1360473/otp_r16b01_linux.tgz"/>
</exec>
</target>
<target name="download_otp_macos" if="isMac" depends="test_otp" unless="otp_downloaded">
<echo message="Downloading Erlang/OTP for MacOS X..."/>
<exec dir="." executable="curl">
<arg value="-s"/>
<arg value="-o"/>
<arg value="otp_r16b01.tgz"/>
<arg value="https://dl.dropboxusercontent.com/u/1360473/otp_r16b01_macos.tgz"/>
</exec>
</target>
<target name="ensure_otp"
depends="test_otp,arch,download_otp_unix,download_otp_macos"
unless="has_otp">
<exec dir="." executable="tar">
<arg value="xzpf" />
<arg value="otp_r16b01.tgz" />
</exec>
<property name="erjang.otp.root" value="${basedir}/${otp_arch}" />
<exec dir="." executable="${erjang.otp.root}/Install">
<arg value="-minimal" />
<arg value="${erjang.otp.root}" />
</exec>
<echo message="Did install erlang in ${erjang.otp.root}" />
</target>
<target name="get_otp_version" depends="ensure_otp">
<exec outputproperty="erjang.otp.version"
dir="."
executable="${erjang.otp.root}/bin/erl">
<arg value="-noshell"/>
<arg value="-eval"/>
<arg value='io:format("~s", [erlang:system_info(otp_release)]), erlang:halt().'/>
</exec>
<echo message="Erlang version is ${erjang.otp.version}" />
</target>
<target name="preloaded_files" depends="ensure_otp">
<description>Place bootstrap files by erjangify-release.sh</description>
<copy todir="bootstrap" flatten="yes">
<fileset dir="${erjang.otp.root}/lib"
includes="erts-*/ebin/**/*.beam"/>
<!-- <dirset dir="${erjang.otp.root}/lib"> -->
<!-- <include name="erts-*/ebin"/> -->
<!-- <includesfile name="*.beam"/> -->
<!-- </dirset> -->
</copy>
</target>
<target name="perf_test" depends="estone_test,boot_stat_test"/>
<target name="estone_test" depends="ensure_otp">
<echo message="running estone with root=${erjang.otp.root}" />
<exec dir="." executable="bash" failonerror="no">
<arg value="src/test/shell/run-estone.sh"/>
<arg value="test-outputs/estone"/>
<env key="OTPROOT" file="${erjang.otp.root}"/>
</exec>
</target>
<target name="boot_stat_test">
<exec dir="." executable="bash" failonerror="no">
<arg value="src/test/shell/run-boot.sh"/>
<arg value="test-outputs/boot-stats"/>
<env key="OTPROOT" file="${erjang.otp.root}"/>
</exec>
</target>
<target name="jar" description="generate the distribution" depends="clean,weave">
<echo message="Packaging ======================" />
<copy file="LICENSE" todir="classes/erjang" />
<copy file="NOTICE" todir="classes/erjang" />
<copy file="erjang_logo4.png" todir="classes/erjang" />
<jar jarfile="erjang-${erjang.version}.jar" basedir="target/classes">
<zipgroupfileset dir="lib" includes="*.jar">
<exclude name="junit.jar" />
</zipgroupfileset>
<exclude name="erjang/test/**" />
<exclude name="erjang/examples/**" />
<exclude name="erjang/bench/**" />
<manifest>
<attribute name="Main-Class" value="erjang.Main" />
</manifest>
</jar>
</target>
<target name="otpjar" depends="get_otp_version">
<jar jarfile="otp-${erjang.otp.version}.jar" basedir="${erjang.otp.root}">
<exclude name="**/*.so" />
<exclude name="**/*.dll" />
<exclude name="**/*.a" />
<exclude name="**/*.erl" />
<exclude name="**/bin/beam" />
<exclude name="**/bin/beam.smp" />
<exclude name="lib/megaco-*/**" />
<exclude name="lib/wx-*/**" />
<exclude name="lib/hipe-*/**" />
<exclude name="lib/jinterface-*/**" />
<exclude name="lib/erl_interface-*/**" />
<exclude name="lib/ic-*/java_src/**" />
<exclude name="usr/include/**" />
<exclude name="**/examples/**" />
</jar>
</target>
<target name="alljar" depends="jar,otpjar">
<jar jarfile="erjang-${erjang.otp.version}.jar" basedir="${erjang.otp.root}">
<!-- include all of erjang -->
<zipgroupfileset dir="." includes="erjang-${erjang.version}.jar" />
<!-- include all of OTP -->
<zipgroupfileset dir="." includes="otp-${erjang.otp.version}.jar" />
<manifest>
<attribute name="Main-Class" value="erjang.Main" />
</manifest>
</jar>
</target>
<target name="javadoc" description="generate Javadoc documentation">
<javadoc destdir="target/doc">
<fileset dir="src"><include name="**/*.java"/></fileset>
</javadoc>
</target>
</project>