build.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="build bullet natives" default="all" basedir="../../../">
  3. <!-- load cpp compiler ant task -->
  4. <taskdef resource="cpptasks.tasks" classpath="lib/antlibs/cpptasks.jar"/>
  5. <!-- load properties -->
  6. <property file="src/bullet/native/bullet.properties"/>
  7. <!-- condition for mac platform check -->
  8. <condition property="isSolaris">
  9. <os name="SunOS"/>
  10. </condition>
  11. <condition property="isMac">
  12. <and>
  13. <os family="mac" />
  14. <os family="unix" />
  15. </and>
  16. </condition>
  17. <!-- condition for windows platform check -->
  18. <condition property="isWindows">
  19. <os family="windows" />
  20. </condition>
  21. <!-- condition for linux platform check -->
  22. <condition property="isLinux">
  23. <and>
  24. <os family="unix"/>
  25. <not>
  26. <os family="mac"/>
  27. </not>
  28. <not>
  29. <os name="SunOS"/>
  30. </not>
  31. </and>
  32. </condition>
  33. <!-- condition for x86_64 check -->
  34. <condition property="isx86_64">
  35. <os arch="x86_64" />
  36. </condition>
  37. <condition property="ndk-build-name" value="ndk-build.cmd" else="ndk-build">
  38. <os family="windows" />
  39. </condition>
  40. <fileset id="lib.jars" dir="${bullet.lib.dir}">
  41. <include name="**/*.jar"/>
  42. </fileset>
  43. <fileset id="lib.jme.jars" dir="${bullet.jme.dir}">
  44. <include name="**/*.jar"/>
  45. </fileset>
  46. <pathconvert property="lib.importpath">
  47. <fileset refid="lib.jars"/>
  48. <fileset refid="lib.jme.jars"/>
  49. </pathconvert>
  50. <target name="build-bullet-natives" description="builds the native bullet library for the platform being run on" depends="-create-folders, create-native-headers, -nativelib-osx, -nativelib-windows, -nativelib-linux, -nativelib-solaris, -nativelib-android">
  51. <echo message="Updating native jME3-bullet-natives.jar"/>
  52. <zip basedir="${bullet.output.base}/jarcontent" file="${bullet.output.base}/jME3-bullet-natives.jar" compress="true"/>
  53. <zip basedir="${bullet.output.base}/android" file="${bullet.output.base}/jME3-bullet-natives-android.jar" compress="true"/>
  54. <copy file="${bullet.output.base}/jME3-bullet-natives.jar" todir="dist/opt/native-bullet/lib/"/>
  55. <copy file="${bullet.output.base}/jME3-bullet-natives-android.jar" todir="dist/opt/native-bullet/lib/"/>
  56. </target>
  57. <target name="create-native-headers" description="creates the native headers">
  58. <javah destdir="${bullet.source.dir}" classpath="${bullet.build.dir}${path.separator}${lib.importpath}" force="yes">
  59. <class name="com.jme3.bullet.PhysicsSpace"/>
  60. <class name="com.jme3.bullet.collision.PhysicsCollisionEvent"/>
  61. <class name="com.jme3.bullet.collision.PhysicsCollisionObject"/>
  62. <class name="com.jme3.bullet.objects.PhysicsCharacter"/>
  63. <class name="com.jme3.bullet.objects.PhysicsGhostObject"/>
  64. <class name="com.jme3.bullet.objects.PhysicsRigidBody"/>
  65. <class name="com.jme3.bullet.objects.PhysicsVehicle"/>
  66. <class name="com.jme3.bullet.objects.VehicleWheel"/>
  67. <class name="com.jme3.bullet.objects.infos.RigidBodyMotionState"/>
  68. <class name="com.jme3.bullet.collision.shapes.CollisionShape"/>
  69. <class name="com.jme3.bullet.collision.shapes.BoxCollisionShape"/>
  70. <class name="com.jme3.bullet.collision.shapes.CapsuleCollisionShape"/>
  71. <class name="com.jme3.bullet.collision.shapes.CompoundCollisionShape"/>
  72. <class name="com.jme3.bullet.collision.shapes.ConeCollisionShape"/>
  73. <class name="com.jme3.bullet.collision.shapes.CylinderCollisionShape"/>
  74. <class name="com.jme3.bullet.collision.shapes.GImpactCollisionShape"/>
  75. <class name="com.jme3.bullet.collision.shapes.HeightfieldCollisionShape"/>
  76. <class name="com.jme3.bullet.collision.shapes.HullCollisionShape"/>
  77. <class name="com.jme3.bullet.collision.shapes.MeshCollisionShape"/>
  78. <class name="com.jme3.bullet.collision.shapes.PlaneCollisionShape"/>
  79. <class name="com.jme3.bullet.collision.shapes.SimplexCollisionShape"/>
  80. <class name="com.jme3.bullet.collision.shapes.SphereCollisionShape"/>
  81. <class name="com.jme3.bullet.joints.PhysicsJoint"/>
  82. <class name="com.jme3.bullet.joints.ConeJoint"/>
  83. <class name="com.jme3.bullet.joints.HingeJoint"/>
  84. <class name="com.jme3.bullet.joints.Point2PointJoint"/>
  85. <class name="com.jme3.bullet.joints.SixDofJoint"/>
  86. <class name="com.jme3.bullet.joints.SixDofSpringJoint"/>
  87. <class name="com.jme3.bullet.joints.SliderJoint"/>
  88. <class name="com.jme3.bullet.joints.motors.RotationalLimitMotor"/>
  89. <class name="com.jme3.bullet.joints.motors.TranslationalLimitMotor"/>
  90. <class name="com.jme3.bullet.util.NativeMeshUtil"/>
  91. <class name="com.jme3.bullet.util.DebugShapeFactory"/>
  92. </javah>
  93. </target>
  94. <!-- compares the API of native bullet and java version-->
  95. <target name="bullet-api-diff">
  96. <echo message="Comparing bullet and jbullet API"/>
  97. <property name="dependencyfinder.home" value="lib/antlibs/depfinder"/>
  98. <path id="dependencyfinder">
  99. <pathelement location="${dependencyfinder.home}/classes"/>
  100. <pathelement location="${dependencyfinder.home}/lib/DependencyFinder.jar"/>
  101. <pathelement location="${dependencyfinder.home}/lib/jakarta-oro.jar"/>
  102. <pathelement location="${dependencyfinder.home}/lib/log4j.jar"/>
  103. <pathelement location="${dependencyfinder.home}/lib/guava.jar"/>
  104. </path>
  105. <taskdef resource="dependencyfindertasks.properties">
  106. <classpath refid="dependencyfinder"/>
  107. </taskdef>
  108. <jarjardiff destfile="bullet-api-diff.xml"
  109. name="jMonkeyEngine3 Bullet Physics API Comparison"
  110. oldlabel="Java Version"
  111. newlabel="Native Version"
  112. level="incompatible">
  113. <old>
  114. <pathelement location="build/jME3-jbullet.jar"/>
  115. </old>
  116. <new>
  117. <pathelement location="build/jME3-bullet.jar"/>
  118. </new>
  119. </jarjardiff>
  120. <xslt style="${dependencyfinder.home}/etc/DiffToHTML.xsl"
  121. in="bullet-api-diff.xml"
  122. out="bullet-api-diff.html" force="true"/>
  123. <delete file="bullet-api-diff.xml"/>
  124. </target>
  125. <target name="-create-folders" description="creates the native headers">
  126. <mkdir dir="${bullet.source.dir}"/>
  127. <mkdir dir="${bullet.build.dir}"/>
  128. <mkdir dir="${bullet.output.dir}"/>
  129. </target>
  130. <target name="-nativelib-osx" if="isMac">
  131. <echo message="Building MacOSX version of native bullet"/>
  132. <mkdir dir="${bullet.output.dir}/macosx"/>
  133. <cc name="${bullet.osx.compiler}" warnings="none" debug="${bullet.compile.debug}" link="shared" outfile="${bullet.output.dir}/macosx/${bullet.library.name}" objdir="${bullet.build.dir}">
  134. <fileset dir="${bullet.source.dir}">
  135. <include name="*.cpp">
  136. </include>
  137. </fileset>
  138. <includepath path="${bullet.osx.java.include}"/>
  139. <includepath path="${bullet.bullet.include}"/>
  140. <compilerarg value="-syslibroot ${bullet.osx.syslibroot}"/>
  141. <!--compilerarg value="-arch"/>
  142. <compilerarg value="ppc"/-->
  143. <compilerarg value="-arch"/>
  144. <compilerarg value="i386"/>
  145. <compilerarg value="-arch"/>
  146. <compilerarg value="x86_64"/>
  147. <linker name="${bullet.osx.compiler}">
  148. <!--libset dir="${bullet.folder}/src/BulletSoftBody" libs="BulletSoftBody"/-->
  149. <libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/>
  150. <libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>
  151. <libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>
  152. <libset dir="${bullet.folder}/src/LinearMath" libs="LinearMath"/>
  153. <!--linkerarg value="-arch"/>
  154. <linkerarg value="ppc"/-->
  155. <linkerarg value="-arch"/>
  156. <linkerarg value="i386"/>
  157. <linkerarg value="-arch"/>
  158. <linkerarg value="x86_64"/>
  159. </linker>
  160. </cc>
  161. <move file="${bullet.output.dir}/macosx/lib${bullet.library.name}.dylib" tofile="${bullet.output.dir}/macosx/lib${bullet.library.name}.jnilib" failonerror="true" verbose="true"/>
  162. <delete file="${bullet.output.dir}/macosx/history.xml"/>
  163. </target>
  164. <target name="-nativelib-linux" if="isLinux">
  165. <echo message="Building Linux version of native bullet"/>
  166. <mkdir dir="${bullet.output.dir}/linux"/>
  167. <cc name="${bullet.linux.compiler}" warnings="severe" debug="${bullet.compile.debug}" link="shared" outfile="${bullet.output.dir}/linux/${bullet.library.name}" objdir="${bullet.build.dir}">
  168. <fileset dir="${bullet.source.dir}">
  169. <include name="*.cpp">
  170. </include>
  171. </fileset>
  172. <includepath path="${bullet.java.include}"/>
  173. <includepath path="${bullet.java.include}/linux"/>
  174. <includepath path="${bullet.bullet.include}"/>
  175. <!--compilerarg value="-m32"/-->
  176. <!--compilerarg value="-static-libgcc"/>
  177. <compilerarg value="-fPIC"/-->
  178. <linker name="${bullet.linux.compiler}">
  179. <!-- linkerarg value="-static-libgcc"/ -->
  180. <libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/>
  181. <libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>
  182. <libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>
  183. <libset dir="${bullet.folder}/src/LinearMath" libs="LinearMath"/>
  184. </linker>
  185. </cc>
  186. <delete file="${bullet.output.dir}/linux/history.xml"/>
  187. </target>
  188. <target name="-nativelib-solaris" if="isSolaris">
  189. <echo message="Building Solaris version of native bullet"/>
  190. <mkdir dir="${bullet.output.dir}/linux"/>
  191. <cc name="${bullet.solaris.compiler}" warnings="severe" debug="${bullet.compile.debug}" link="shared" outfile="${bullet.output.dir}/solaris/${bullet.library.name}" objdir="${bullet.build.dir}">
  192. <fileset dir="${bullet.source.dir}">
  193. <include name="*.cpp">
  194. </include>
  195. </fileset>
  196. <includepath path="${bullet.java.include}"/>
  197. <includepath path="${bullet.java.include}/solaris"/>
  198. <includepath path="${bullet.bullet.include}"/>
  199. <!--compilerarg value="-m32"/-->
  200. <compilerarg value="-m32"/>
  201. <compilerarg value="-fno-strict-aliasing"/>
  202. <compilerarg value="-pthread"/>
  203. <compilerarg value="-fPIC"/>
  204. <compilerarg value="-D_REENTRANT"/>
  205. <compilerarg value="-static-libstdc++"/>
  206. <compilerarg value="-static-libgcc"/>
  207. <compilerarg value="-D_REENTRANT"/>
  208. <linker name="${bullet.solaris.compiler}">
  209. <linkerarg value="-R/usr/sfw/lib"/>
  210. <libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/>
  211. <libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>
  212. <libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>
  213. <libset dir="${bullet.folder}/src/LinearMath" libs="LinearMath"/>
  214. </linker>
  215. </cc>
  216. <delete file="${bullet.output.dir}/solaris/history.xml"/>
  217. </target>
  218. <target name="-nativelib-windows" if="isWindows">
  219. <echo message="Building Windows version of native bullet"/>
  220. <mkdir dir="${bullet.output.dir}/windows"/>
  221. <cc multithreaded="" name="${bullet.windows.compiler}" warnings="none" debug="${bullet.compile.debug}" outtype="shared" outfile="${bullet.output.dir}/windows/${bullet.library.name}" objdir="${bullet.build.dir}">
  222. <fileset dir="${bullet.source.dir}">
  223. <include name="*.cpp">
  224. </include>
  225. </fileset>
  226. <includepath path="${bullet.java.include}"/>
  227. <includepath path="${bullet.java.include}/win32"/>
  228. <includepath path="${bullet.bullet.include}"/>
  229. <!--compilerarg value="-m32"/-->
  230. <linker name="${bullet.windows.compiler}" debug="${bullet.compile.debug}" >
  231. <linkerarg value="-o${bullet.library.name}.dll" />
  232. <linkerarg value="--kill-at" />
  233. <linkerarg value="-static"/>
  234. <libset dir="${bullet.folder}/lib" libs="BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath"/>
  235. </linker>
  236. </cc>
  237. <delete file="${bullet.output.dir}/windows/history.xml"/>
  238. </target>
  239. <target name="-nativelib-android" depends="-check-android-ndk" if="haveAndoidNdk">
  240. <!-- delete previous android jni, libs, and obj subdirectories for a clean start -->
  241. <delete dir="build/bullet-android/jni" failonerror="false"/>
  242. <delete dir="build/bullet-android/libs" failonerror="false"/>
  243. <delete dir="build/bullet-android/obj" failonerror="false"/>
  244. <!-- create the android subdirectory in jarcontent for the libbulletjme.so shared library -->
  245. <mkdir dir="${bullet.output.dir}/../../android"/>
  246. <!-- create the jni subdirectory -->
  247. <mkdir dir="build/bullet-android/jni" />
  248. <!-- copy Android.mk and Application.mk files into jni directory -->
  249. <copy file="${bullet.source.dir}/android/Android.mk" todir="build/bullet-android/jni" verbose="true"/>
  250. <copy file="${bullet.source.dir}/android/Application.mk" todir="build/bullet-android/jni" verbose="true"/>
  251. <!-- copy edited version of jmePhysicsSpace to remove NDK compile error -->
  252. <copy file="${bullet.source.dir}/android/jmePhysicsSpace.cpp" todir="build/bullet-android/jni" verbose="true"/>
  253. <!-- copy jME3 Native Bullet files into jni directory -->
  254. <copy todir="build/bullet-android/jni" verbose="true" flatten="false">
  255. <fileset dir="${bullet.source.dir}">
  256. <include name="*.cpp" />
  257. <include name="*.h" />
  258. <!-- skip jmePhysicsSpace (use edited one) to remove NDK compile error -->
  259. <exclude name="jmePhysicsSpace.cpp" />
  260. </fileset>
  261. </copy>
  262. <!-- copy Bullet-2.79 files into jni directory -->
  263. <copy todir="build/bullet-android/jni" verbose="true" flatten="false">
  264. <fileset dir="${bullet.bullet.include}">
  265. <include name="**/*.cpp"/>
  266. <include name="**/*.h"/>
  267. <include name="**/*.cl"/>
  268. </fileset>
  269. </copy>
  270. <exec executable="${ndk.dir}/${ndk-build-name}" failonerror="true" >
  271. <arg line="-C build/bullet-android/"/>
  272. </exec>
  273. <!-- copy resulting library directories to jarcontent directory -->
  274. <copy todir="${bullet.output.dir}/../../android" verbose="true" flatten="false">
  275. <fileset dir="build/bullet-android/libs">
  276. <include name="**/*.*"/>
  277. <include name="**/*.*"/>
  278. <!--exclude name="**/x86/*.*"/-->
  279. </fileset>
  280. </copy>
  281. </target>
  282. <target name="-check-android-ndk">
  283. <available file="${ndk.dir}/${ndk-build-name}" property="haveAndoidNdk"/>
  284. </target>
  285. </project>