-
Notifications
You must be signed in to change notification settings - Fork 56
/
build.xml
executable file
·475 lines (428 loc) · 17.7 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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<!-- build.xml
ant build file for EduMIPS64.
(c) 2006-2013 Andrea Spadaccini and the EduMIPS64 dev team.
Useful targets:
- slim-jar builds the GUI version, with no javahelp libraries.
- standalone-jar builds the GUI version, with embedded javahelp libraries.
- clean removes the jar file and the build dir
- docs builds the HTML and PDF docs, both in english and in
italian
The output file names are in the init target.
-->
<project name="edumips64" default="slim-jar" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<!-- Task definition for JaCoCo, the Java Coverage library -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="libs/asm-5.0.3.jar" />
<classpath path="libs/asm-commons-5.0.3.jar" />
<classpath path="libs/asm-tree-5.0.3.jar" />
<classpath path="libs/asm-util-5.0.3.jar" />
<classpath path="libs/org.jacoco.ant-0.7.7.201606060606.jar" />
<classpath path="libs/org.jacoco.core-0.7.7.201606060606.jar" />
<classpath path="libs/org.jacoco.report-0.7.7.201606060606.jar" />
<classpath path="libs/org.jacoco.agent-0.7.7.201606060606.jar" />
</taskdef>
<target name="init">
<!-- Meta info about the simulator -->
<property name="version" value="1.2.3" />
<property name="codename" value="Angelo" />
<!-- Set build file properties -->
<property name="sourceDir" value="src/main/java/org/edumips64/" />
<property name="webDir" value="src/main/java/org/edumips64/client/" />
<property name="testDir" value="src/test/java/org/edumips64/" />
<property name="testResourcesDir" value="build/resources/test" />
<property name="outputDir" value="build" />
<property name="webOutputDir" value="war/" />
<property name="javadocDir" value="javadoc" />
<property name="reportDir" value="report" />
<property name="gwtVersion" value="2.8.0-rc1" />
<!-- Access the environment -->
<property environment="env" />
<property name="base.classpath" value="libs/javahelp-2.0.05.jar:libs/junit-4.10.jar:libs/hamcrest-core-1.3.jar:${env.CLASSPATH}" />
<!-- File names -->
<property name="standalone_jar_filename" value="edumips64-${version}.jar" />
<property name="slim_jar_filename" value="edumips64-${version}-nodeps.jar" />
<property name="cli_jar_filename" value="edumips64-${version}-cli.jar" />
<property name="latest_jar_filename" value="edumips64-latest.jar" />
<property name="tarbz2File" value="edumips64-${version}.tar.bz2" />
<!-- Docs directories -->
<property name="docs_src_it" value="docs/user/it/src" />
<property name="docs_src_en" value="docs/user/en/src" />
<!-- Compilation options -->
<property name="src_java_version" value="8" />
<property name="dst_java_version" value="8" />
<property name="debug" value="on" />
<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />
<property name="gwt.sdk" location="libs" />
<path id="project.class.path">
<fileset dir="libs" includes="**/*.jar"/>
<pathelement location="war/WEB-INF/classes"/>
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
</path>
</target>
<target name="webLibs" depends="init" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-${gwtVersion}.jar" />
<!-- Add any additional server libs that need to be copied -->
</target>
<target name="compileWeb" depends="webLibs" description="Compile java source to bytecode">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src/main/java" includes="**" encoding="utf-8"
includeantruntime="false"
destdir="war/WEB-INF/classes"
source="${src_java_version}" target="${dst_java_version}" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src/main/java" excludes="**/*.java"/>
</copy>
<copy todir="war/">
<fileset dir="utils">
<include name="edumips64.html" />
</fileset>
</copy>
</target>
<target name="mkdirs" depends="init">
<!-- Create directories for the compilation process. -->
<mkdir dir="${outputDir}" />
</target>
<!-- like gwtc, but with only one worker. Works on Cloud9 due to reduced memory demand -->
<target name="gwtc-lowmem" depends="compileWeb" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="2g">
<classpath>
<pathelement location="src/main/java"/>
<path refid="project.class.path"/>
</classpath>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.edumips64.webclient"/>
<arg line="-strict"/>
<arg line="-generateJsInteropExports"/>
<arg line="-localWorkers"/>
<arg value="1"/>
</java>
</target>
<target name="gwtc" depends="compileWeb" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="2g">
<classpath>
<pathelement location="src/main/java"/>
<path refid="project.class.path"/>
</classpath>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.edumips64.webclient"/>
<arg line="-strict"/>
<arg line="-generateJsInteropExports"/>
</java>
</target>
<target name="devmode" depends="compileWeb" description="Run development mode (pass -Dgwt.args=-nosuperDevMode to fallback to classic DevMode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode" maxmemory="1g">
<classpath>
<pathelement location="src/main/java"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/gwt-codeserver.jar"/>
</classpath>
<arg line="-generateJsInteropExports"/>
<arg value="-startupUrl"/>
<arg value="edumips64.html"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY, -logLevel DEBUG or -nosuperDevMode -->
<arg line="${gwt.args}"/>
<arg value="org.edumips64.webclient"/>
</java>
</target>
<!-- *** clean *** target that cleans the built files and the build directory-->
<target name="clean" depends="init,cleandocs">
<delete file="${standalone_jar_filename}" />
<delete file="${tarbz2File}" />
<delete file="${slim_jar_filename}" />
<delete file="${cli_jar_filename}" />
<delete dir="${outputDir}" />
<delete dir="${javadocDir}" />
<delete dir="${webOutputDir}" />
<delete dir="${reportDir}" />
</target>
<target name="cleandocs" depends="init">
<delete dir="${docs_src_it}/../output" />
<delete dir="${docs_src_en}/../output" />
<delete file="edumips64-${version}-manual-en.pdf" />
<delete file="edumips64-${version}-manual-it.pdf" />
</target>
<!-- *** javadoc *** build the javadoc -->
<target name="javadoc" depends="init">
<mkdir dir="${javadocDir}" />
<javadoc
destdir="${javadocDir}"
author="true"
version="true"
use="true"
additionalparam=" -encoding ISO-8859-1"
sourcepath="${sourceDir}/../../"
classpath="${base.classpath}:${base.classpath}"
packagenames="org.edumips64.*"/>
</target>
<!-- *** docs *** builds all the docs (html, pdf in both languages) -->
<target name="docs" depends="htmldoc,pdfdoc" />
<!-- miscellaneous docs targets -->
<target name="htmldoc" depends="html_it,html_en" />
<target name="pdfdoc" depends="pdf_it,pdf_en" />
<target name="docs_it" depends="html_it,pdf_it" />
<target name="docs_en" depends="html_en,pdf_en" />
<target name="html_it" depends="init">
<exec executable="make" failonerror="true" dir="${docs_src_it}">
<arg line="html"/>
</exec>
</target>
<target name="html_en" depends="init">
<exec executable="make" failonerror="true" dir="${docs_src_en}">
<arg line="html"/>
</exec>
</target>
<target name="pdf_it" depends="init">
<exec executable="make" failonerror="true" dir="${docs_src_it}">
<arg line="latexpdf"/>
</exec>
<copy file="docs/user/it/output/latex/EduMIPS64.pdf" tofile="edumips64-${version}-manual-it.pdf"/>
</target>
<target name="pdf_en" depends="init">
<exec executable="make" failonerror="true" dir="${docs_src_en}">
<arg line="latexpdf"/>
</exec>
<copy file="docs/user/en/output/latex/EduMIPS64.pdf" tofile="edumips64-${version}-manual-en.pdf"/>
</target>
<!-- *** compile *** compiles the code -->
<target name="compile" depends="mkdirs">
<javac
source="${src_java_version}"
target="${dst_java_version}"
srcdir="${sourceDir}"
destdir="${outputDir}"
debug="${debug}"
debuglevel="lines,vars,source"
excludes="client/**"
includeantruntime="false"
classpath="${base.classpath}">
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
</javac>
</target>
<!-- *** test *** run unit tests-->
<target name="test" depends="mkdirs,compile">
<!-- prepare resources for the tests -->
<copy todir="${testResourcesDir}">
<fileset dir="src/test/resources/">
<include name="**/*.*" />
</fileset>
</copy>
<!-- cannot use the compile target since we'll need to compile test code
as well. -->
<javac
source="${src_java_version}"
target="${dst_java_version}"
srcdir="${testDir}"
destdir="${outputDir}"
debug="${debug}"
includeantruntime="false"
classpath="${base.classpath}"
debuglevel="lines,vars,source">
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
</javac>
<jacoco:coverage>
<junit printsummary="true" haltonfailure="yes" haltonerror="yes" fork="true">
<classpath>
<pathelement path="${base.classpath}"/>
<pathelement path="${outputDir}"/>
</classpath>
<test name="org.edumips64.core.CPUTest">
<formatter type="plain" usefile="false"/>
</test>
<test name="org.edumips64.EndToEndTests">
<formatter type="plain" usefile="false"/>
</test>
<test name="org.edumips64.core.FixedBitSetTest">
<formatter type="plain" usefile="false"/>
</test>
<test name="org.edumips64.core.ParserTest">
<formatter type="plain" usefile="false"/>
</test>
<test name="org.edumips64.core.MemoryTest">
<formatter type="plain" usefile="false"/>
</test>
<test name="org.edumips64.core.fpu.FPInstructionUtilsTest">
<formatter type="plain" usefile="false"/>
</test>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="jacoco.exec" />
</executiondata>
<structure name="EduMIPS64 (excluding Swing UI)">
<classfiles>
<fileset dir="build/">
<exclude name="org/edumips64/ui/swing/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="utf8">
<fileset dir="src/main/java/">
<exclude name="org/edumips64/ui/swing/*.java" />
</fileset>
</sourcefiles>
</structure>
<html destdir="${reportDir}"/>
<xml destfile="${reportDir}/report.xml"/>
</jacoco:report>
<delete dir="${outputDir}" />
<delete file="jacoco.exec" />
</target>
<!-- *** standalone-jar *** compile with embedded javahelp -->
<target name="standalone-jar" depends="compile,htmldoc">
<property name="jar_filename" value="${standalone_jar_filename}" />
<property name="main_class" value="org.edumips64.Main" />
<property name="splash_img" value="org/edumips64/img/splash.png"/>
<antcall target="copy-base-files" />
<antcall target="copy-help-files" />
<antcall target="copy-help-libs" />
<antcall target="make-jarfile" />
</target>
<!-- *** latest-jar *** like standalone-jar, but with a version-independent filename -->
<target name="latest-jar" depends="compile,htmldoc">
<property name="jar_filename" value="${latest_jar_filename}" />
<property name="main_class" value="org.edumips64.Main" />
<property name="splash_img" value="org/edumips64/img/splash.png"/>
<antcall target="copy-base-files" />
<antcall target="copy-help-files" />
<antcall target="copy-help-libs" />
<antcall target="make-jarfile" />
</target>
<!-- *** slim-jar *** compile without javahelp. -->
<target name="slim-jar" depends="compile">
<property name="jar_filename" value="${slim_jar_filename}" />
<property name="main_class" value="org.edumips64.Main" />
<property name="splash_img" value="org/edumips64/img/splash.png"/>
<antcall target="make-jarfile" />
</target>
<!-- *** cli-jar *** runs org.edumips64.MainCLI -->
<target name="cli-jar" depends="compile">
<property name="jar_filename" value="${cli_jar_filename}" />
<property name="main_class" value="org.edumips64.MainCLI" />
<antcall target="make-jarfile" />
</target>
<target name="make-jarfile" depends="git.revision">
<tstamp/>
<antcall target="copy-base-files" />
<jar destfile="${jar_filename}" basedir="${outputDir}">
<manifest>
<attribute name="Main-Class" value="${main_class}"/>
<attribute name="SplashScreen-Image" value="${splash_img}"/>
<attribute name="Signature-Version" value="${version}"/>
<attribute name="Build-Date" value="${TODAY}"/>
<attribute name="Codename" value="${codename}"/>
<attribute name="Git-Revision" value="${git.revision}"/>
</manifest>
</jar>
<delete dir="${outputDir}" />
<signjar jar="${jar_filename}" keystore="utils/key-edumips" storepass="123456" keypass="123456" alias="edumips64" />
</target>
<!-- Utility targets to copy files. -->
<target name="copy-help-files">
<copy todir="${outputDir}/org/edumips64/help/en/html">
<fileset dir="docs/user/en/output/html">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/help/en">
<fileset dir="docs/user/en/javahelp">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/help/it/html">
<fileset dir="docs/user/it/output/html">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/help/it/img">
<fileset dir="docs/user/img">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/help/en/img">
<fileset dir="docs/user/img">
<include name="**/*.*" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/help/it">
<fileset dir="docs/user/it/javahelp">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="copy-base-files">
<copy todir="${outputDir}/org/edumips64/img">
<fileset dir="${sourceDir}/img">
<include name="**/*.png" />
</fileset>
</copy>
<copy todir="${outputDir}/org/edumips64/utils">
<fileset dir="${sourceDir}/utils">
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="copy-help-libs">
<property name="libsDir" value="${outputDir}/tmp_libs/" />
<unzip src="libs/javahelp-2.0.05.jar" dest="${libsDir}" />
<copy todir="${outputDir}/com">
<fileset dir="${libsDir}/com">
<include name="**/*.class" />
</fileset>
</copy>
<copy todir="${outputDir}/javax">
<fileset dir="${libsDir}/javax">
<include name="**/*.class" />
</fileset>
</copy>
<delete dir="${libsDir}" />
</target>
<!-- Source release -->
<target name="src-release" depends="clean,init">
<mkdir dir="edumips64-${version}" />
<copy todir="edumips64-${version}/">
<fileset dir=".">
<include name="authors" />
<include name="build.xml" />
<include name="ChangeLog" />
<include name="LICENSE" />
<include name="readme.md" />
<include name="RELEASE_NOTES" />
<include name="docs/**/*" />
<include name="src/**/*" />
<include name="utils/**/*" />
</fileset>
</copy>
<tar destfile="${tarbz2File}" basedir="." includes="edumips64-${version}/" compression="bzip2" />
<delete dir="edumips64-${version}" />
</target>
<!-- Fetch git commit ID (adapted from http://stackoverflow.com/a/4059546/193852) -->
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
</project>