forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
363 lines (306 loc) · 14.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
<project name="LWJGL" basedir="." default="all">
<property name="build.sysclasspath" value="ignore"/>
<property name="config" location="config" relative="true"/>
<import file="${config}/build-definitions.xml" id="defs"/>
<!-- Initialize build -->
<target name="-initialize" description="Initializes the directories required by the build process">
<mkdir dir="${lib}"/>
<mkdir dir="${generated}"/>
<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>
<!-- Cleans up any files created during the execution of this script -->
<target name="clean" description="Cleans all directories controlled by this ant script" depends="clean-java, clean-native, clean-generated">
<delete dir="${bin}"/>
</target>
<target name="clean-generated" description="Cleans files generated by this ant script" depends="clean-generated-java,clean-generated-native">
<!-- We track the generated directory in a separate repo, so delete individual subdirectories only. -->
<delete dir="${generated.tests}"/>
<delete dir="${generated.javadoc}"/>
</target>
<!-- Cleans up any non-native files created during the execution of this script -->
<target name="clean-java" description="Cleans non-native files generated by this ant script" depends="clean-generated-java">
<!-- Delete java classes only to avoid unnecessary native recompilation -->
<delete dir="${bin.core}"/>
<delete dir="${bin.util}"/>
<delete dir="${bin.templates}"/>
<delete dir="${bin.tests}"/>
</target>
<target name="clean-generated-java" description="Cleans Java source files generated by this ant script">
<delete file="${generated}/touch.txt" quiet="true"/>
<delete dir="${generated.java}"/>
</target>
<!-- Useful when we need to force native recompilation -->
<target name="clean-native" description="Cleans native binary files generated by this ant script">
<delete dir="${bin.native}"/>
</target>
<target name="clean-generated-native" description="Cleans native source files generated by this ant 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">
<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>
<condition property="env.JAVA6_HOME" value="${env.JAVA_HOME}">
<not><isset property="env.JAVA6_HOME"/></not>
</condition>
<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>
</target>
<target name="compile-templates" description="Compiles the Templates module" depends="-initialize">
<uptodate targetfile="${bin}/Templates/touch.txt" property="templates-uptodate">
<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"/>
<jvmarg value="-Dorg.lwjgl.templates.output=${bin.templates}"/>
<arg line="${kotlinc}/lib/kotlin-compiler.jar${path.separator}${kotlinc}/lib/kotlin-runtime.jar"/>
<arg line="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler 4096 notime"/>
<arg line="-module ${config}/Templates.ktm"/>
<!--
<arg value="-Xno-call-assertions"/>
<arg value="-Xno-param-assertions"/>
-->
</java>
<touch file="${bin.templates}/touch.txt"/>
</target>
<target name="formatter" description="Runs the template formatter tool" depends="-initialize, -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="-initialize">
<available file="${bin.templates}/touch.txt" 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="${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"/>
<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, -init-compile">
<javac debug="yes" 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>
<!-- 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="-initialize, compile">
<ant antfile="${config}/${platform}/build.xml" inheritAll="false"/>
</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}/"/>
</javac>
</target>
<target name="-init-runtime" description="Initializes properties required for running demos and tests">
<path id="library.path">
<pathelement path="${bin}"/>
<pathelement path="${lib}"/>
</path>
<property name="library.path" refid="library.path"/>
<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">
<condition property="osxargs" value="-XstartOnFirstThread" else="">
<isset property="platform.macosx"/>
</condition>
<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=${library.path}"/>
<jvmarg line="${osxargs}"/>
<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">
<fail message="Please use -Dclass=<class> to specify the demo main class to run." unless="class"/>
<condition property="class" value="${class}" else="">
<isset property="class"/>
</condition>
<condition property="osxargs" value="-XstartOnFirstThread" else="">
<isset property="platform.macosx"/>
</condition>
<condition property="jvmargs" value="${jvmargs}" else="">
<isset property="jvmargs"/>
</condition>
<condition property="args" value="${args}" else="">
<isset property="args"/>
</condition>
<java classname="${class}" classpathref="runtime.classpath" fork="true" failonerror="true" taskname="Demo">
<classpath>
<pathelement path="${lib}/testng.jar"/>
</classpath>
<jvmarg value="-Djava.library.path=${library.path}"/>
<jvmarg line="${osxargs}"/>
<jvmarg line="${jvmargs}"/>
<arg line="${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>
<fileset dir="${src.core}" includes="**"/>
<fileset dir="${src.util}" includes="**"/>
<fileset dir="${generated.java}" includes="**"/>
</javadoc>
</target>
<target name="release" description="" depends="compile,javadoc">
<!-- 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}/windows/x64"/>
<mkdir dir="${release.native}/windows/x86"/>
<update name="LWJGL Win64" url="http://build.lwjgl.org/${build.type}/windows/x64/lwjgl.dll" dest="${release.native}/windows/x64"/>
<update name="LWJGL Win32" url="http://build.lwjgl.org/${build.type}/windows/x86/lwjgl.dll" dest="${release.native}/windows/x86"/>
<update name="OpenAL32 Win64" url="http://build.lwjgl.org/${build.type}/windows/x64/OpenAL32.dll" dest="${release.native}/windows/x64"/>
<update name="OpenAL32 Win32" url="http://build.lwjgl.org/${build.type}/windows/x86/OpenAL32.dll" dest="${release.native}/windows/x86"/>
<mkdir dir="${release.native}/linux/x64"/>
<mkdir dir="${release.native}/linux/x86"/>
<update name="LWJGL Linux64" url="http://build.lwjgl.org/${build.type}/linux/x64/liblwjgl.so" dest="${release.native}/linux/x64"/>
<update name="LWJGL Linux32" url="http://build.lwjgl.org/${build.type}/linux/x86/liblwjgl.so" dest="${release.native}/linux/x86"/>
<update name="OpenAL32 Linux64" url="http://build.lwjgl.org/${build.type}/linux/x64/libopenal.so" dest="${release.native}/linux/x64"/>
<update name="OpenAL32 Linux32" url="http://build.lwjgl.org/${build.type}/linux/x64/libopenal.so" dest="${release.native}/linux/x86"/>
<mkdir dir="${release.native}/macosx/x64"/>
<update name="LWJGL OSX" url="http://build.lwjgl.org/${build.type}/macosx/x64/liblwjgl.dylib" dest="${release.native}/macosx/x64"/>
<update name="OpenAL32 OSX" url="http://build.lwjgl.org/${build.type}/macosx/x64/libopenal.dylib" dest="${release.native}/macosx/x64"/>
<!-- 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>