Home | History | Annotate | Download | only in jni
      1 <project name="gdx-controllers-desktop-MacOsX-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/macosx32" />
      6 	<!-- output directory for the shared library -->
      7 	<property name="libsDir" value="../libs/macosx32" />
      8 	<!-- the name of the shared library -->
      9 	<property name="libName" value="libgdx-controllers-desktop.dylib"/>
     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 	<!--  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 -arch i386 -DFIXED_POINT -fmessage-length=0 -fPIC -mmacosx-version-min=10.5"/>
     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 -arch i386 -DFIXED_POINT -fmessage-length=0 -fPIC -mmacosx-version-min=10.5 -x objective-c++"/>
     31 	<fileset id="g++-files" dir="./">
     32 		<exclude name="target/"/>
     33 				<include name="*.cpp"/>
     34 		<include name="ois-v1-4svn/src/*.cpp"/>
     35 		<include name="ois-v1-4svn/src/mac/*.mm"/>
     36 		<include name="ois-v1-4svn/src/mac/MacHIDManager.cpp"/>
     37 		<include name="ois-v1-4svn/src/mac/MacJoyStick.cpp"/>
     38 
     39 		
     40 	</fileset>
     41 
     42 	<!-- define linker and options -->
     43 	<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
     44 	<property name="linker-opts" value="-shared -arch i386 -mmacosx-version-min=10.5"/>
     45 	<property name="libraries" value="-framework CoreServices -framework Carbon -framework IOKit -framework Cocoa"/>
     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="precompile">
     56 		<condition property="compiler-found">
     57 			<and>
     58 				<or>
     59 					<!-- Include both b/c Windows might be either -->
     60 					<available file="${g++}" filepath="${env.PATH}"/>
     61 					<available file="${g++}" filepath="${env.Path}"/>
     62 				</or>
     63 				<or>
     64 					<!-- Include both b/c Windows might be either -->
     65 					<available file="${gcc}" filepath="${env.PATH}"/>
     66 					<available file="${gcc}" filepath="${env.Path}"/>
     67 				</or>
     68 			</and>
     69 		</condition>
     70 		<condition property="has-compiler">
     71 			<equals arg1="${compiler-found}" arg2="true"/>
     72 		</condition>
     73 		
     74 	</target>
     75 	
     76 	<target name="create-build-dir" depends="precompile" if="has-compiler">
     77 		<!-- FIXME this is pretty nasty :/ -->
     78 		<copy todir="${buildDir}">
     79 			<fileset refid="g++-files"/>
     80 			<fileset refid="gcc-files"/>
     81 		</copy>
     82 		<delete>
     83 			<fileset dir="${buildDir}">
     84 				<include name="*"/>
     85 				<exclude name="*.o"/>
     86 			</fileset>
     87 		</delete>
     88 	</target>
     89 
     90 	<!-- compiles all C and C++ files to object files in the build directory -->
     91 	<target name="compile" depends="create-build-dir" if="has-compiler">
     92 		<mkdir dir="${buildDir}"/>
     93 		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
     94 			<arg line="${g++-opts}"/>
     95 			<arg value="-Ijni-headers"/>
     96 			<arg value="-Ijni-headers/${jniPlatform}"/>
     97 			<arg value="-I."/>
     98 						<arg value="-Iois-v1-4svn/includes"/>
     99 			<arg value="-Idinput/"/>
    100 
    101 			<srcfile/>
    102 			<arg value="-o"/>
    103 			<targetfile/>
    104 			<fileset refid="g++-files"/>
    105 			<compositemapper>
    106 				<mapper type="glob" from="*.cpp" to="*.o"/>
    107 				<mapper type="glob" from="*.mm" to="*.o"/>
    108 			</compositemapper>
    109 		</apply>
    110 		<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
    111 			<arg line="${gcc-opts}"/>
    112 			<arg value="-Ijni-headers"/>
    113 			<arg value="-Ijni-headers/${jniPlatform}"/>
    114 			<arg value="-I."/>
    115 						<arg value="-Iois-v1-4svn/includes"/>
    116 			<arg value="-Idinput/"/>
    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