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