Home | History | Annotate | Download | only in bullet
      1 /*******************************************************************************
      2  * Copyright 2011 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *   http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.physics.bullet;
     18 
     19 import java.io.File;
     20 
     21 import com.badlogic.gdx.files.FileHandle;
     22 import com.badlogic.gdx.jnigen.AntScriptGenerator;
     23 import com.badlogic.gdx.jnigen.BuildConfig;
     24 import com.badlogic.gdx.jnigen.BuildExecutor;
     25 import com.badlogic.gdx.jnigen.BuildTarget;
     26 import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
     27 import com.badlogic.gdx.jnigen.NativeCodeGenerator;
     28 
     29 public class BulletBuild {
     30 	public static void main (String[] args) throws Exception {
     31 		// generate C/C++ code
     32 		new NativeCodeGenerator().generate("src", "bin", "jni");
     33 
     34 		// Flags to accomodate SWIG generated code
     35 		String cppFlags = "";
     36 
     37 		// SWIG doesn't emit strict aliasing compliant code
     38 		cppFlags += " -fno-strict-aliasing";
     39 		// SWIG directors aren't clearly documented to require RTTI, but SWIG
     40 		// normally generates a small number of dynamic_casts for director code.
     41 		// gdx-bullet's swig build.xml replaces these with static C casts so we
     42 		// can compile without RTTI and save some disk space. It seems to work
     43 		// with these static casts.
     44 		cppFlags += " -fno-rtti";
     45 		// Disable profiling (it's on by default). If you change this, you
     46 		// must regenerate the SWIG wrappers with the changed value.
     47 		cppFlags += " -DBT_NO_PROFILE";
     48 
     49 		// generate build scripts
     50 		String[] excludes = {"src/bullet/BulletMultiThreaded/GpuSoftBodySolvers/**"};
     51 		String[] headers = {"src/bullet/", "src/custom/", "src/extras/Serialize/"};
     52 
     53 		BuildTarget win32home = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
     54 		win32home.compilerPrefix = "";
     55 		win32home.buildFileName = "build-windows32home.xml";
     56 		win32home.excludeFromMasterBuildFile = true;
     57 		win32home.cExcludes = win32home.cppExcludes = excludes;
     58 		win32home.headerDirs = headers;
     59 		win32home.cppFlags += cppFlags;
     60 
     61 		BuildTarget win32 = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
     62 		win32.cExcludes = win32.cppExcludes = excludes;
     63 		win32.headerDirs = headers;
     64 		win32.cppFlags += cppFlags;
     65 
     66 		BuildTarget win64 = BuildTarget.newDefaultTarget(TargetOs.Windows, true);
     67 		win64.cExcludes = win64.cppExcludes = excludes;
     68 		win64.headerDirs = headers;
     69 		win64.cppFlags += cppFlags;
     70 
     71 		BuildTarget lin32 = BuildTarget.newDefaultTarget(TargetOs.Linux, false);
     72 		lin32.cExcludes = lin32.cppExcludes = excludes;
     73 		lin32.headerDirs = headers;
     74 		lin32.cppFlags += cppFlags;
     75 
     76 		BuildTarget lin64 = BuildTarget.newDefaultTarget(TargetOs.Linux, true);
     77 		lin64.cExcludes = lin64.cppExcludes = excludes;
     78 		lin64.headerDirs = headers;
     79 		lin64.cppFlags += cppFlags;
     80 
     81 		BuildTarget mac = BuildTarget.newDefaultTarget(TargetOs.MacOsX, false);
     82 		mac.cExcludes = mac.cppExcludes = excludes;
     83 		mac.headerDirs = headers;
     84 		mac.cppFlags += cppFlags;
     85 
     86 		BuildTarget mac64 = BuildTarget.newDefaultTarget(TargetOs.MacOsX, true);
     87 		mac64.cExcludes = mac.cppExcludes = excludes;
     88 		mac64.headerDirs = headers;
     89 		mac64.cppFlags += cppFlags;
     90 
     91 		BuildTarget android = BuildTarget.newDefaultTarget(TargetOs.Android, false);
     92 		android.cExcludes = android.cppExcludes = excludes;
     93 		android.headerDirs = headers;
     94 		android.cppFlags += cppFlags + " -fexceptions";
     95 
     96 		BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
     97 		ios.cExcludes = ios.cppExcludes = excludes;
     98 		ios.headerDirs = headers;
     99 		ios.cppFlags += cppFlags;
    100 
    101 		new AntScriptGenerator().generate(new BuildConfig("gdx-bullet"), win32home, win32, win64, lin32, lin64, mac, mac64, android, ios);
    102 		new FileHandle(new File("jni/Application.mk")).writeString("\nAPP_STL := stlport_static\n", true);
    103 
    104 		// build natives
    105 		// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");
    106 //		BuildExecutor.executeAnt("jni/build-linux64.xml", "");
    107 //		BuildExecutor.executeAnt("jni/build-android32.xml", "");
    108 //		BuildExecutor.executeAnt("jni/build.xml", "pack-natives");
    109 	}
    110 }
    111