2
0
Эх сурвалжийг харах

- automatically download and compile bullet source for native bullet

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8855 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 жил өмнө
parent
commit
ae4ff3e45a

+ 83 - 87
engine/bullet-native-build.txt

@@ -1,16 +1,96 @@
 ***********************************
-* Build info for bulletjme       *
+* Build info for bulletjme        *
 * (c) 2011 Normen Hansen          *
 ***********************************
 
 This document outlines the process of building bullet-jme on different platforms.
-Since bullet-jme is a native java library and bullet gets included statically,
+Since bulletjme is a native java library and bullet gets included statically,
 building requires you to download and build the bullet source first.
 
+Note that you do need to have CMake and a GCC compiler installed as well as
+the Android NDK in case you want to build for android too.
+
+-----------------------------------
+Requirements
+-----------------------------------
+ALL PLATFORMS
+- Java SDK 1.5+: http://java.sun.com
+- Apache ANT: http://ant.apache.org (Included in most Java IDEs)
+- Android NDK (optional): http://developer.android.com/sdk/ndk/index.html
+
+WINDOWS
+- Install mingw GNU C++ Compiler: http://www.mingw.org/
+- Install CMake: http://www.cmake.org/
+
+Mac OSX
+- Install XCode: http://developer.apple.com/ (or via the App Store)
+- Install http://www.macports.org
+- Install cmake via macports, in the Terminal type:
+> sudo port install cmake
+
+LINUX
+- Install cmake (and gcc if not available) via your package manager of choice, e.g.
+> sudo apt-get install cmake
+
+-----------------------------------
+Building
+-----------------------------------
+The build script in this directory does everything needed to download and compile
+bullet and the jme-bullet library, you only need to call the appropriate ant target,
+via your IDE or command line:
+
+> ant build-bullet-natives
+
+..and all of the steps below are executed automatically, including the download.
+
+You can alter options in the "nbproject/bullet.properties" file, such as the used
+bullet version, native compilation options (see below), path to Android NDK etc.
+
+-----------------------------------
+Altering the native build process
+-----------------------------------
+bullet-jme uses cpptasks to compile native code as well as the Android NDK.
+
+If you get compilation errors, try setting "native.java.include" in the build.properties file to your
+JDK include directory, e.g. /opt/java/include or "c:\Program Files\Java\jdk1.6.0_20\include".
+
+To change the used compiler, edit the "native.platform.compiler" entry in the
+"build.properties" file. The following c++ compilers work with cpptasks:
+
+gcc     GCC C++ compiler
+g++     GCC C++ compiler
+c++     GCC C++ compiler
+msvc    Microsoft Visual C++
+bcc     Borland C++ Compiler
+icl     Intel C++ compiler for Windows (IA-32)
+ecl     Intel C++ compiler for Windows (IA-64)
+icc     Intel C++ compiler for Linux (IA-32)
+ecc     Intel C++ compiler for Linux (IA-64)
+CC      Sun ONE C++ compiler
+aCC     HP aC++ C++ Compiler
+wcl     OpenWatcom C/C++ compiler
+
+In the "nbproject" folder you can find "build-native-platform.xml" files containing the commands
+to compile bullet-jme on different platforms. If you want to alter the process,
+you can copy and modify one of the files and import it in the "build.xml" file instead
+of the old one.
+
+-----------------------------------
+Netbeans Project
+-----------------------------------
+The project also includes a Netbeans project to edit and build
+the source in the Netbeans IDE in the /src/bullet/ subfolder.
+
+To have correct syntax highlighting in .cpp/.h files:
+
+- in Netbeans Settings -> C/C++ -> Code Assistance -> C++
+  - add bullet-2.77/src as include directories for c++
+  - add JAVA_HOME/include as include directories for c++
+
 
 
 ***********************************
-* Building bullet                 *
+* Building bullet (optional)      *
 ***********************************
 
 -----------------------------------
@@ -83,87 +163,3 @@ Commands:
 More info on building bullet
 -----------------------------------
 http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Installation
