<?xml version="1.0" encoding="UTF-8"?>
<project name= "build bullet natives" default= "all" basedir= "../" >
<!-- load cpp compiler ant task -->
<taskdef resource= "cpptasks.tasks" classpath= "lib/antlibs/cpptasks.jar" />
<!-- load properties -->
<property file= "nbproject/bullet-native.properties" />
<!-- condition for mac platform check -->
<condition property= "isSolaris" >
<os name= "SunOS" />
</condition>
<condition property= "isMac" >
<and >
<os family= "mac" />
<os family= "unix" />
</and>
</condition>
<!-- condition for windows platform check -->
<condition property= "isWindows" >
<os family= "windows" />
</condition>
<!-- condition for linux platform check -->
<condition property= "isLinux" >
<and >
<os family= "unix" />
<not >
<os family= "mac" />
</not>
<not >
<os name= "SunOS" />
</not>
</and>
</condition>
<!-- condition for x86_64 check -->
<condition property= "isx86_64" >
<os arch= "x86_64" />
</condition>
<condition property= "ndk-build-name" value= "ndk-build.cmd" else= "ndk-build" >
<os family= "windows" />
</condition>
<fileset id= "lib.jars" dir= "${bullet.lib.dir}" >
<include name= "**/*.jar" />
</fileset>
<fileset id= "lib.jme.jars" dir= "${bullet.jme.dir}" >
<include name= "**/*.jar" />
</fileset>
<pathconvert property= "lib.importpath" >
<fileset refid= "lib.jars" />
<fileset refid= "lib.jme.jars" />
</pathconvert>
<target name= "build-bullet-natives" description= "builds the native bullet library for the platform being run on and for android if NDK available" depends= "create-native-headers, compile-native-library, compile-android" >
<echo message= "Updating native jME3-bullet-natives.jar" />
<zip basedir= "${bullet.output.base}/jarcontent" file= "${bullet.output.base}/jME3-bullet-natives.jar" compress= "true" />
<zip basedir= "${bullet.output.base}/android" file= "${bullet.output.base}/jME3-bullet-natives-android.jar" compress= "true" />
<copy file= "${bullet.output.base}/jME3-bullet-natives.jar" todir= "dist/opt/native-bullet/lib/" />
<copy file= "${bullet.output.base}/jME3-bullet-natives-android.jar" todir= "dist/opt/native-bullet/lib/" />
</target>
<target name= "create-native-headers" description= "creates the native C++ headers for the java native methods" >
<javah destdir= "${bullet.source.dir}" classpath= "${bullet.build.dir}${path.separator}${lib.importpath}" >
<class name= "com.jme3.bullet.PhysicsSpace" />
<class name= "com.jme3.bullet.collision.PhysicsCollisionEvent" />
<class name= "com.jme3.bullet.collision.PhysicsCollisionObject" />
<class name= "com.jme3.bullet.objects.PhysicsCharacter" />
<class name= "com.jme3.bullet.objects.PhysicsGhostObject" />
<class name= "com.jme3.bullet.objects.PhysicsRigidBody" />
<class name= "com.jme3.bullet.objects.PhysicsVehicle" />
<class name= "com.jme3.bullet.objects.VehicleWheel" />
<class name= "com.jme3.bullet.objects.infos.RigidBodyMotionState" />
<class name= "com.jme3.bullet.collision.shapes.CollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.BoxCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.CapsuleCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.CompoundCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.ConeCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.CylinderCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.GImpactCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.HeightfieldCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.HullCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.MeshCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.PlaneCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.SimplexCollisionShape" />
<class name= "com.jme3.bullet.collision.shapes.SphereCollisionShape" />
<class name= "com.jme3.bullet.joints.PhysicsJoint" />
<class name= "com.jme3.bullet.joints.ConeJoint" />
<class name= "com.jme3.bullet.joints.HingeJoint" />
<class name= "com.jme3.bullet.joints.Point2PointJoint" />
<class name= "com.jme3.bullet.joints.SixDofJoint" />
<class name= "com.jme3.bullet.joints.SixDofSpringJoint" />
<class name= "com.jme3.bullet.joints.SliderJoint" />
<class name= "com.jme3.bullet.joints.motors.RotationalLimitMotor" />
<class name= "com.jme3.bullet.joints.motors.TranslationalLimitMotor" />
<class name= "com.jme3.bullet.util.NativeMeshUtil" />
<class name= "com.jme3.bullet.util.DebugShapeFactory" />
</javah>
</target>
<!-- compares the API of native bullet and java version -->
<target name= "bullet-api-diff" description= "creates a html file showing the differences between the native and jbullet based jme3-bullet api" >
<echo message= "Comparing bullet and jbullet API" />
<property name= "dependencyfinder.home" value= "lib/antlibs/depfinder" />
<path id= "dependencyfinder" >
<pathelement location= "${dependencyfinder.home}/classes" />
<pathelement location= "${dependencyfinder.home}/lib/DependencyFinder.jar" />
<pathelement location= "${dependencyfinder.home}/lib/jakarta-oro.jar" />
<pathelement location= "${dependencyfinder.home}/lib/log4j.jar" />
<pathelement location= "${dependencyfinder.home}/lib/guava.jar" />
</path>
<taskdef resource= "dependencyfindertasks.properties" >
<classpath refid= "dependencyfinder" />
</taskdef>
<jarjardiff destfile= "bullet-api-diff.xml"
name="jMonkeyEngine3 Bullet Physics API Comparison"
oldlabel="Java Version"
newlabel="Native Version"
level="incompatible">
<old >
<pathelement location= "build/jME3-jbullet.jar" />
</old>
<new >
<pathelement location= "build/jME3-bullet.jar" />
</new>
</jarjardiff>
<xslt style= "${dependencyfinder.home}/etc/DiffToHTML.xsl"
in="bullet-api-diff.xml"
out="bullet-api-diff.html" force="true"/>
<delete file= "bullet-api-diff.xml" />
</target>
<target name= "compile-native-library" description= "compiles the native libbulletjme binary for the current platform" depends= "compile-bullet-sources, -create-folders, -nativelib-osx, -nativelib-windows, -nativelib-linux, -nativelib-linux-64, -nativelib-solaris" />
<target name= "-create-folders" description= "creates the needed folders" >
<mkdir dir= "${bullet.source.dir}" />
<mkdir dir= "${bullet.build.dir}" />
<mkdir dir= "${bullet.output.dir}" />
<mkdir dir= "build/bullet-native" />
<mkdir dir= "build/bullet-native-64" />
</target>
<target name= "-nativelib-osx" if= "isMac" >
<echo message= "Building MacOSX version of native bullet" />
<mkdir dir= "${bullet.output.dir}/macosx" />
<cc name= "${bullet.osx.compiler}" warnings= "none" debug= "${bullet.compile.debug}" link= "shared" outfile= "${bullet.output.dir}/macosx/${bullet.library.name}" objdir= "build/bullet-native" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" >
</include>
</fileset>
<includepath path= "${bullet.osx.java.include}" />
<includepath path= "${bullet.bullet.include}" />
<compilerarg value= "-syslibroot ${bullet.osx.syslibroot}" />
<!-- compilerarg value=" - arch"/>
<compilerarg value= "ppc" / - - >
<compilerarg value= "-arch" />
<compilerarg value= "i386" />
<compilerarg value= "-arch" />
<compilerarg value= "x86_64" />
<linker name= "${bullet.osx.compiler}" >
<libset dir= "build/bullet-base" libs= "BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath" />
<!-- linkerarg value=" - arch"/>
<linkerarg value= "ppc" / - - >
<linkerarg value= "-arch" />
<linkerarg value= "i386" />
<linkerarg value= "-arch" />
<linkerarg value= "x86_64" />
</linker>
</cc>
<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" />
<delete file= "${bullet.output.dir}/macosx/history.xml" />
</target>
<target name= "-nativelib-linux" if= "isLinux" >
<echo message= "Building Linux version of native bullet" />
<mkdir dir= "${bullet.output.dir}/linux" />
<cc name= "${bullet.linux.compiler}" warnings= "severe" debug= "${bullet.compile.debug}" link= "shared" outfile= "${bullet.output.dir}/linux/${bullet.library.name}" objdir= "build/bullet-native" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" >
</include>
</fileset>
<includepath path= "${bullet.java.include}" />
<includepath path= "${bullet.java.include}/linux" />
<includepath path= "${bullet.bullet.include}" />
<compilerarg value= "-m32" />
<linker name= "${bullet.linux.compiler}" >
<linkerarg value= "-m32" />
<libset dir= "build/bullet-base" libs= "BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath" />
</linker>
</cc>
<delete file= "${bullet.output.dir}/linux/history.xml" />
</target>
<target name= "-nativelib-linux-64" if= "isLinux,isx86_64" >
<echo message= "Building Linux version of native bullet" />
<mkdir dir= "${bullet.output.dir}/linux" />
<cc name= "${bullet.linux.compiler}" warnings= "severe" debug= "${bullet.compile.debug}" link= "shared" outfile= "${bullet.output.dir}/linux/${bullet.library.name}64" objdir= "build/bullet-native64" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" >
</include>
</fileset>
<includepath path= "${bullet.java.include}" />
<includepath path= "${bullet.java.include}/linux" />
<includepath path= "${bullet.bullet.include}" />
<linker name= "${bullet.linux.compiler}" >
<libset dir= "build/bullet-base-64" libs= "BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath" />
</linker>
</cc>
<delete file= "${bullet.output.dir}/linux/history.xml" />
</target>
<target name= "-nativelib-solaris" if= "isSolaris" >
<echo message= "Building Solaris version of native bullet" />
<mkdir dir= "${bullet.output.dir}/linux" />
<cc name= "${bullet.solaris.compiler}" warnings= "severe" debug= "${bullet.compile.debug}" link= "shared" outfile= "${bullet.output.dir}/solaris/${bullet.library.name}" objdir= "build/bullet-native" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" >
</include>
</fileset>
<includepath path= "${bullet.java.include}" />
<includepath path= "${bullet.java.include}/solaris" />
<includepath path= "${bullet.bullet.include}" />
<!-- compilerarg value=" - m32"/ -->
<compilerarg value= "-m32" />
<compilerarg value= "-fno-strict-aliasing" />
<compilerarg value= "-pthread" />
<compilerarg value= "-fPIC" />
<compilerarg value= "-D_REENTRANT" />
<compilerarg value= "-static-libstdc++" />
<compilerarg value= "-static-libgcc" />
<compilerarg value= "-D_REENTRANT" />
<linker name= "${bullet.solaris.compiler}" >
<linkerarg value= "-R/usr/sfw/lib" />
<libset dir= "${bullet.folder}/src/BulletMultiThreaded" libs= "BulletMultiThreaded" />
<libset dir= "${bullet.folder}/src/BulletDynamics" libs= "BulletDynamics" />
<libset dir= "${bullet.folder}/src/BulletCollision" libs= "BulletCollision" />
<libset dir= "${bullet.folder}/src/LinearMath" libs= "LinearMath" />
</linker>
</cc>
<delete file= "${bullet.output.dir}/solaris/history.xml" />
</target>
<target name= "-nativelib-windows" if= "isWindows" >
<echo message= "Building Windows version of native bullet" />
<mkdir dir= "${bullet.output.dir}/windows" />
<cc multithreaded= "" name= "${bullet.windows.compiler}" warnings= "none" debug= "${bullet.compile.debug}" outtype= "shared" outfile= "${bullet.output.dir}/windows/${bullet.library.name}" objdir= "build/bullet-native" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" >
</include>
</fileset>
<includepath path= "${bullet.java.include}" />
<includepath path= "${bullet.java.include}/win32" />
<includepath path= "${bullet.bullet.include}" />
<!-- compilerarg value=" - m32"/ -->
<linker name= "${bullet.windows.compiler}" debug= "${bullet.compile.debug}" >
<linkerarg value= "-o${bullet.library.name}.dll" />
<linkerarg value= "--kill-at" />
<linkerarg value= "-static" />
<libset dir= "${bullet.folder}/lib" libs= "BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath" />
</linker>
</cc>
<delete file= "${bullet.output.dir}/windows/history.xml" />
</target>
<target name= "compile-android" description= "compiles libbulletjme using the Android NDK" depends= "-check-android-ndk" if= "haveAndoidNdk" >
<!-- delete previous android jni, libs, and obj subdirectories for a clean start -->
<delete dir= "build/bullet-android/jni" failonerror= "false" />
<delete dir= "build/bullet-android/libs" failonerror= "false" />
<delete dir= "build/bullet-android/obj" failonerror= "false" />
<!-- create the android subdirectory in jarcontent for the libbulletjme.so shared library -->
<mkdir dir= "${bullet.output.base}/android" />
<!-- create the jni subdirectory -->
<mkdir dir= "build/bullet-android/jni" />
<!-- copy Android.mk and Application.mk files into jni directory -->
<copy file= "${bullet.source.dir}/android/Android.mk" todir= "build/bullet-android/jni" verbose= "true" />
<copy file= "${bullet.source.dir}/android/Application.mk" todir= "build/bullet-android/jni" verbose= "true" />
<!-- copy jME3 Native Bullet files into jni directory -->
<copy todir= "build/bullet-android/jni" verbose= "true" flatten= "false" >
<fileset dir= "${bullet.source.dir}" >
<include name= "*.cpp" />
<include name= "*.h" />
</fileset>
</copy>
<!-- copy Bullet - 2.79 files into jni directory -->
<copy todir= "build/bullet-android/jni" verbose= "true" flatten= "false" >
<fileset dir= "${bullet.bullet.include}" >
<include name= "**/*.cpp" />
<include name= "**/*.h" />
<include name= "**/*.cl" />
</fileset>
</copy>
<exec executable= "${ndk.dir}/${ndk-build-name}" failonerror= "true" >
<arg line= "-C build/bullet-android/" />
</exec>
<!-- copy resulting library directories to jarcontent directory -->
<copy todir= "${bullet.output.base}/android" verbose= "true" flatten= "false" >
<fileset dir= "build/bullet-android/libs" >
<include name= "**/*.*" />
<include name= "**/*.*" />
<!-- exclude name="**/x86/*.*"/ -->
</fileset>
</copy>
</target>
<target name= "-check-android-ndk" >
<available file= "${ndk.dir}/${ndk-build-name}" property= "haveAndoidNdk" />
</target>
<target name= "compile-bullet-sources" description= "downloads and compiles the bullet native library to static binaries to be included in the final libbulletjme" depends= "-get-bullet-sources, -compile-bullet-sources-windows, -compile-bullet-sources-macosx, -compile-bullet-sources-linux, -compile-bullet-sources-linux-64" />
<target name= "-get-bullet-sources" depends= "-check-bullet-sources" unless= "haveBulletSource" >
<echo > Downloading bullet source..</echo>
<get src= "${bullet.download}" dest= "../bullet.zip" />
<unzip src= "../bullet.zip" dest= "../" />
<delete file= "../bullet.zip" />
</target>
<target name= "-check-bullet-sources" >
<available file= "${bullet.folder}" property= "haveBulletSource" />
<available file= "build/bullet-base/libBulletMultiThreaded.a" property= "haveBulletLibrary" />
<available file= "build/bullet-base-64/libBulletMultiThreaded.a" property= "haveBulletLibrary64" />
</target>
<target name= "-compile-bullet-sources-windows" if= "isWindows" >
<exec executable= "${cmake.windows}" dir= "${bullet.folder}" failonerror= "true" >
<arg value= "." />
<arg value= "-DBUILD_SHARED_LIBS=OFF" />
<arg value= "-DBUILD_EXTRAS:BOOL=OFF" />
<arg value= "-DBUILD_DEMOS:BOOL=OFF" />
<arg value= "-DCMAKE_BUILD_TYPE=Release" />
<arg value= "." />
<arg value= "-G" />
<arg value= "'MinGW Makefiles'" />
</exec>
<exec executable= "${make.windows}" dir= "${bullet.folder}" />
</target>
<target name= "-compile-bullet-sources-macosx" if= "isMac" unless= "haveBulletLibrary" >
<mkdir dir= "build/bullet-base" />
<property location= "build/bullet-base" name= "build.folder.resolved" />
<exec executable= "${cmake.osx}" dir= "${bullet.folder}" failonerror= "true" >
<arg value= "-DLIBRARY_OUTPUT_PATH='${build.folder.resolved}'" />
<arg value= "-DBUILD_SHARED_LIBS=OFF" />
<arg value= "-DCMAKE_OSX_ARCHITECTURES='i386;x86_64'" />
<arg value= "-DBUILD_EXTRAS=off" />
<arg value= "-DBUILD_DEMOS=off" />
<arg value= "-DCMAKE_BUILD_TYPE=Release" />
</exec>
<exec executable= "${make.osx}" dir= "${bullet.folder}" />
</target>
<target name= "-compile-bullet-sources-linux" if= "isLinux" unless= "haveBulletLibrary" >
<mkdir dir= "build/bullet-base" />
<property location= "build/bullet-base" name= "build.folder.resolved" />
<exec executable= "${cmake.linux}" dir= "${bullet.folder}" failonerror= "true" >
<arg value= "-DLIBRARY_OUTPUT_PATH='${build.folder.resolved}'" />
<arg value= "-DBUILD_SHARED_LIBS=OFF" />
<arg value= "-DBUILD_STATIC_LIBS=ON" />
<arg value= "-DCMAKE_C_FLAGS=-fPIC" />
<arg value= "-DCMAKE_CXX_FLAGS=-fPIC" />
<arg value= "-DCMAKE_C_FLAGS=-m32" />
<arg value= "-DCMAKE_CXX_FLAGS=-m32" />
<arg value= "-DBUILD_EXTRAS=off" />
<arg value= "-DBUILD_DEMOS=off" />
<arg value= "-DCMAKE_BUILD_TYPE=Release" />
</exec>
<exec executable= "${make.linux}" dir= "${bullet.folder}" />
</target>
<target name= "-compile-bullet-sources-linux-64" if= "isLinux,isx86_64" unless= "haveBulletLibrary64" >
<mkdir dir= "build/bullet-base-64" />
<property location= "build/bullet-base-64" name= "build64.folder.resolved" />
<exec executable= "${cmake.linux}" dir= "${bullet.folder}" failonerror= "true" >
<arg value= "-DLIBRARY_OUTPUT_PATH='${build64.folder.resolved}'" />
<arg value= "-DBUILD_SHARED_LIBS=OFF" />
<arg value= "-DBUILD_STATIC_LIBS=ON" />
<arg value= "-DCMAKE_C_FLAGS=-fPIC" />
<arg value= "-DCMAKE_CXX_FLAGS=-fPIC" />
<arg value= "-DBUILD_EXTRAS=off" />
<arg value= "-DBUILD_DEMOS=off" />
<arg value= "-DCMAKE_BUILD_TYPE=Release" />
</exec>
<exec executable= "${make.linux}" dir= "${bullet.folder}" />
</target>
</project>