• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<project name="gdx-bullet-Linux-32" basedir="." default="postcompile">
2	<!-- include the environment -->
3	<property environment="env"/>
4	<!-- output directory for temporary object files -->
5	<property name="buildDir" value="target/linux32" />
6	<!-- output directory for the shared library -->
7	<property name="libsDir" value="../libs/linux32" />
8	<!-- the name of the shared library -->
9	<property name="libName" value="libgdx-bullet.so"/>
10	<!-- the jni header jniPlatform to use -->
11	<property name="jniPlatform" value="linux"/>
12	<!-- the compilerPrefix for the C & C++ compilers -->
13	<property name="compilerPrefix" value=""/>
14	<!--  the compilerSuffix for the C & C++ compilers -->
15	<property name="compilerSuffix" value="" />
16
17	<!-- define gcc compiler, options and files to compile -->
18	<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
19	<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m32 -fPIC"/>
20	<fileset id="gcc-files" dir="./">
21		<exclude name="target/"/>
22				<include name="memcpy_wrap.c"/>
23		<include name="**/*.c"/>
24
25				<exclude name="src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/**"/>
26
27	</fileset>
28
29	<!-- define g++ compiler, options and files to compile -->
30	<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
31	<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m32 -fPIC -fno-strict-aliasing -fno-rtti -DBT_NO_PROFILE"/>
32	<fileset id="g++-files" dir="./">
33		<exclude name="target/"/>
34				<include name="**/*.cpp"/>
35
36				<exclude name="src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/**"/>
37
38	</fileset>
39
40	<!-- define linker and options -->
41	<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
42	<property name="linker-opts" value="-shared -m32"/>
43	<property name="libraries" value=""/>
44
45	<!-- cleans the build directory, removes all object files and shared libs -->
46	<target name="clean">
47		<delete includeemptydirs="true" quiet="true">
48			<fileset dir="${buildDir}"/>
49			<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
50		</delete>
51	</target>
52
53	<target name="precompile">
54		<condition property="compiler-found">
55			<and>
56				<or>
57					<!-- Include both b/c Windows might be either -->
58					<available file="${g++}" filepath="${env.PATH}"/>
59					<available file="${g++}" filepath="${env.Path}"/>
60				</or>
61				<or>
62					<!-- Include both b/c Windows might be either -->
63					<available file="${gcc}" filepath="${env.PATH}"/>
64					<available file="${gcc}" filepath="${env.Path}"/>
65				</or>
66			</and>
67		</condition>
68		<condition property="has-compiler">
69			<equals arg1="${compiler-found}" arg2="true"/>
70		</condition>
71
72	</target>
73
74	<target name="create-build-dir" depends="precompile" if="has-compiler">
75		<!-- FIXME this is pretty nasty :/ -->
76		<copy todir="${buildDir}">
77			<fileset refid="g++-files"/>
78			<fileset refid="gcc-files"/>
79		</copy>
80		<delete>
81			<fileset dir="${buildDir}">
82				<include name="*"/>
83				<exclude name="*.o"/>
84			</fileset>
85		</delete>
86	</target>
87
88	<!-- compiles all C and C++ files to object files in the build directory -->
89	<target name="compile" depends="create-build-dir" if="has-compiler">
90		<mkdir dir="${buildDir}"/>
91		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
92			<arg line="${g++-opts}"/>
93			<arg value="-Ijni-headers"/>
94			<arg value="-Ijni-headers/${jniPlatform}"/>
95			<arg value="-I."/>
96						<arg value="-Isrc/bullet/"/>
97			<arg value="-Isrc/custom/"/>
98			<arg value="-Isrc/extras/Serialize/"/>
99
100			<srcfile/>
101			<arg value="-o"/>
102			<targetfile/>
103			<fileset refid="g++-files"/>
104			<compositemapper>
105				<mapper type="glob" from="*.cpp" to="*.o"/>
106				<mapper type="glob" from="*.mm" to="*.o"/>
107			</compositemapper>
108		</apply>
109		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
110			<arg line="${gcc-opts}"/>
111			<arg value="-Ijni-headers"/>
112			<arg value="-Ijni-headers/${jniPlatform}"/>
113			<arg value="-I."/>
114						<arg value="-Isrc/bullet/"/>
115			<arg value="-Isrc/custom/"/>
116			<arg value="-Isrc/extras/Serialize/"/>
117
118			<srcfile/>
119			<arg value="-o"/>
120			<targetfile/>
121			<fileset refid="gcc-files"/>
122			<compositemapper>
123				<mapper type="glob" from="*.c" to="*.o"/>
124				<mapper type="glob" from="*.m" to="*.o"/>
125			</compositemapper>
126		</apply>
127	</target>
128
129	<!-- links the shared library based on the previously compiled object files -->
130	<target name="link" depends="compile" if="has-compiler">
131		<fileset dir="${buildDir}" id="objFileSet">
132			<patternset>
133				<include name="**/*.o" />
134			</patternset>
135		</fileset>
136		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
137		<mkdir dir="${libsDir}" />
138		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
139			<arg line="${linker-opts}" />
140			<arg value="-o" />
141			<arg path="${libsDir}/${libName}" />
142			<arg line="${objFiles}"/>
143			<arg line="${libraries}" />
144		</exec>
145	</target>
146
147	<target name="postcompile" depends="link">
148
149	</target>
150</project>
151