-
-
-
-***********************************
-* Building bulletjme             *
-***********************************
-
------------------------------------
-Requirements
------------------------------------
-- Java SDK 1.5+: http://java.sun.com
-- Apache ANT: http://ant.apache.org
-- C++ Compiler: (see below)
-- jme3 Source: http://jmonkeyengine.googlecode.com/
-- Statically compiled bullet source (see above)
-
------------------------------------
-Preparation
------------------------------------
-- copy/link bullet-trunk folder into the same folder where the bullet-jme folder is:
-
-disk
- |
- +-root folder
-    |
-    +-engine
-    |
-    +-sdk
-    |
-    +-bullet-trunk
-
-- You can alter options in the "src/bullet/native/bullet.properties" file, such as the used bullet
-  version, native compilation options etc. (see below)
-
------------------------------------
-Building bulletjme native
------------------------------------
-Commands:
-> cd engine
-> ant jar
-> ant build-bullet-natives
-
-Thats all. ANT takes care building native binaries and copies them to th elib directory.
-
-If you get compilation errors, try setting "native.java.include" in the build.properties file to your
-JDK include directory, e.g. /opt/java/include or "c:\Program Files\Java\jdk1.6.0_20\include".
-
------------------------------------
-Altering the native build process
------------------------------------
-bullet-jme uses cpptasks to compile native code.
-
-To change the used compiler, edit the "native.platform.compiler" entry in the
-"build.properties" file. The following c++ compilers work with cpptasks:
-
-gcc     GCC C++ compiler
-g++     GCC C++ compiler
-c++     GCC C++ compiler
-msvc    Microsoft Visual C++
-bcc     Borland C++ Compiler
-icl     Intel C++ compiler for Windows (IA-32)
-ecl     Intel C++ compiler for Windows (IA-64)
-icc     Intel C++ compiler for Linux (IA-32)
-ecc     Intel C++ compiler for Linux (IA-64)
-CC      Sun ONE C++ compiler
-aCC     HP aC++ C++ Compiler
-wcl     OpenWatcom C/C++ compiler
-
-In the "nbproject" folder you can find "build-native-platform.xml" files containing the commands
-to compile bullet-jme on different platforms. If you want to alter the process,
-you can copy and modify one of the files and import it in the "build.xml" file instead
-of the old one.
-
------------------------------------
-Netbeans Project
------------------------------------
-The project also includes a Netbeans project to edit and build
-the source in the Netbeans IDE in the /src/bullet/ subfolder.
-
-To have correct syntax highlighting in .cpp/.h files:
-
-- in Netbeans Settings -> C/C++ -> Code Assistance -> C++
-  - add bullet-2.77/src as include directories for c++
-  - add JAVA_HOME/include as include directories for c++

+ 52 - 1
engine/nbproject/build-bullet-natives.xml

@@ -51,7 +51,7 @@
         <fileset refid="lib.jme.jars"/>
     </pathconvert>
 
-    <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">
+    <target name="build-bullet-natives" description="builds the native bullet library for the platform being run on" depends="-compile-bullet-sources, -create-folders, create-native-headers, -nativelib-osx, -nativelib-windows, -nativelib-linux, -nativelib-solaris, -nativelib-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"/>
@@ -302,4 +302,55 @@
         <available file="${ndk.dir}/${ndk-build-name}" property="haveAndoidNdk"/>
     </target>
     
+    <target name="-compile-bullet-sources" depends="-get-bullet-sources, -compile-bullet-sources-windows, -compile-bullet-sources-macosx, -compile-bullet-sources-linux"/>
+
+    <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"/>
+    </target>
+    
+    <target name="-compile-bullet-sources-windows" if="isWindows">
+        <exec executable="${cmake.windows}" dir="${bullet.folder}">
+            <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">
+        <exec executable="${cmake.osx}" dir="${bullet.folder}">
+            <arg value="-DBUILD_SHARED_LIBS=OFF"/>
+            <arg value="-DBUILD_STATIC_LIBS=ON"/>
+            <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">
+        <exec executable="${cmake.linux}" dir="${bullet.folder}">
+            <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>

+ 12 - 2
engine/nbproject/bullet-native.properties

@@ -4,8 +4,9 @@
 bullet.library.name=bulletjme
 bullet.library.version=0.9
 
-# change if bullet folder has different location
+# change if bullet folder has different name
 bullet.folder=../bullet-2.79
+bullet.download=http://bullet.googlecode.com/files/bullet-2.79-rev2440.zip
 
 # compile options
 bullet.compile.debug=false
@@ -22,7 +23,16 @@ bullet.java.include=${java.home}/../include
 # OSX has no JRE, only JDK
 bullet.osx.java.include=/System/Library/Frameworks/JavaVM.framework/Headers
 
-# location of Android NDK
+# exec command for cmake and make for different platforms,
+# needed to compile bullet before compiling the jme bullet libraries
+cmake.windows=cmake
+make.windows=mingw32-make
+cmake.linux=cmake
+make.linux=make
+cmake.osx=/opt/local/bin/cmake
+make.osx=make
+
+# location of Android NDK if available
 ndk.dir=/opt/android-ndk-r7
 
 # dont change these..