This repository has been archived by the owner on Mar 22, 2019. It is now read-only.
forked from smarr/SOMns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
379 lines (331 loc) · 15.2 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
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
<project name="som" basedir="." default="compile-all"
xmlns:unless="ant:unless"
xmlns:if="ant:if"
xmlns:jacoco="antlib:org.jacoco.ant">
<property name="src.dir" value="src"/>
<property name="src_gen.dir" value="src_gen"/>
<property name="lib.dir" location="libs" />
<property name="bd.dir" location="${lib.dir}/black-diamonds/" />
<property name="unit.dir" value="tests/java" />
<property name="kompos.dir" value="tools/kompos" />
<property name="graal.dir" location="${lib.dir}/truffle/compiler" />
<property name="truffle.dir" location="${lib.dir}/truffle/truffle" />
<property name="sdk.dir" location="${lib.dir}/truffle/sdk" />
<property name="sdk.build" location="${sdk.dir}/mxbuild/dists" />
<property name="truffle.build" location="${truffle.dir}/mxbuild/dists" />
<property name="somns-deps.version" value="0.3.3" />
<property name="checkstyle.version" value="8.8" />
<property name="jacoco.version" value="0.8.0" />
<!-- <property name="lib.url" value="https://dl.bintray.com/smarr/SOM" /> -->
<property name="lib.url" value="http://stefan-marr.de/dev" />
<property name="mx.cmd" value="../../mx/mx" />
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property environment="env"/>
<path id="project.classpath">
<pathelement location="${classes.dir}" />
<pathelement location="${unit.dir}" />
<pathelement location="${bd.dir}/build/classes" />
<pathelement location="${sdk.build}/graal-sdk.jar" />
<pathelement location="${sdk.build}/word-api.jar" />
<pathelement location="${lib.dir}/somns-deps-dev.jar" />
<pathelement location="${lib.dir}/somns-deps.jar" />
<pathelement location="${truffle.build}/truffle-api.jar" />
<pathelement location="${truffle.build}/truffle-debug.jar" />
<pathelement location="${truffle.build}/truffle-dsl-processor.jar" />
<pathelement location="${truffle.build}/truffle-tck.jar" />
</path>
<condition property="is.atLeastJava9" value="true" else="false">
<or>
<matches string="${java.version}" pattern="^9"/>
<matches string="${java.version}" pattern="^1[0-9]"/>
</or>
</condition>
<echo>
ant.java.version: ${ant.java.version}
java.version: ${java.version}
is.atLeastJava9: ${is.atLeastJava9}
</echo>
<target name="clean" description="Remove build directories and generated code">
<delete dir="${build.dir}"/>
<delete dir="${src_gen.dir}"/>
</target>
<target name="clean-truffle" depends="check-truffle-available" if="truffle.present">
<exec executable="${mx.cmd}" dir="${truffle.dir}">
<arg value="clean"/>
</exec>
</target>
<target name="clobber" description="Do clean, and also clean truffle build" depends="clean,clean-truffle">
<delete dir="${kompos.dir}/out"/>
<delete dir="${kompos.dir}/node_modules"/>
<ant dir="${bd.dir}" useNativeBasedir="true" target="clean" inheritAll="false"/>
</target>
<target name="check-truffle-available">
<available file="${lib.dir}/truffle/.git" property="truffle.present"/>
</target>
<target name="truffle" depends="check-truffle-available"
unless="truffle.present">
<exec executable="./.gitloadmodules" failonerror="true">
</exec>
</target>
<target name="truffle-libs" unless="skip.libs" depends="truffle,build-graal">
<exec executable="${mx.cmd}" dir="${truffle.dir}" failonerror="true">
<arg value="build"/>
<arg value="--no-native"/>
</exec>
</target>
<target name="build-graal" description="Build the embedded Graal" unless="skip.graal">
<echo unless:true="${is.atLeastJava9}" level="warning">
The used JDK needs to have JVMCI support, which is the case for Java 9.
If Java 8 is needed, see
http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html
for a JVMCI JDK Download.
</echo>
<exec executable="${mx.cmd}" dir="${graal.dir}" failonerror="true">
<arg value="build" />
<arg value="--no-native" />
</exec>
</target>
<target name="bd-libs"> <!-- implicit dependency on truffle-libs -->
<ant dir="${bd.dir}" useNativeBasedir="true" target="libs-junit" inheritAll="false">
<property name="force.java8" value="${is.atLeastJava9}" />
</ant>
<ant dir="${bd.dir}" useNativeBasedir="true" target="compile-nodeps" inheritAll="false">
<property name="sdk.build" value="${sdk.build}" />
<property name="truffle.dir" value="${truffle.dir}" />
<property name="truffle.build" value="${truffle.build}" />
<property name="force.java8" value="${is.atLeastJava9}" />
</ant>
</target>
<target name="ideinit" depends="source">
<exec executable="${mx.cmd}" dir="${truffle.dir}" failonerror="true">
<arg value="eclipseinit"/>
</exec>
<exec executable="${mx.cmd}" dir="${sdk.dir}" failonerror="true">
<arg value="eclipseinit"/>
</exec>
</target>
<target name="libs" depends="truffle-libs,bd-libs" unless="skip.libs">
<get src="${lib.url}/somns-deps-${somns-deps.version}.jar"
usetimestamp="true"
dest="${lib.dir}/somns-deps.jar" />
<get src="${lib.url}/somns-deps-dev-${somns-deps.version}.jar"
usetimestamp="true"
dest="${lib.dir}/somns-deps-dev.jar" />
</target>
<target name="source" description="Download Source Jars for development">
<get src="${lib.url}/somns-deps-source-${somns-deps.version}.jar"
usetimestamp="true"
dest="${lib.dir}/somns-deps-source.jar" />
</target>
<target name="eclipseformat">
<pathconvert pathsep=" " property="javafiles">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${unit.dir}">
<include name="**/*.java"/>
</fileset>
</pathconvert>
<exec executable="${env.ECLIPSE_EXE}" dir="${basedir}">
<arg value="-nosplash"/>
<arg value="-application"/>
<arg value="-consolelog"/>
<arg value="-data"/>
<arg value="${basedir}"/>
<arg value="-vm"/>
<arg value="${env.JAVA_HOME}/bin/java"/>
<arg value="org.eclipse.jdt.core.JavaCodeFormatter"/>
<arg value="-config"/>
<arg value="${basedir}/.settings/org.eclipse.jdt.core.prefs"/>
<arg line="${javafiles}"/>
</exec>
</target>
<target name="eclipseformat-check" depends="eclipseformat">
<exec executable="git" dir="${basedir}">
<arg value="status" />
<arg value="*.java" />
</exec>
<exec executable="git" dir="${basedir}" failonerror="true">
<arg value="diff-index" />
<arg value="--quiet" />
<arg value="--exit-code" />
<arg value="--ignore-submodules" />
<arg value="HEAD" />
</exec>
</target>
<target name="checkstyle-jar">
<get src="http://tenet.dl.sourceforge.net/project/checkstyle/checkstyle/${checkstyle.version}/checkstyle-${checkstyle.version}-all.jar"
usetimestamp="true"
dest="${lib.dir}/checkstyle-${checkstyle.version}-all.jar" />
</target>
<target name="checkstyle" depends="checkstyle-jar" description="Check Code with Checkstyle">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpath="${lib.dir}/checkstyle-${checkstyle.version}-all.jar" />
<checkstyle config=".checkstyle_checks.xml">
<fileset dir="src" includes="**/*.java"/>
<formatter type="plain"/>
</checkstyle>
</target>
<target name="jacoco-lib" description="Get JaCoCo dependency">
<get src="http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/${jacoco.version}/jacoco-${jacoco.version}.zip"
usetimestamp="true"
dest="${lib.dir}/jacoco-${jacoco.version}.zip" />
<unzip src="${lib.dir}/jacoco-${jacoco.version}.zip" dest="${lib.dir}/jacoco"/>
<taskdef uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml"
classpath="${lib.dir}/jacoco/lib/jacocoant.jar" />
</target>
<target name="codacy-coverage-lib" description="Report Coverage to Codacy">
<get src="https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/2.0.2/codacy-coverage-reporter-2.0.2-assembly.jar"
usetimestamp="true"
dest="${lib.dir}/codacy-coverage-reporter.jar" />
</target>
<target name="java8-on-java9" description="Support Java 9 or later" if="${is.atLeastJava9}">
<mkdir dir="${classes.dir}" />
<javac includeantruntime="false" srcdir="${lib.dir}/java8" destdir="${classes.dir}" debug="true">
<compilerarg line="--release 8" />
</javac>
</target>
<target name="compile-som" description="Compile SOMns" depends="java8-on-java9">
<mkdir dir="${build.dir}"/>
<mkdir dir="${classes.dir}" />
<mkdir dir="${src_gen.dir}" />
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
<classpath refid="project.classpath" />
<compilerarg line="-s ${src_gen.dir}" />
<compilerarg line="-XDignore.symbol.file" />
<compilerarg line="-Xlint:all" />
<compilerarg line="--release 8" if:true="${is.atLeastJava9}" />
</javac>
<javac includeantruntime="false" srcdir="${src_gen.dir}" destdir="${classes.dir}" debug="true">
<classpath refid="project.classpath" />
<compilerarg line="-s ${src_gen.dir}" />
<compilerarg line="-Xlint:all" />
<compilerarg line="--release 8" if:true="${is.atLeastJava9}" />
</javac>
<javac includeantruntime="false" srcdir="${unit.dir}" destdir="${classes.dir}" debug="true">
<classpath refid="project.classpath" />
<compilerarg line="--release 8" if:true="${is.atLeastJava9}" />
</javac>
</target>
<target name="compile" depends="libs,compile-som" description="Compile SOMns and dependencies">
</target>
<target name="kompos" description="Build Kompos">
<exec executable="npm" dir="${kompos.dir}" failonerror="true">
<arg value="--quiet"/>
<arg value="install"/>
</exec>
</target>
<target name="compile-all" depends="compile,kompos" description="Build SOMns and Kompos">
</target>
<target name="jar" depends="compile" description="Package as JAR">
<jar destfile="${build.dir}/som.jar" basedir="${classes.dir}"></jar>
</target>
<target name="unit-tests" depends="compile,jacoco-lib" description="Execute tests">
<jacoco:coverage>
<junit haltonerror="false" haltonfailure="false" failureproperty="test.failed"
outputtoformatters="true" fork="true" forkmode="once">
<jvmarg value="-ea" />
<jvmarg value="-esa" />
<classpath refid="project.classpath" />
<batchtest fork="yes" filtertrace="false">
<fileset dir="${unit.dir}">
<include name="**/*Test*.java"/>
<include name="**/*TCK.java"/>
</fileset>
</batchtest>
<formatter type="brief" usefile="false"/>
</junit>
</jacoco:coverage>
<jacoco:coverage>
<java classname="som.VM" fork="true" failonerror="true">
<classpath refid="project.classpath" />
<jvmarg value="-ea" />
<jvmarg value="-esa" />
<arg line="core-lib/TestSuite/TestRunner.ns" />
</java>
</jacoco:coverage>
<fail message="Basic tests failed." if="test.failed" />
</target>
<target name="som-tests" depends="compile">
<!-- delete old coverage data, this should be the first task generating coverage data -->
<delete file="all.gcov" />
<exec executable="./som" failonerror="true">
<arg value="--coverage" />
<arg value="all.gcov" />
<arg value="--java-coverage" />
<arg value="jacoco.exec" />
<arg value="-G" />
<arg value="core-lib/TestSuite/TestRunner.ns" />
</exec>
<exec executable="./som" failonerror="true">
<arg value="-X" />
<arg value="core-lib/TestSuite/TestRunner.ns" />
</exec>
</target>
<target name="dynamic-metrics-tests" depends="compile-som">
<exec executable="tests/dym/test.sh" failonerror="true">
<arg value="--coverage" />
</exec>
</target>
<target name="superinstructions-tests" depends="compile-som">
<exec executable="tests/superinstructions/test.sh" failonerror="true"></exec>
</target>
<target name="update-test-data" depends="compile-som" description="Updates the test data for DynamicMetrics and SuperInstructions">
<exec executable="tests/dym/test.sh" failonerror="true">
<arg value="update" />
</exec>
<exec executable="tests/superinstructions/test.sh" failonerror="true">
<arg value="update" />
</exec>
</target>
<target name="replay-tests" depends="compile">
<exec executable="tests/replay/test.sh" failonerror="true">
<arg value="1" />
</exec>
<exec executable="tests/replay/test.sh" failonerror="true">
<arg value="2" />
</exec>
</target>
<target name="core-tests" depends="unit-tests,som-tests,dynamic-metrics-tests,superinstructions-tests">
</target>
<target name="send-java-coverage" depends="jacoco-lib,codacy-coverage-lib">
<jacoco:report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="SOMns coverage">
<classfiles>
<fileset dir="${classes.dir}"/>
<fileset dir="${bd.dir}/build/classes"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src"/>
<fileset dir="${bd.dir}/src"/>
</sourcefiles>
</structure>
<!-- <html destdir="report"/> -->
<xml destfile="jacoco.xml"/>
</jacoco:report>
<java classname="com.codacy.CodacyCoverageReporter">
<classpath>
<pathelement location="${lib.dir}/codacy-coverage-reporter.jar" />
</classpath>
<arg value="-l" />
<arg value="Java" />
<arg value="-r" />
<arg value="jacoco.xml" />
</java>
</target>
<target name="send-somns-coverage">
<!-- submit coverage data -->
<java classname="coveralls.Report" fork="true" failonerror="true">
<classpath refid="project.classpath" />
<arg value="${env.COVERALLS_REPO_TOKEN}" />
<arg value="all.gcov" />
</java>
</target>
<target name="coverage" depends="send-java-coverage,send-somns-coverage" />
<target name="tests" depends="core-tests,replay-tests,coverage">
</target>
</project>