Home | History | Annotate | Download | only in jni
      1 <project name="gdx-IOS-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/native/ios32" />
      6 	<!-- output directory for the shared library -->
      7 	<property name="libsDir" value="../libs/ios32" />
      8 	<!-- the name of the shared library -->
      9 	<property name="libName" value="libgdx.a"/>
     10 	<!-- the jni header jniPlatform to use -->
     11 	<property name="jniPlatform" value="mac"/>
     12 	<!-- the compilerPrefix for the C & C++ compilers -->
     13 	<property name="compilerPrefix" value=""/>		
     14 	<property name="iphoneos-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/"/>	
     15 	<property name="iphonesimulator-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk"/>		
     16 	<property name="tvos-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/"/>	
     17 	<property name="tvossimulator-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.2.sdk"/>
     18 	
     19 	
     20 	<!-- define gcc compiler, options and files to compile -->
     21 	<property name="gcc" value="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"/>	
     22 	<property name="gcc-opts" value="-c -Wall -O2"/>
     23 	<fileset id="gcc-files" dir="./">
     24 		<exclude name="target/"/>		
     25 				<include name="memcpy_wrap.c"/>
     26 		<include name="**/*.c"/>
     27 
     28 		
     29 	</fileset>
     30 	
     31 	<!-- define g++ compiler, options and files to compile -->
     32 	<property name="g++" value="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"/>
     33 	<property name="g++-opts" value="-c -Wall -O2"/>
     34 	<fileset id="g++-files" dir="./">
     35 		<exclude name="target/"/>
     36 				<include name="**/*.cpp"/>
     37 
     38 				<exclude name="android/**"/>
     39 
     40 	</fileset>
     41 
     42 	<!-- define linker and options -->
     43 	<property name="linker" value="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"/>
     44 	<property name="linker-opts" value="rcs"/>
     45 	<property name="libraries" value=""/>
     46 	
     47 	<!-- cleans the build directory, removes all object files and shared libs -->
     48 	<target name="clean">
     49 		<delete includeemptydirs="true" quiet="true">
     50 			<fileset dir="${buildDir}"/>
     51 			<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
     52 		</delete>
     53 	</target>
     54 	
     55 	<target name="clean-objfiles">
     56 		<delete>
     57 			<fileset dir="${buildDir}">
     58 				<include name="**/*.o"/>
     59 			</fileset>
     60 		</delete>
     61 	</target>
     62 	
     63 	<target name="create-build-dir">
     64 		<!-- FIXME this is pretty nasty :/ -->
     65 		<copy todir="${buildDir}">
     66 			<fileset refid="g++-files"/>
     67 			<fileset refid="gcc-files"/>
     68 		</copy>
     69 		<delete>
     70 			<fileset dir="${buildDir}">
     71 				<include name="*"/>
     72 				<exclude name="*.o"/>
     73 			</fileset>
     74 		</delete>
     75 	</target>		
     76 
     77 	<!-- compiles all C and C++ files to object files in the build directory, for 386 builds-->
     78 	<target name="compile-386" depends="clean,create-build-dir">
     79 		<mkdir dir="${buildDir}"/>
     80 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
     81 			<arg line="-isysroot ${iphonesimulator-sdk} -arch i386 -miphoneos-version-min=6.0 ${g++-opts}"/>
     82 			<arg value="-Ijni-headers"/>
     83 			<arg value="-Ijni-headers/${jniPlatform}"/>
     84 			<arg value="-I."/>
     85 						<arg value="-Iiosgl"/>
     86 
     87 			<srcfile/>
     88 			<arg value="-o"/>
     89 			<targetfile/>
     90 			<fileset refid="g++-files"/>
     91 			<compositemapper>
     92 				<mapper type="glob" from="*.cpp" to="*.o"/>
     93 				<mapper type="glob" from="*.mm" to="*.o"/>
     94 			</compositemapper>
     95 		</apply>
     96 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
     97 			<arg line="-isysroot ${iphonesimulator-sdk} -arch i386 -miphoneos-version-min=6.0 ${gcc-opts}"/>
     98 			<arg value="-Ijni-headers"/>
     99 			<arg value="-Ijni-headers/${jniPlatform}"/>
    100 			<arg value="-I."/>
    101 						<arg value="-Iiosgl"/>
    102 
    103 			<srcfile/>
    104 			<arg value="-o"/>
    105 			<targetfile/>
    106 			<fileset refid="gcc-files"/>
    107 			<compositemapper>
    108 				<mapper type="glob" from="*.c" to="*.o"/>
    109 			</compositemapper>
    110 		</apply>
    111 	</target>	
    112 
    113 	<!-- links the shared library based on the previously compiled object files -->
    114 	<target name="link-386" depends="compile-386">
    115 		<fileset dir="${buildDir}" id="objFileSet">
    116 			<patternset>
    117 				<include name="**/*.o" />
    118 			</patternset>
    119 		</fileset>
    120 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    121 		<mkdir dir="${libsDir}" />
    122 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    123 			<arg line="${linker-opts}" />
    124 			<arg path="${libsDir}/${libName}.386" />
    125 			<arg line="${objFiles}"/>
    126 			<arg line="${libraries}" />
    127 		</exec>
    128 	</target>
    129 	
    130 	<!-- compiles all C and C++ files to object files in the build directory, for x86_64 builds-->
    131 	<target name="compile-x86_64" depends="create-build-dir">
    132 		<mkdir dir="${buildDir}"/>
    133 		<antcall target="clean-objfiles"/>
    134 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
    135 			<arg line="-isysroot ${iphonesimulator-sdk} -arch x86_64 -miphoneos-version-min=6.0 ${g++-opts}"/>
    136 			<arg value="-Ijni-headers"/>
    137 			<arg value="-Ijni-headers/${jniPlatform}"/>
    138 			<arg value="-I."/>
    139 						<arg value="-Iiosgl"/>
    140 
    141 			<srcfile/>
    142 			<arg value="-o"/>
    143 			<targetfile/>
    144 			<fileset refid="g++-files"/>
    145 			<compositemapper>
    146 				<mapper type="glob" from="*.cpp" to="*.o"/>
    147 				<mapper type="glob" from="*.mm" to="*.o"/>
    148 			</compositemapper>
    149 		</apply>
    150 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    151 			<arg line="-isysroot ${iphonesimulator-sdk} -arch x86_64 -miphoneos-version-min=6.0 ${gcc-opts}"/>
    152 			<arg value="-Ijni-headers"/>
    153 			<arg value="-Ijni-headers/${jniPlatform}"/>
    154 			<arg value="-I."/>
    155 						<arg value="-Iiosgl"/>
    156 
    157 			<srcfile/>
    158 			<arg value="-o"/>
    159 			<targetfile/>
    160 			<fileset refid="gcc-files"/>
    161 			<compositemapper>
    162 				<mapper type="glob" from="*.c" to="*.o"/>
    163 			</compositemapper>
    164 		</apply>
    165 	</target>	
    166 
    167 	<!-- links the shared library based on the previously compiled object files -->
    168 	<target name="link-x86_64" depends="compile-x86_64">
    169 		<fileset dir="${buildDir}" id="objFileSet">
    170 			<patternset>
    171 				<include name="**/*.o" />
    172 			</patternset>
    173 		</fileset>
    174 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    175 		<mkdir dir="${libsDir}" />
    176 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    177 			<arg line="${linker-opts}" />
    178 			<arg path="${libsDir}/${libName}.x86_64" />
    179 			<arg line="${objFiles}"/>
    180 			<arg line="${libraries}" />
    181 		</exec>
    182 	</target>
    183 	
    184 	<!-- compiles all C and C++ files to object files in the build directory, for armv7 builds-->
    185 	<target name="compile-arm" depends="create-build-dir">
    186 		<mkdir dir="${buildDir}"/>
    187 		<antcall target="clean-objfiles"/>
    188 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
    189 			<arg line="-isysroot ${iphoneos-sdk} -arch armv7 -miphoneos-version-min=6.0 -fembed-bitcode ${g++-opts}"/>
    190 			<arg value="-Ijni-headers"/>
    191 			<arg value="-Ijni-headers/${jniPlatform}"/>
    192 			<arg value="-I."/>
    193 						<arg value="-Iiosgl"/>
    194 
    195 			<srcfile/>
    196 			<arg value="-o"/>
    197 			<targetfile/>
    198 			<fileset refid="g++-files"/>
    199 			<compositemapper>
    200 				<mapper type="glob" from="*.cpp" to="*.o"/>
    201 				<mapper type="glob" from="*.mm" to="*.o"/>
    202 			</compositemapper>
    203 		</apply>
    204 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    205 			<arg line="-isysroot ${iphoneos-sdk} -arch armv7 -miphoneos-version-min=6.0 -fembed-bitcode ${gcc-opts}"/>
    206 			<arg value="-Ijni-headers"/>
    207 			<arg value="-Ijni-headers/${jniPlatform}"/>
    208 			<arg value="-I."/>
    209 						<arg value="-Iiosgl"/>
    210 
    211 			<srcfile/>
    212 			<arg value="-o"/>
    213 			<targetfile/>
    214 			<fileset refid="gcc-files"/>
    215 			<compositemapper>
    216 				<mapper type="glob" from="*.c" to="*.o"/>
    217 			</compositemapper>
    218 		</apply>
    219 	</target>	
    220 
    221 	<!-- links the shared library based on the previously compiled object files -->
    222 	<target name="link-arm" depends="compile-arm">
    223 		<fileset dir="${buildDir}" id="objFileSet">
    224 			<patternset>
    225 				<include name="**/*.o" />
    226 			</patternset>
    227 		</fileset>
    228 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    229 		<mkdir dir="${libsDir}" />
    230 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    231 			<arg line="${linker-opts}" />
    232 			<arg path="${libsDir}/${libName}.armv7" />
    233 			<arg line="${objFiles}"/>
    234 			<arg line="${libraries}" />
    235 		</exec>
    236 	</target>
    237 	
    238 	<!-- compiles all C and C++ files to object files in the build directory, for arm64 builds-->
    239 	<target name="compile-arm64" depends="create-build-dir,clean-objfiles">
    240 		<mkdir dir="${buildDir}"/>
    241 		<antcall target="clean-objfiles"/>
    242 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
    243 			<arg line="-isysroot ${iphoneos-sdk} -arch arm64 -miphoneos-version-min=6.0 -fembed-bitcode ${g++-opts}"/>
    244 			<arg value="-Ijni-headers"/>
    245 			<arg value="-Ijni-headers/${jniPlatform}"/>
    246 			<arg value="-I."/>
    247 						<arg value="-Iiosgl"/>
    248 
    249 			<srcfile/>
    250 			<arg value="-o"/>
    251 			<targetfile/>
    252 			<fileset refid="g++-files"/>
    253 			<compositemapper>
    254 				<mapper type="glob" from="*.cpp" to="*.o"/>
    255 				<mapper type="glob" from="*.mm" to="*.o"/>
    256 			</compositemapper>
    257 		</apply>
    258 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    259 			<arg line="-isysroot ${iphoneos-sdk} -arch arm64 -miphoneos-version-min=6.0 -fembed-bitcode ${gcc-opts}"/>
    260 			<arg value="-Ijni-headers"/>
    261 			<arg value="-Ijni-headers/${jniPlatform}"/>
    262 			<arg value="-I."/>
    263 						<arg value="-Iiosgl"/>
    264 
    265 			<srcfile/>
    266 			<arg value="-o"/>
    267 			<targetfile/>
    268 			<fileset refid="gcc-files"/>
    269 			<compositemapper>
    270 				<mapper type="glob" from="*.c" to="*.o"/>
    271 			</compositemapper>
    272 		</apply>
    273 	</target>	
    274 
    275 	<!-- links the shared library based on the previously compiled object files -->
    276 	<target name="link-arm64" depends="compile-arm64">
    277 		<fileset dir="${buildDir}" id="objFileSet">
    278 			<patternset>
    279 				<include name="**/*.o" />
    280 			</patternset>
    281 		</fileset>
    282 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    283 		<mkdir dir="${libsDir}" />
    284 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    285 			<arg line="${linker-opts}" />
    286 			<arg path="${libsDir}/${libName}.arm64" />
    287 			<arg line="${objFiles}"/>
    288 			<arg line="${libraries}" />
    289 		</exec>
    290 	</target>
    291 	
    292 	<!-- compiles all C and C++ files to object files in the build directory, for tvOS x86_64 builds-->
    293 	<target name="compile-tvos-x86_64" depends="create-build-dir">
    294 		<mkdir dir="${buildDir}"/>
    295 		<antcall target="clean-objfiles"/>
    296 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
    297 			<arg line="-isysroot ${tvossimulator-sdk} -arch x86_64 -mtvos-version-min=9.0 ${g++-opts}"/>
    298 			<arg value="-Ijni-headers"/>
    299 			<arg value="-Ijni-headers/${jniPlatform}"/>
    300 			<arg value="-I."/>
    301 						<arg value="-Iiosgl"/>
    302 
    303 			<srcfile/>
    304 			<arg value="-o"/>
    305 			<targetfile/>
    306 			<fileset refid="g++-files"/>
    307 			<compositemapper>
    308 				<mapper type="glob" from="*.cpp" to="*.o"/>
    309 				<mapper type="glob" from="*.mm" to="*.o"/>
    310 			</compositemapper>
    311 		</apply>
    312 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    313 			<arg line="-isysroot ${tvossimulator-sdk} -arch x86_64 -mtvos-version-min=9.0 ${gcc-opts}"/>
    314 			<arg value="-Ijni-headers"/>
    315 			<arg value="-Ijni-headers/${jniPlatform}"/>
    316 			<arg value="-I."/>
    317 						<arg value="-Iiosgl"/>
    318 
    319 			<srcfile/>
    320 			<arg value="-o"/>
    321 			<targetfile/>
    322 			<fileset refid="gcc-files"/>
    323 			<compositemapper>
    324 				<mapper type="glob" from="*.c" to="*.o"/>
    325 			</compositemapper>
    326 		</apply>
    327 	</target>	
    328 
    329 	<!-- links the shared library based on the previously compiled object files -->
    330 	<target name="link-tvos-x86_64" depends="compile-tvos-x86_64">
    331 		<fileset dir="${buildDir}" id="objFileSet">
    332 			<patternset>
    333 				<include name="**/*.o" />
    334 			</patternset>
    335 		</fileset>
    336 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    337 		<mkdir dir="${libsDir}" />
    338 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    339 			<arg line="${linker-opts}" />
    340 			<arg path="${libsDir}/${libName}.tvos.x86_64" />
    341 			<arg line="${objFiles}"/>
    342 			<arg line="${libraries}" />
    343 		</exec>
    344 	</target>
    345 	
    346 	<!-- compiles all C and C++ files to object files in the build directory, for tvOS arm64 builds-->
    347 	<target name="compile-tvos-arm64" depends="create-build-dir,clean-objfiles">
    348 		<mkdir dir="${buildDir}"/>
    349 		<antcall target="clean-objfiles"/>
    350 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
    351 			<arg line="-isysroot ${tvos-sdk} -arch arm64 -mtvos-version-min=9.0 -fembed-bitcode ${g++-opts}"/>
    352 			<arg value="-Ijni-headers"/>
    353 			<arg value="-Ijni-headers/${jniPlatform}"/>
    354 			<arg value="-I."/>
    355 						<arg value="-Iiosgl"/>
    356 
    357 			<srcfile/>
    358 			<arg value="-o"/>
    359 			<targetfile/>
    360 			<fileset refid="g++-files"/>
    361 			<compositemapper>
    362 				<mapper type="glob" from="*.cpp" to="*.o"/>
    363 				<mapper type="glob" from="*.mm" to="*.o"/>
    364 			</compositemapper>
    365 		</apply>
    366 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    367 			<arg line="-isysroot ${tvos-sdk} -arch arm64 -mtvos-version-min=9.0 -fembed-bitcode ${gcc-opts}"/>
    368 			<arg value="-Ijni-headers"/>
    369 			<arg value="-Ijni-headers/${jniPlatform}"/>
    370 			<arg value="-I."/>
    371 						<arg value="-Iiosgl"/>
    372 
    373 			<srcfile/>
    374 			<arg value="-o"/>
    375 			<targetfile/>
    376 			<fileset refid="gcc-files"/>
    377 			<compositemapper>
    378 				<mapper type="glob" from="*.c" to="*.o"/>
    379 			</compositemapper>
    380 		</apply>
    381 	</target>	
    382 
    383 	<!-- links the shared library based on the previously compiled object files -->
    384 	<target name="link-tvos-arm64" depends="compile-tvos-arm64">
    385 		<fileset dir="${buildDir}" id="objFileSet">
    386 			<patternset>
    387 				<include name="**/*.o" />
    388 			</patternset>
    389 		</fileset>
    390 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    391 		<mkdir dir="${libsDir}" />
    392 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    393 			<arg line="${linker-opts}" />
    394 			<arg path="${libsDir}/${libName}.tvos.arm64" />
    395 			<arg line="${objFiles}"/>
    396 			<arg line="${libraries}" />
    397 		</exec>
    398 	</target>
    399 
    400 	<target name="link-fat">
    401 		<exec executable="lipo" failonerror="true" dir="${libsDir}">
    402 			<arg line="-create -output ${libName} ${libName}.386 ${libName}.x86_64 ${libName}.armv7 ${libName}.arm64"/>
    403 		</exec>
    404 		<exec executable="lipo" failonerror="true" dir="${libsDir}">
    405 			<arg line="-create -output ${libName}.tvos ${libName}.tvos.x86_64 ${libName}.tvos.arm64"/>
    406 		</exec>
    407 	</target>
    408 
    409 	<target name="postcompile" depends="link-386,link-x86_64,link-arm,link-arm64,link-tvos-x86_64,link-tvos-arm64,link-fat">
    410 		
    411 	</target>
    412 </project>
    413