forked from RomRaider/RomRaider
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
431 lines (385 loc) · 21.5 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
<?xml version="1.0"?>
<!-- Master build file for RomRaider
RomRaider Open-Source Tuning, Logging and Reflashing
Copyright (C) 2006-2022 RomRaider.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<project name="romraider" default="help" basedir=".">
<!-- get the environment -->
<property environment="env" />
<!-- =================================================================== -->
<!-- Help -->
<!-- All externally callable targets should be listed here, along -->
<!-- with common property overrides -->
<!-- =================================================================== -->
<target name="help" depends="-init">
<echo message="help [Print this message ]" />
<echo message="clean [Clean generated files ]" />
<echo message="prepare [Create directories for output files ]" />
<echo message=" [ and generate files from templates ]" />
<echo message="build [Compile the Java source files ]" />
<echo message="rebuild [Call the clean and build targets ]" />
<echo message="javadoc [Generate the API documentation of the ]" />
<echo message=" [ Java source code ]" />
<echo message="installer [Create the installation packages ]" />
<echo message="standalone [Create the ZIP packages ]" />
<echo message="all [Complete rebuild and packaging ]" />
<echo message="unittest [Run all unit tests ]" />
</target>
<!-- =================================================================== -->
<!-- Initialization target - only callable internally -->
<!-- =================================================================== -->
<target name="-init" unless="initialized" description="Initialize the build environment">
<property name="initialized" value="true" />
<!-- set the various timestamp properties we may need -->
<tstamp>
<format property="time.rfc822" pattern="EEE, dd MMM yyyy HH:mm:ss Z" locale="en"/>
<format property="time.year" pattern="yyyy" locale="en"/>
<format property="mnth.day" pattern="MMMdd" locale="en"/>
</tstamp>
<scriptdef language="javascript" name="toUpper">
project.setProperty("mnth.day",
project.getProperty("mnth.day").toUpperCase());
</scriptdef>
<toUpper/>
<!-- set os specific properties -->
<property name="os.windows" value="windows" />
<property name="ext.windows" value="bat" />
<property name="os.linux" value="linux" />
<property name="ext.linux" value="sh" />
<condition property="os" value="${os.windows}" else="${os.linux}">
<os family="windows" />
</condition>
<condition property="is.windows">
<equals arg1="${os}" arg2="${os.windows}" />
</condition>
<!-- java compiler properties -->
<property name="javac.source" value="1.6" />
<property name="javac.target" value="1.6" />
<condition property="bootclasspath.dir" value="${env.JRE_DIR}/lib"
else="C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib">
<isset property="env.JRE_DIR" />
</condition>
<property name="debug" value="off" />
<property name="deprecation" value="on" />
<property name="javac.verbose" value="off" />
<!-- version properties are set in this file, both for the product itself and
for some of the external dependencies (jar files and such) -->
<property file="version.properties" />
<!-- basic project properties -->
<property name="src.dir" value="${basedir}/src" />
<property name="src.java.dir" value="${src.dir}/main/java" />
<property name="src.res.dir" value="${src.dir}/main/resources" />
<property name="graphics.dir" value="${src.res.dir}/graphics" />
<property name="docs.dir" value="${basedir}/docs" />
<property name="build.dir" value="${basedir}/build" />
<property name="template.dir" value="${basedir}/templates" />
<property name="3rdparty.dir" value="${basedir}/3rdparty" />
<!-- all generated files should go to somewhere in the build directory -->
<property name="classes.dir" value="${build.dir}/classes" />
<property name="javadoc.dir" value="${build.dir}/javadoc" />
<property name="dist.dir" value="${build.dir}/dist" />
<property name="testclasses.dir" value="${build.dir}/test" />
<!-- package naming properties -->
<property name="jar.package" value="${name.package}.jar" />
<property name="jar.installer-prefix"
value="${name.package}${version.major}.${version.minor}.${version.patch}-${version.buildnumber}" />
<!-- support tools -->
<!-- creates EXE wrappers around java apps -->
<property name="launch4j.dir" location="${3rdparty.dir}/launch4j" />
<!-- installer packager -->
<property name="izpack.dir" value="${3rdparty.dir}/IzPack" />
<condition property="have.3rdparty">
<and>
<available file="${izpack.dir}/izpack-standalone-compiler.jar" />
<available file="${launch4j.dir}/launch4j.jar" />
</and>
</condition>
<property name="izpack.compile" value="${izpack.dir}/izpack-standalone-compiler.jar" />
<!-- define custom tasks -->
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" onerror="report"
classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" />
<path id="windows.classpath">
<fileset dir="lib/common" includes="*.jar" />
<fileset dir="lib/windows" includes="*.jar" />
</path>
<path id="linux.classpath">
<fileset dir="lib/common" includes="*.jar" />
<fileset dir="lib/linux" includes="*.jar" />
</path>
<path id="test.classpath">
<fileset dir="${testclasses.dir}" includes="**/*.jar" />
</path>
<path id="junit_compile.classpath">
<path refid="linux.classpath" />
<pathelement location="lib/testing/junit.jar" />
<pathelement location="lib/testing/hamcrest.jar" />
</path>
<path id="junit_runtime.classpath">
<path refid="junit_compile.classpath" />
<pathelement location="${build.dir}/linux/lib/RomRaider.jar" />
<path refid="test.classpath" />
</path>
<!-- this set of filters should contain all the substitutions needed -->
<filterset id="version.filterset">
<filter token="time.year" value="${time.year}" />
<filter token="warning.generated-file" value="${warning.generated-file}" />
<filter token="name.package" value="${name.package}" />
<filter token="description.package" value="${description.package}" />
<filter token="name.organization" value="${name.organization}" />
<filter token="name.maintainer" value="${name.maintainer}" />
<filter token="email.maintainer" value="${email.maintainer}" />
<filter token="supporturl" value="${supporturl}" />
<filter token="romrevisionurl" value="${romrevisionurl}" />
<filter token="ecudefsurl" value="${ecudefsurl}" />
<filter token="loggerdefsurl" value="${loggerdefsurl}" />
<filter token="carsdefsurl" value="${carsdefsurl}" />
<filter token="release_notes" value="${release_notes}" />
<filter token="version.major" value="${version.major}" />
<filter token="version.minor" value="${version.minor}" />
<filter token="version.patch" value="${version.patch}" />
<filter token="version.buildnumber" value="${version.buildnumber}" />
<filter token="version.extra" value="${version.extra}" />
<filter token="version.extra1" value="${version.extra1}" />
<filter token="min.logger.def.version" value="${min.logger.def.version}" />
<filter token="build.arch" value="${build.arch}" />
<filter token="jvm.args.win" value="${jvm.args.win}" />
<filter token="jvm.args.linux" value="${jvm.args.linux}" />
</filterset>
</target>
<!-- =================================================================== -->
<!-- cleans all generated files -->
<!-- =================================================================== -->
<target name="clean" depends="-init" description="Clean all generated files">
<delete dir="${build.dir}" failonerror="false" />
</target>
<!-- =================================================================== -->
<!-- pre-build preparation -->
<!-- =================================================================== -->
<target name="prepare" depends="-init" description="Pre-build preparation">
<!-- generate the Version class -->
<copy overwrite="true" tofile="${src.java.dir}/com/romraider/Version.java"
file="src/main/java/com/romraider/Version.java.template">
<filterset refid="version.filterset" />
</copy>
</target>
<!-- =================================================================== -->
<!-- complete rebuild -->
<!-- =================================================================== -->
<target name="rebuild" depends="clean, build" description="Rebuild"/>
<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile-windows" depends="prepare" description="Compile the source directory for Windows">
<macro_compile os="${os.windows}" srcdir="${src.java.dir}" destdir="${classes.dir}" classpathref="windows.classpath"/>
</target>
<target name="compile-linux" depends="prepare" description="Compile the source directory for Linux">
<macro_compile os="${os.linux}" srcdir="${src.java.dir}" destdir="${classes.dir}" classpathref="linux.classpath"/>
</target>
<!-- =================================================================== -->
<!-- Build jar files -->
<!-- =================================================================== -->
<target name="build-linux" depends="compile-linux" description="Build the Jar file for Linux">
<macro_jar os="${os.linux}" basedir="${classes.dir}"/>
</target>
<target name="build-windows" depends="compile-windows" description="Build the Jar file for Windows">
<macro_jar os="${os.windows}" basedir="${classes.dir}"/>
</target>
<target name="build" depends="build-windows, build-linux" description="Build the Jar files for Linux and Windows"/>
<!-- =================================================================== -->
<!-- Compile and run all unit tests -->
<!-- =================================================================== -->
<target name="compile-for-unittests" depends="prepare" description="Compile and run Linux unit tests">
<mkdir dir="${testclasses.dir}" />
<macro_compile os="${os.linux}" srcdir="${src.dir}" destdir="${testclasses.dir}" classpathref="junit_compile.classpath" />
<macro_jar os="${os.linux}" basedir="${testclasses.dir}"/>
</target>
<target name="unittest" depends="compile-for-unittests" description="Perform unit tests">
<!-- We execute same coverage on both Windows and Linux-->
<junit printsummary="withOutAndErr" showoutput="true" haltonfailure="true">
<classpath refid="junit_runtime.classpath" />
<batchtest skipNonTests="true">
<fileset dir="${testclasses.dir}">
<include name="**/*Test*" />
</fileset>
</batchtest>
<formatter type="brief" usefile="false"/>
</junit>
<fail message="test failed" if="junit.failure" />
</target>
<!-- ================================================================== -->
<!-- generate javadoc -->
<!-- ================================================================== -->
<target name="javadoc" depends="-init" description="Generate javadocs">
<delete quiet="true" dir="${javadoc.dir}" />
<mkdir dir="${javadoc.dir}" />
<javadoc windowtitle="${name.package}" header="${javadoc.header}" sourcepath="${src.java.dir}" author="yes"
version="yes" destdir="${javadoc.dir}"
breakiterator="yes" maxmemory="96m">
<packageset dir="src">
<include name="**" />
</packageset>
<bottom>${javadoc.footer}</bottom>
<classpath refid="${os.windows}.classpath" />
</javadoc>
</target>
<!-- =================================================================== -->
<!-- create installation -->
<!-- =================================================================== -->
<target name="installer" depends="-init" if="have.3rdparty"
description="Create installation distribution packages">
<delete dir="${dist.dir}" failonerror="false" />
<mkdir dir="${dist.dir}/windows" />
<mkdir dir="${dist.dir}/linux" />
<!-- generate installer scripts from templates -->
<copy overwrite="true" tofile="${dist.dir}/install-windows.xml"
file="${template.dir}/install-windows.xml.template">
<filterset refid="version.filterset" />
</copy>
<copy overwrite="true" tofile="${dist.dir}/install-linux.xml" file="${template.dir}/install-linux.xml.template">
<filterset refid="version.filterset" />
</copy>
<copy overwrite="true" tofile="${dist.dir}/shortcutSpec-windows.xml"
file="${template.dir}/shortcutSpec-windows.xml.template">
<filterset refid="version.filterset" />
</copy>
<copy overwrite="true" tofile="${dist.dir}/shortcutSpec-linux.xml"
file="${template.dir}/shortcutSpec-linux.xml.template">
<filterset refid="version.filterset" />
</copy>
<!-- generate the launch4j scripts from templates -->
<copy overwrite="true" tofile="${dist.dir}/l4j-installer.xml" file="${template.dir}/l4j-installer.xml.template">
<filterset refid="version.filterset" />
</copy>
<copy overwrite="true" tofile="${dist.dir}/l4j-package.xml" file="${template.dir}/l4j-package.xml.template">
<filterset refid="version.filterset" />
</copy>
<macro_generate_executables/>
</target>
<!-- =================================================================== -->
<!-- create standalone ZIP -->
<!-- =================================================================== -->
<target name="standalone" depends="rebuild"
description="Create standalone ZIP packages">
<macro_standalone os="${os.windows}" />
<macro_standalone os="${os.linux}" />
</target>
<!-- =================================================================== -->
<!-- all -->
<!-- =================================================================== -->
<target name="all" depends="rebuild, installer, standalone"
description="Compile and create distribution packages" />
<!-- =================================================================== -->
<!-- Macros -->
<!-- =================================================================== -->
<macrodef name="macro_generate_executables">
<sequential>
<!-- create the exe launcher of the package for Windows -->
<antcall target="-launch4j">
<param name="type" value="package" />
</antcall>
<!-- generate the installers -->
<macro_izpack_compile os="${os}" target.os="${os.windows}" />
<macro_izpack_compile os="${os}" target.os="${os.linux}" />
<!-- create the exe launcher of the installer for Windows -->
<antcall target="-launch4j">
<param name="type" value="installer" />
</antcall>
</sequential>
</macrodef>
<target name="-launch4j" if="is.windows"
description="Create the exe launcher of the installer or package for Windows">
<launch4j configFile="${dist.dir}/l4j-${type}.xml" />
</target>
<macrodef name="macro_izpack_compile">
<attribute name="os" />
<attribute name="target.os" />
<sequential>
<java jar="${izpack.compile}" fork="true">
<arg line="${dist.dir}/install-@{target.os}.xml -b . -o ${dist.dir}/@{target.os}/${jar.installer-prefix}-@{target.os}.jar -k standard" />
</java>
</sequential>
</macrodef>
<macrodef name="macro_jar">
<attribute name="os" />
<attribute name="basedir" />
<sequential>
<mkdir dir="${build.dir}/@{os}/lib" />
<manifestclasspath property="@{os}.jar.classpath" jarfile="${jar.package}">
<classpath>
<fileset dir="lib/common" includes="*.jar" />
<fileset dir="lib/@{os}" includes="*.jar" />
</classpath>
</manifestclasspath>
<manifest file="${build.dir}/@{os}/MANIFEST.MF">
<attribute name="Built-By" value="${name.maintainer}" />
<attribute name="Main-Class" value="${class.start}" />
<attribute name="Class-Path" value="${@{os}.jar.classpath}" />
</manifest>
<jar basedir="@{basedir}" destfile="${build.dir}/@{os}/lib/${jar.package}"
manifest="${build.dir}/@{os}/MANIFEST.MF">
<fileset dir="${src.res.dir}">
<include name="**/*.*" />
</fileset>
</jar>
</sequential>
</macrodef>
<macrodef name="macro_compile">
<attribute name="os" />
<attribute name="srcdir" />
<attribute name="destdir" />
<attribute name="classpathref" />
<sequential>
<mkdir dir="${classes.dir}" />
<path id="bootpath.ref">
<fileset dir="${bootclasspath.dir}" includes="*.jar"/>
</path>
<javac
failonerror="true"
srcdir="@{srcdir}"
destdir="@{destdir}"
source="${javac.source}"
target="${javac.target}"
includeantruntime="false"
debug="${debug}"
verbose="${javac.verbose}"
deprecation="${deprecation}"
compiler="javac${javac.target}"
bootclasspath="${toString:bootpath.ref}"
encoding="UTF-8" >
<!--
<compilerarg value="-Xlint" />
-->
<classpath refid="@{classpathref}" />
</javac>
</sequential>
</macrodef>
<macrodef name="macro_standalone">
<attribute name="os" />
<sequential>
<zip destfile="${dist.dir}/@{os}/${name.package}${version.major}.${version.minor}.${version.patch}${version.extra}${version.extra1}-@{os}.zip">
<zipfileset file="build/@{os}/lib/${jar.package}" prefix="${name.package}" />
<zipfileset file="scripts/run.${ext.@{os}}" prefix="${name.package}" filemode="755" />
<zipfileset file="license.txt" prefix="${name.package}" />
<zipfileset file="release_notes.txt" prefix="${name.package}" />
<zipfileset file="lib/log4j.properties" prefix="${name.package}/lib"/>
<zipfileset dir="plugins" prefix="${name.package}/plugins" />
<zipfileset dir="lib/common" prefix="${name.package}/lib/common" />
<zipfileset dir="lib/@{os}" prefix="${name.package}/lib/@{os}" />
<zipfileset dir="src" prefix="${name.package}/src" excludes="**/*.template" />
<zipfileset dir="customize" prefix="${name.package}/customize"/>
<zipfileset dir="i18n" prefix="${name.package}/i18n"/>
</zip>
</sequential>
</macrodef>
</project>