/
build.xml
128 lines (109 loc) · 5.65 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
<!--
Copyright LWJGL. All rights reserved.
License terms: http://lwjgl.org/license.php
-->
<project name="native-macosx" basedir="../.." xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="../build-definitions.xml"/>
<property name="LWJGL_LIBRARY" value="liblwjgl.dylib"/>
<!-- Ask Xcode for correct path to XCode tools -->
<!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
<exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-error" failonerror="false" failifexecutionfails="false">
<arg value="--print-path"/>
</exec>
<!-- Default to /Developer if xcode-select fails -->
<condition property="developer_path" value="/Developer">
<isset property="xcode-error"/>
</condition>
<!-- Choose a MacOSX SDK -->
<macrodef name="find-sdkroot">
<attribute name="version"/>
<sequential>
<condition property="sdkroot" value="${developer_path}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX@{version}.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX@{version}.sdk" type="dir"/>
</and>
</condition>
</sequential>
</macrodef>
<find-sdkroot version="10.10"/>
<find-sdkroot version="10.9"/>
<find-sdkroot version="10.8"/>
<condition property="compiler" value="clang" else="gcc"> <!-- Use clang on 10.8 or newer, gcc on 10.7 -->
<isset property="sdkroot"/>
</condition>
<find-sdkroot version="10.7"/>
<fail unless="sdkroot" message="Failed to find the MacOS X SDK."/>
<fileset id="link-objects" dir="${bin.native}" includes="*.o"/>
<fileset id="link-libraries" dir="${lib.abs}/macosx/${build.arch}/">
<include name="libffi.a"/>
<include name="libglfw3.a" if:true="${build.glfw}"/>
</fileset>
<fileset id="link-ovr" dir="${OCULUS_SDK_PATH}/LibOVR/Lib/Mac/Release" includes="*.framework" if:true="${build.ovr}"/>
<property name="macosx-version-min" value="10.7"/>
<target name="compile-native-platform">
<echo message="${sdkroot}" taskname="SDK Root"/>
<!-- COMPILE -->
<property name="warnings" value="-Werror -Wfatal-errors -Wall -Wextra -pedantic -Wno-extended-offsetof"/>
<apply dir="${bin.native}" executable="${compiler}" dest="${bin.native}" skipemptyfilesets="true" failonerror="true" parallel="true" taskname="Compiler">
<arg line="-c -std=c99 -O3 -fPIC ${warnings} -DLWJGL_MACOSX -isysroot ${sdkroot} -mmacosx-version-min=${macosx-version-min}"/>
<arg value="-I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers"/>
<!-- Paths relative to dir -->
<arg value="-I${src.native.abs}/system"/>
<arg value="-I${src.native.abs}/system/macosx"/>
<arg value="-I${src.native.abs}/system/libffi"/>
<arg value="-I${src.native.abs}/glfw" if:true="${build.glfw}"/>
<arg value="-I${src.native.abs}/openal" if:true="${build.openal}"/>
<arg value="-I${src.native.abs}/opencl" if:true="${build.opencl}"/>
<arg value="-I${src.native.abs}/opengl" if:true="${build.opengl}"/>
<arg value="-I${OCULUS_SDK_PATH}/LibOVR/Include" if:true="${build.ovr}"/>
<!-- Paths relative to basedir -->
<fileset dir="${src.native}/system" includes="*.c"/>
<fileset dir="${src.native}/system/libffi" includes="*.c"/>
<fileset dir="${generated.native}/system" includes="*.c"/>
<fileset dir="${generated.native}/system/macosx" includes="*.c"/>
<fileset dir="${generated.native}/system/macosx" includes="*.m"/>
<fileset dir="${generated.native}/system/libffi" includes="*.c"/>
<fileset dir="${generated.native}/glfw" includes="*.c" if:true="${build.glfw}"/>
<fileset dir="${generated.native}/glfw/macosx" includes="*.c" if:true="${build.glfw}"/>
<fileset dir="${generated.native}/openal" includes="*.c" if:true="${build.openal}"/>
<fileset dir="${generated.native}/opencl" includes="*.c" excludes="*CL20.c" if:true="${build.opencl}"/>
<fileset dir="${generated.native}/opengl" includes="*.c" if:true="${build.opengl}"/>
<fileset dir="${generated.native}/opengl/cgl" includes="*.c" if:true="${build.opengl}"/>
<fileset dir="${generated.native}/ovr" includes="*.c" if:true="${build.ovr}"/>
<regexpmapper from="^(.*)\.(c|m)" to="\1.o"/>
</apply>
<!-- LINK -->
<uptodate property="link-uptodate" targetfile="${lib}/${LWJGL_LIBRARY}">
<srcfiles refid="link-objects"/>
<srcfiles refid="link-libraries"/>
<srcfiles refid="link-ovr" if:true="${build.ovr}"/>
</uptodate>
<antcall target="-link-if-necessary"/>
</target>
<target name="-link-if-necessary" unless="link-uptodate">
<antcall target="-link"/>
</target>
<target name="-update-dependencies" unless="${build.offline}">
<mkdir dir="${lib}/macosx"/>
<mkdir dir="${lib}/macosx/x64"/>
<update-dependency name="OpenAL32" artifact="x64/libopenal.dylib" dest="${lib}/libopenal.dylib" if:true="${build.openal}"/>
<update-dependency name="glfw3" artifact="x64/libglfw3.a" if:true="${build.glfw}"/>
<update-dependency name="libffi" artifact="x64/libffi.a"/>
</target>
<target name="-link" depends="-update-dependencies">
<apply dir="${lib}" executable="${compiler}" failonerror="true" parallel="true" taskname="Linker">
<srcfile/>
<arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=${macosx-version-min} -o ${LWJGL_LIBRARY}'/>
<arg line="-framework AppKit"/>
<!--<arg line="-framework CoreFoundation"/>-->
<arg line="-framework CoreVideo"/>
<!--<arg line="-framework Cocoa"/>-->
<arg line="-framework IOKit"/>
<arg line="-framework OpenGL" if:true="${build.opengl}"/>
<arg line="-F ${OCULUS_SDK_PATH}/LibOVR/Lib/Mac/Release -framework LibOVR" if:true="${build.ovr}"/>
<fileset refid="link-objects"/>
<fileset refid="link-libraries"/>
</apply>
</target>
</project>