forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
478 lines (395 loc) · 18.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
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
476
477
478
<!--
Copyright LWJGL. All rights reserved.
License terms: http://lwjgl.org/license.php
-->
<project name="LWJGL" basedir="." default="all" xmlns:if="ant:if" xmlns:unless="ant:unless">
<property name="build.sysclasspath" value="ignore"/>
<property name="config" location="config" relative="true"/>
<import file="${config}/build-definitions.xml"/>
<import file="${config}/build-assets.xml"/>
<import file="${config}/${platform}/build.xml"/>
<!-- Initialize build -->
<target name="init" description="Initializes the directories required by the build process">
<fail message="LWJGL requires Ant version 1.9.3 or higher.">
<condition>
<not>
<antversion atleast="1.9.3"/>
</not>
</condition>
</fail>
<!-- These depend on LWJGL_BUILD_OUTPUT and may be symlinks -->
<mkdir-symlink dir="bin"/>
<mkdir-symlink dir="generated"/>
<mkdir-symlink dir="release"/>
<mkdir dir="${bin.core}"/>
<mkdir dir="${bin.util}"/>
<mkdir dir="${bin.templates}"/>
<mkdir dir="${bin.tests}"/>
<mkdir dir="${bin.native}"/>
<ant antfile="update-dependencies.xml" target="check-dependencies" inheritAll="false"/>
<!--<taskdef resource="org/jetbrains/kotlin/buildtools/ant/antlib.xml" classpath="${kotlinc}/lib/kotlin-ant.jar"/>-->
<taskdef resource="testngtasks" classpath="libs/testng.jar"/>
</target>
<target name="init-generated" description="Initializes the lwjgl3-generated git repository in /generated. [Optional]">
<confirm-replace dir="generated" msg="The /generated directory contents will be replaced with a fresh clone of the lwjgl3-generated repository. Continue?"/>
<!-- Purge /generated contents -->
<delete-symlink dir="generated"/>
<mkdir-symlink dir="generated"/>
<!-- Clone repo -->
<exec executable="git" failonerror="true">
<arg value="clone"/>
<arg value="https://github.com/LWJGL/lwjgl3-generated.git"/>
<arg value="generated"/>
</exec>
</target>
<target name="init-wiki" description="Initializes the lwjgl3-wiki git repository in /wiki. [Optional]">
<confirm-replace dir="${wiki}" msg="The ${wiki} directory contents will be replaced with a fresh clone of the lwjgl3-wiki repository. Continue?"/>
<delete dir="${wiki}"/>
<exec executable="git" failonerror="true">
<arg value="clone"/>
<arg value="https://github.com/LWJGL/lwjgl3-wiki.wiki.git"/>
<arg value="${wiki}"/>
</exec>
</target>
<target name="reset" description="Resets the repository to its initial state.">
<local name="reset.input"/>
<input
message="This action will clean everything and also remove libraries and sub-repositories. Continue?"
validargs="y,n"
defaultvalue="n"
addproperty="reset.input"
/>
<condition property="do.reset">
<equals arg1="y" arg2="${reset.input}"/>
</condition>
<fail unless="do.reset">Cancelled</fail>
<antcall target="clean"/>
<delete-symlink dir="generated"/>
<delete dir="${wiki}"/>
<delete dir="${lib}"/>
<echo message="Reset successful."/>
</target>
<target name="clean" description="Cleans all directories controlled by this script" depends="clean-java, clean-native, clean-templates, clean-generated">
<delete-symlink dir="bin"/>
<delete-symlink dir="release"/>
<!-- Do not delete /generated, it may contain the lwjgl3-generated git repo -->
<!-- Do not delete /wiki, it may contain the lwjgl3-wiki git repo -->
<echo message="Cleanup successful."/>
</target>
<target name="clean-java" description="Deletes Java binary files produced by this script">
<delete dir="${bin.core}"/>
<delete dir="${bin.util}"/>
<delete dir="${bin.tests}"/>
</target>
<target name="clean-native" description="Deletes native binary files produced by this script">
<delete dir="${bin.native}"/>
</target>
<target name="clean-templates" description="Deletes template binary files produced by this script">
<delete dir="${bin.templates}"/>
</target>
<target name="clean-generated" description="Deletes sources, test results and documentation generated by this script" depends="clean-generated-java,clean-generated-native">
<delete dir="${generated.tests}"/>
<delete dir="${generated.javadoc}"/>
</target>
<target name="clean-generated-java" description="Deletes Java sources generated by this script">
<delete file="${generated}/touch.txt" quiet="true"/>
<delete dir="${generated.java}"/>
</target>
<target name="clean-generated-native" description="Deletes native sources generated by this script">
<delete file="${generated}/touch.txt" quiet="true"/>
<delete dir="${generated.native}"/>
</target>
<target name="all" description="Build LWJGL and runs the tests" depends="compile-templates,tests"/>
<target name="-init-compile" description="Initializes properties required for compilation" depends="modules">
<condition property="java.home.missing">
<not>
<or>
<isset property="env.JAVA_HOME"/>
<isset property="env.JAVA6_HOME"/>
</or>
</not>
</condition>
<fail if="java.home.missing" message="Please set the JAVA_HOME environment variable."/>
<!--
JAVA6_HOME will be used for the bootclasspath. This will cause compilation to fail
if a Java 7+ API is used by mistake. Do not fail if it is not set, try to use
JAVA_HOME instead and issue a warning if that's not a Java 6 SDK.
-->
<sequential>
<script language="javascript">
if ( !java.lang.System.getenv().containsKey("JAVA6_HOME") ) {
var version = java.lang.System.getProperty("java.specification.version");
if ( !version.equals("1.6") )
print("The environment variable JAVA6_HOME has not been set. Using JAVA_HOME (version " + version + ").");
}
</script>
</sequential>
<property name="env.JAVA6_HOME" value="${env.JAVA_HOME}" unless:set="env.JAVA6_HOME"/>
<path id="jdk.boot.classpath.jars">
<fileset dir="${env.JAVA6_HOME}/jre/lib">
<include name="*.jar"/>
</fileset>
<fileset file="${env.JAVA6_HOME}/lib/tools.jar"/>
</path>
<path id="jdk.boot.classpath.applejars">
<fileset dir="${env.JAVA6_HOME}/bundle/Classes">
<include name="*.jar"/>
</fileset>
</path>
<condition property="jdk.boot.classpath" value="jdk.boot.classpath.applejars" else="jdk.boot.classpath.jars">
<available file="${env.JAVA6_HOME}/bundle/Classes/classes.jar"/>
</condition>
<patternset id="src.core.files">
<include name="org/lwjgl/*.java"/>
<include name="org/lwjgl/system/*.java"/>
<include name="org/lwjgl/system/libffi/**"/>
<include name="org/lwjgl/system/linux/**"/>
<include name="org/lwjgl/system/macosx/**"/>
<exclude name="org/lwjgl/system/macosx/ObjC*.java" unless:true="${build.macosx.objc}"/>
<include name="org/lwjgl/system/windows/**"/>
</patternset>
<patternset id="src.util.files">
<include name="org/lwjgl/openal/**" if:true="${build.openal}"/>
</patternset>
<patternset id="generated.java.files">
<include name="org/lwjgl/stb/**" if:true="${build.stb}"/>
<include name="org/lwjgl/glfw/**" if:true="${build.glfw}"/>
<include name="org/lwjgl/openal/**" if:true="${build.openal}"/>
<include name="org/lwjgl/opencl/**" if:true="${build.opencl}"/>
<include name="org/lwjgl/opengl/**" if:true="${build.opengl}"/>
<include name="org/lwjgl/mantle/**" if:true="${build.mantle}"/>
<include name="org/lwjgl/ovr/**" if:true="${build.ovr}"/>
</patternset>
</target>
<target name="compile-templates" description="Compiles the Templates module" depends="init">
<uptodate targetfile="${bin.templates}/org/lwjgl/generator/Generator.class" property="templates-uptodate">
<srcfiles dir="${config}" includes="build-modules.xml"/>
<srcfiles dir="${src.templates}" includes="**"/>
</uptodate>
<antcall target="-compile-templates"/>
</target>
<target name="-compile-templates" description="Compiles the Templates module" depends="-init-compile" unless="templates-uptodate">
<!-- Compile Java dependencies -->
<javac debug="yes" destdir="${bin}/Templates" encoding="utf8" source="1.6" target="1.6" bootclasspathref="${jdk.boot.classpath}" taskname="Java dependencies">
<src path="${src.templates}"/>
<include name="org/lwjgl/**"/>
</javac>
<!-- Compile Kotlin code -->
<echo message="Compiling Kotlin templates. This will take several seconds..." level="info" taskname="Templates"/>
<java
classpath="${kotlinc}/lib/kotlin-preloader.jar"
classname="org.jetbrains.kotlin.preloading.Preloader"
fork="true" failonerror="true" taskname="Templates"
>
<jvmarg value="-server"/>
<jvmarg value="-Xms1024m"/>
<jvmarg value="-Xverify:none"/>
<arg path="${kotlinc}/lib/kotlin-compiler.jar:${kotlinc}/lib/kotlin-runtime.jar"/>
<arg line="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler 4096 notime"/>
<arg line="-kotlin-home ${kotlinc}"/>
<arg line="-d ${bin.templates}"/>
<arg value="${src.templates}/org/lwjgl/generator"/>
<arg value="${src.templates}/org/lwjgl/system"/>
<arg value="${src.templates}/org/lwjgl/glfw" if:true="${build.glfw}"/>
<arg value="${src.templates}/org/lwjgl/openal" if:true="${build.openal}"/>
<arg value="${src.templates}/org/lwjgl/opencl" if:true="${build.opencl}"/>
<arg value="${src.templates}/org/lwjgl/opencl/CLTypes.kt" if:true="${build.opengl_nocl}"/>
<arg value="${src.templates}/org/lwjgl/opengl/GLTypes.kt" if:true="${build.opencl_nogl}"/>
<arg value="${src.templates}/org/lwjgl/opengl" if:true="${build.opengl}"/>
<arg value="${src.templates}/org/lwjgl/ovr" if:true="${build.ovr}"/>
<arg value="${src.templates}/org/lwjgl/stb" if:true="${build.stb}"/>
<!--
<arg value="-Xno-call-assertions"/>
<arg value="-Xno-param-assertions"/>
-->
</java>
</target>
<target name="formatter" description="Runs the template formatter tool" depends="init, -init-compile"> <!-- Removed "compile-templates" until Kotlin adds support for incremental compilation -->
<javac debug="yes" destdir="${bin.templates}" encoding="utf8" source="1.6" target="1.6" bootclasspathref="${jdk.boot.classpath}">
<src path="${src.templates}"/>
<include name="org/lwjgl/**"/>
</javac>
<java
classname="org.lwjgl.generator.util.TemplateFormatter"
fork="true"
spawn="true"
>
<classpath>
<pathelement path="${bin.templates}"/>
<pathelement path="${res}"/>
</classpath>
</java>
</target>
<target name="generate" description="Runs the bindings Generator" depends="init, -init-compile">
<available file="${bin.templates}/org/lwjgl/generator/Generator.class" property="has-compiled-templates"/>
<fail unless="has-compiled-templates" message="Please invoke the compile-templates target first."/>
<uptodate property="generated-uptodate" targetfile="${generated}/touch.txt">
<srcfiles dir="${config}" includes="build-modules.xml"/>
<srcfiles dir="${bin.templates}" includes="**/*.class"/>
</uptodate>
<antcall target="-generate"/>
</target>
<target name="-generate" description="Runs the code Generator" unless="generated-uptodate">
<java
classname="org.lwjgl.generator.GeneratorPackage"
fork="true"
failonerror="true"
taskname="Generator"
>
<classpath>
<pathelement path="${bin.templates}"/>
<pathelement path="${kotlinc}/lib/kotlin-runtime.jar"/>
</classpath>
<jvmarg value="-server"/>
<jvmarg line="${build.modules}"/>
<arg value="${src.templates}"/>
<arg value="${generated}"/>
</java>
<touch file="${generated}/touch.txt" verbose="false"/>
</target>
<target name="compile" description="Compiles the Java source code" depends="generate">
<javac debug="yes" sourcepath="" destdir="${bin.core}" encoding="utf8" source="1.6" target="1.6" bootclasspathref="${jdk.boot.classpath}" taskname="Core">
<src>
<pathelement path="${src.core}"/>
<pathelement path="${src.util}"/>
<pathelement path="${generated.java}"/>
</src>
<patternset refid="src.core.files"/>
<patternset refid="src.util.files"/>
<patternset refid="generated.java.files"/>
<!-- Supresses internal API (e.g. Unsafe) usage warnings -->
<compilerarg value="-XDignore.symbol.file=true"/>
</javac>
</target>
<target name="compile-native" description="Compiles the native source code" depends="init, compile">
<antcall target="compile-native-platform"/>
</target>
<target name="compile-tests" description="Compiles the LWJGL test suite" depends="compile">
<javac debug="yes" destdir="${bin.tests}" encoding="utf8" source="1.6" target="1.6" bootclasspathref="${jdk.boot.classpath}" taskname="Tests">
<classpath>
<pathelement path="${bin.core}"/>
<pathelement path="${bin.util}"/>
<pathelement path="${lib}/testng.jar"/>
</classpath>
<src path="${src.tests}/"/>
<include name="org/lwjgl/system/**"/>
<include name="org/lwjgl/demo/util/**"/>
<include name="org/lwjgl/demo/windows/**"/>
<include name="org/lwjgl/openal/**" if:true="${build.openal}"/>
<include name="org/lwjgl/opencl/**" if:true="${build.opencl}"/>
<include name="org/lwjgl/demo/glfw/**" if:true="${build.glfw}"/>
<include name="org/lwjgl/demo/openal/**" if:true="${build.openal}"/>
<include name="org/lwjgl/demo/opencl/**" if:true="${build.glfw_opencl}"/>
<include name="org/lwjgl/demo/opencl/CLDemo.java" if:true="${build.opencl}"/>
<include name="org/lwjgl/demo/opengl/**" if:true="${build.glfw}"/>
<include name="org/lwjgl/demo/ovr/**" if:true="${build.ovr}"/>
<include name="org/lwjgl/demo/stb/**" if:true="${build.glfw_stb}"/>
</javac>
</target>
<target name="-init-runtime" description="Initializes properties required for running demos and tests">
<path id="runtime.classpath">
<pathelement path="${bin.core}"/>
<pathelement path="${bin.util}"/>
<pathelement path="${res}"/>
<pathelement path="${bin.tests}"/>
</path>
</target>
<target name="tests" description="Runs the LWJGL test suite" depends="compile-tests, compile-native, -init-runtime">
<testng outputDir="${generated.tests}" classpathref="runtime.classpath" taskname="Tests">
<classpath>
<pathelement path="${lib}/jcommander.jar"/>
</classpath>
<jvmarg value="-Xcheck:jni"/>
<jvmarg value="-ea"/>
<jvmarg value="-Dorg.lwjgl.util.Debug=true"/>
<jvmarg value="-Djava.library.path=${lib}"/>
<jvmarg value="-XstartOnFirstThread" if:set="platform.macosx"/>
<xmlfileset dir="${config}" includes="tests.xml,tests_${platform}.xml"/>
</testng>
</target>
<target name="demo" description="Runs an LWJGL demo" depends="compile-tests, compile-native, -init-runtime, -update-assets">
<fail message="Please use -Dclass=<class> to specify the demo main class to run." unless="class"/>
<java classname="${class}" classpathref="runtime.classpath" fork="true" failonerror="true" taskname="Demo">
<classpath>
<pathelement path="${lib}/testng.jar"/>
</classpath>
<jvmarg value="-Djava.library.path=${lib}"/>
<jvmarg value="-XstartOnFirstThread" if:set="platform.macosx"/>
<jvmarg line="${jvmargs}" if:set="jvmargs"/>
<arg line="${args}" if:set="args"/>
</java>
</target>
<target name="javadoc" description="Generates the LWJGL JavaDoc" depends="generate">
<uptodate targetfile="${generated.javadoc}/index.html" property="javadoc-uptodate">
<srcfiles dir="${src.core}" includes="**"/>
<srcfiles dir="${generated.java}" includes="**"/>
</uptodate>
<antcall target="-javadoc"/>
</target>
<target name="-javadoc" description="Generates the LWJGL JavaDoc" depends="-init-compile" unless="javadoc-uptodate">
<delete dir="${generated.javadoc}"/>
<javadoc
destdir="${generated.javadoc}"
source="1.6"
bootclasspathref="${jdk.boot.classpath}"
windowtitle="LWJGL ${build.version}"
encoding="utf8"
docencoding="utf8"
useexternalfile="true"
nohelp="true"
notree="true"
stylesheetfile="${config}/javadoc.css"
doclet="org.lwjgl.system.ExcludeDoclet"
docletpath="${bin.templates}"
>
<!-- TODO: Add package-info documentation -->
<doctitle><![CDATA[<h1>Lightweight Java Game Library</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright LWJGL. All Rights Reserved. <a href="http://lwjgl.org/license.php">License terms</a>.</i>]]></bottom>
<classpath>
<pathelement path="${src.core}"/>
<pathelement path="${src.util}"/>
<pathelement path="${generated.java}"/>
</classpath>
<fileset dir="${src.core}">
<patternset refid="src.core.files"/>
</fileset>
<fileset dir="${src.util}">
<patternset refid="src.util.files"/>
</fileset>
<fileset dir="${generated.java}">
<patternset refid="generated.java.files"/>
</fileset>
</javadoc>
</target>
<target name="release" description="Creates the LWJGL binary redistributable" depends="compile,javadoc">
<echo file="${release}/build.txt" if:set="build.revision">LWJGL ${build.version} build ${build.revision}</echo>
<!-- Bundle classes -->
<mkdir dir="${release.jar}"/>
<jar destfile="${release.jar}/lwjgl.jar" basedir="${bin.core}" includes="**" level="9" index="true"/>
<!-- Download binaries from build.lwjgl.org -->
<mkdir dir="${release.native}"/>
<update name="LWJGL Win64" url="http://build.lwjgl.org/${build.type}/windows/x64/lwjgl.dll" dest="${release.native}"/>
<update name="LWJGL Win32" url="http://build.lwjgl.org/${build.type}/windows/x86/lwjgl.dll" dest="${release.native}/lwjgl32.dll"/>
<update name="OpenAL32 Win64" url="http://build.lwjgl.org/${build.type}/windows/x64/OpenAL32.dll" dest="${release.native}/OpenAL.dll"/>
<update name="OpenAL32 Win32" url="http://build.lwjgl.org/${build.type}/windows/x86/OpenAL32.dll" dest="${release.native}/OpenAL32.dll"/>
<update name="LWJGL Linux64" url="http://build.lwjgl.org/${build.type}/linux/x64/liblwjgl.so" dest="${release.native}"/>
<update name="LWJGL Linux32" url="http://build.lwjgl.org/${build.type}/linux/x86/liblwjgl.so" dest="${release.native}/liblwjgl32.so"/>
<update name="OpenAL32 Linux64" url="http://build.lwjgl.org/${build.type}/linux/x64/libopenal.so" dest="${release.native}"/>
<update name="OpenAL32 Linux32" url="http://build.lwjgl.org/${build.type}/linux/x64/libopenal.so" dest="${release.native}/libopenal32.so"/>
<update name="LWJGL OSX" url="http://build.lwjgl.org/${build.type}/macosx/x64/liblwjgl.dylib" dest="${release.native}"/>
<update name="OpenAL32 OSX" url="http://build.lwjgl.org/${build.type}/macosx/x64/libopenal.dylib" dest="${release.native}"/>
<!-- Bundle javadoc -->
<mkdir dir="${release.doc}"/>
<zip destfile="${release.doc}/javadoc.zip" basedir="${generated.javadoc}" includes="**" level="9"/>
<!-- Copy license files -->
<copy todir="${release.doc}">
<fileset dir="${doc}" includes="LICENSE.txt"/>
<fileset dir="${doc}" includes="3rdparty/**"/>
</copy>
<!-- Bundle source -->
<zip destfile="${release}/src.zip" level="9">
<fileset dir="${src.core}" includes="**"/>
<fileset dir="${generated.java}" includes="**"/>
</zip>
</target>
</project>