Home | History | Annotate | Download | only in jni
      1 <project name="gdx-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/native/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.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 		
     26 	</fileset>
     27 	
     28 	<!-- define g++ compiler, options and files to compile -->
     29 	<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
     30 	<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m32 -fPIC"/>
     31 	<fileset id="g++-files" dir="./">
     32 		<exclude name="target/"/>
     33 				<include name="**/*.cpp"/>
     34 
     35 				<exclude name="android/**"/>
     36 		<exclude name="iosgl/**"/>
     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 			
     97 			<srcfile/>
     98 			<arg value="-o"/>
     99 			<targetfile/>
    100 			<fileset refid="g++-files"/>
    101 			<compositemapper>
    102 				<mapper type="glob" from="*.cpp" to="*.o"/>
    103 				<mapper type="glob" from="*.mm" to="*.o"/>
    104 			</compositemapper>
    105 		</apply>
    106 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    107 			<arg line="${gcc-opts}"/>
    108 			<arg value="-Ijni-headers"/>
    109 			<arg value="-Ijni-headers/${jniPlatform}"/>
    110 			<arg value="-I."/>
    111 			
    112 			<srcfile/>
    113 			<arg value="-o"/>
    114 			<targetfile/>
    115 			<fileset refid="gcc-files"/>
    116 			<compositemapper>
    117 				<mapper type="glob" from="*.c" to="*.o"/>
    118 				<mapper type="glob" from="*.m" to="*.o"/>
    119 			</compositemapper>
    120 		</apply>
    121 	</target>	
    122 
    123 	<!-- links the shared library based on the previously compiled object files -->	
    124 	<target name="link" depends="compile" if="has-compiler">
    125 		<fileset dir="${buildDir}" id="objFileSet">
    126 			<patternset>
    127 				<include name="**/*.o" />
    128 			</patternset>
    129 		</fileset>
    130 		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
    131 		<mkdir dir="${libsDir}" />
    132 		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
    133 			<arg line="${linker-opts}" />
    134 			<arg value="-o" />
    135 			<arg path="${libsDir}/${libName}" />
    136 			<arg line="${objFiles}"/>
    137 			<arg line="${libraries}" />
    138 		</exec>
    139 	</target>	
    140 	
    141 	<target name="postcompile" depends="link">
    142 		
    143 	</target>
    144 </project>
    145