+ config.jniDir.child(buildFileName) + "'");\r
\r
if (!target.excludeFromMasterBuildFile) {\r
- if (target.os != TargetOs.MacOsX) {\r
+ if (target.os != TargetOs.MacOsX && target.os != TargetOs.IOS) {\r
buildFiles.add(buildFileName);\r
- }\r
+ } \r
sharedLibFiles.add(getSharedLibFilename(target.os, target.is64Bit, config.sharedLibName));\r
libsDirs.add("../" + libsDir.path().replace('\\', '/'));\r
}\r
libPrefix = "lib";\r
libSuffix = ".dylib";\r
}\r
+ if (os == TargetOs.IOS) {\r
+ libPrefix = "lib";\r
+ libSuffix = ".a";\r
+ }\r
return libPrefix + sharedLibName + libSuffix;\r
}\r
\r
}\r
\r
// read template file from resources\r
- String template = new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/build-target.xml.template",\r
+ String template = null;\r
+ if(target.os == TargetOs.IOS) {\r
+ template = new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/build-ios.xml.template",\r
FileType.Classpath).readString();\r
+ } else {\r
+ template = new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/build-target.xml.template",\r
+ FileType.Classpath).readString();\r
+ }\r
\r
// generate shared lib filename and jni platform headers directory name\r
String libName = getSharedLibFilename(target.os, target.is64Bit, config.sharedLibName);\r
public class BuildTarget {\r
/** The target operating system of a build target. */\r
public enum TargetOs {\r
- Windows, Linux, MacOsX, Android\r
+ Windows, Linux, MacOsX, Android, IOS\r
}\r
\r
/** the target operating system **/\r
"-lm");\r
return android;\r
}\r
+ \r
+ if(type == TargetOs.IOS) {\r
+ // iOS, 386 simulator and armv7a, compiled to fat static lib\r
+ BuildTarget ios = new BuildTarget(TargetOs.IOS, false, new String[] {"**/*.c"}, new String[0],\r
+ new String[] {"**/*.cpp"}, new String[0], new String[0], "",\r
+ "-c -Wall -O2",\r
+ "-c -Wall -O2",\r
+ "rcs");\r
+ return ios;\r
+ }\r
\r
throw new RuntimeException("Unknown target type");\r
}\r
--- /dev/null
+<project name="%projectName%" basedir="." default="postcompile">\r
+ <!-- include the environment -->\r
+ <property environment="env"/> \r
+ <!-- output directory for temporary object files -->\r
+ <property name="buildDir" value="%buildDir%" />\r
+ <!-- output directory for the shared library -->\r
+ <property name="libsDir" value="%libsDir%" />\r
+ <!-- the name of the shared library -->\r
+ <property name="libName" value="%libName%"/>\r
+ <!-- the jni header jniPlatform to use -->\r
+ <property name="jniPlatform" value="mac"/>\r
+ <!-- the compilerPrefix for the C & C++ compilers -->\r
+ <property name="compilerPrefix" value="%compilerPrefix%"/> \r
+ <property name="iphoneos-platform" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"/>\r
+ <property name="iphoneos-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/"/>\r
+ <property name="iphonesimulator-platform" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin"/>\r
+ <property name="iphonesimulator-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/"/>\r
+ \r
+ <!-- define gcc compiler, options and files to compile -->\r
+ <property name="gcc" value="${compilerPrefix}gcc"/> \r
+ <property name="gcc-opts" value="%cFlags%"/>\r
+ <fileset id="gcc-files" dir="./">\r
+ <exclude name="target/"/> \r
+ %cIncludes%\r
+ %cExcludes%\r
+ </fileset>\r
+ \r
+ <!-- define g++ compiler, options and files to compile -->\r
+ <property name="g++" value="${compilerPrefix}g++"/>\r
+ <property name="g++-opts" value="%cppFlags%"/>\r
+ <fileset id="g++-files" dir="./">\r
+ <exclude name="target/"/>\r
+ %cppIncludes%\r
+ %cppExcludes%\r
+ </fileset>\r
+\r
+ <!-- define linker and options -->\r
+ <property name="linker" value="${compilerPrefix}ar"/>\r
+ <property name="linker-opts" value="%linkerFlags%"/>\r
+ <property name="libraries" value="%libraries%"/>\r
+ \r
+ <!-- cleans the build directory, removes all object files and shared libs -->\r
+ <target name="clean">\r
+ <delete includeemptydirs="true" quiet="true">\r
+ <fileset dir="${buildDir}"/>\r
+ <fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>\r
+ </delete>\r
+ </target>\r
+ \r
+ <target name="clean-objfiles">\r
+ <delete>\r
+ <fileset dir="${buildDir}">\r
+ <include name="**/*.o"/>\r
+ </fileset>\r
+ </delete>\r
+ </target>\r
+ \r
+ <target name="create-build-dir">\r
+ <!-- FIXME this is pretty nasty :/ -->\r
+ <copy todir="${buildDir}">\r
+ <fileset refid="g++-files"/>\r
+ <fileset refid="gcc-files"/>\r
+ </copy>\r
+ <delete>\r
+ <fileset dir="${buildDir}">\r
+ <include name="*"/>\r
+ <exclude name="*.o"/>\r
+ </fileset>\r
+ </delete>\r
+ </target>\r
+\r
+ <!-- compiles all C and C++ files to object files in the build directory, for 386 builds-->\r
+ <target name="compile-386" depends="clean,create-build-dir">\r
+ <mkdir dir="${buildDir}"/>\r
+ <apply failonerror="true" executable="${iphonesimulator-platform}/${g++}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphonesimulator-sdk} -arch i386 ${g++-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ %headerDirs%\r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="g++-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.cpp" to="*.o"/>\r
+ <mapper type="glob" from="*.mm" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ <apply failonerror="true" executable="${iphonesimulator-platform}/${gcc}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphonesimulator-sdk} -arch i386 ${gcc-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ %headerDirs%\r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="gcc-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.c" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ </target> \r
+\r
+ <!-- links the shared library based on the previously compiled object files -->\r
+ <target name="link-386" depends="compile-386">\r
+ <fileset dir="${buildDir}" id="objFileSet">\r
+ <patternset>\r
+ <include name="**/*.o" />\r
+ </patternset>\r
+ </fileset>\r
+ <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />\r
+ <mkdir dir="${libsDir}" />\r
+ <exec executable="${iphonesimulator-platform}/${linker}" failonerror="true" dir="${buildDir}">\r
+ <arg line="${linker-opts}" />\r
+ <arg path="${libsDir}/${libName}.386" />\r
+ <arg line="${objFiles}"/>\r
+ <arg line="${libraries}" />\r
+ </exec>\r
+ </target>\r
+ \r
+ <!-- compiles all C and C++ files to object files in the build directory, for 386 builds-->\r
+ <target name="compile-arm" depends="create-build-dir,clean-objfiles">\r
+ <mkdir dir="${buildDir}"/>\r
+ <apply failonerror="true" executable="${iphoneos-platform}/${g++}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphoneos-sdk} -arch armv7 ${g++-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ %headerDirs%\r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="g++-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.cpp" to="*.o"/>\r
+ <mapper type="glob" from="*.mm" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ <apply failonerror="true" executable="${iphoneos-platform}/${gcc}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphoneos-sdk} -arch armv7 ${gcc-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ %headerDirs%\r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="gcc-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.c" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ </target> \r
+\r
+ <!-- links the shared library based on the previously compiled object files -->\r
+ <target name="link-arm" depends="compile-arm">\r
+ <fileset dir="${buildDir}" id="objFileSet">\r
+ <patternset>\r
+ <include name="**/*.o" />\r
+ </patternset>\r
+ </fileset>\r
+ <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />\r
+ <mkdir dir="${libsDir}" />\r
+ <exec executable="${iphoneos-platform}/${linker}" failonerror="true" dir="${buildDir}">\r
+ <arg line="${linker-opts}" />\r
+ <arg path="${libsDir}/${libName}.armv7" />\r
+ <arg line="${objFiles}"/>\r
+ <arg line="${libraries}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="link-fat">\r
+ <exec executable="lipo" failonerror="true" dir="${libsDir}">\r
+ <arg line="-create -output ${libName} ${libName}.386 ${libName}.armv7"/>\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="postcompile" depends="link-386,link-arm,link-fat">\r
+ %postcompile%\r
+ </target>\r
+</project>\r
--- /dev/null
+<project name="gdx-IOS-32" basedir="." default="postcompile">\r
+ <!-- include the environment -->\r
+ <property environment="env"/> \r
+ <!-- output directory for temporary object files -->\r
+ <property name="buildDir" value="../target/native/ios32" />\r
+ <!-- output directory for the shared library -->\r
+ <property name="libsDir" value="../libs/ios32" />\r
+ <!-- the name of the shared library -->\r
+ <property name="libName" value="libgdx.a"/>\r
+ <!-- the jni header jniPlatform to use -->\r
+ <property name="jniPlatform" value="mac"/>\r
+ <!-- the compilerPrefix for the C & C++ compilers -->\r
+ <property name="compilerPrefix" value=""/> \r
+ <property name="iphoneos-platform" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin"/>\r
+ <property name="iphoneos-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/"/>\r
+ <property name="iphonesimulator-platform" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin"/>\r
+ <property name="iphonesimulator-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/"/>\r
+ \r
+ <!-- define gcc compiler, options and files to compile -->\r
+ <property name="gcc" value="${compilerPrefix}gcc"/> \r
+ <property name="gcc-opts" value="-c -Wall -O2"/>\r
+ <fileset id="gcc-files" dir="./">\r
+ <exclude name="target/"/> \r
+ <include name="memcpy_wrap.c"/>
+ <include name="**/*.c"/>
+\r
+ \r
+ </fileset>\r
+ \r
+ <!-- define g++ compiler, options and files to compile -->\r
+ <property name="g++" value="${compilerPrefix}g++"/>\r
+ <property name="g++-opts" value="-c -Wall -O2"/>\r
+ <fileset id="g++-files" dir="./">\r
+ <exclude name="target/"/>\r
+ <include name="**/*.cpp"/>
+\r
+ \r
+ </fileset>\r
+\r
+ <!-- define linker and options -->\r
+ <property name="linker" value="${compilerPrefix}ar"/>\r
+ <property name="linker-opts" value="rcs"/>\r
+ <property name="libraries" value=""/>\r
+ \r
+ <!-- cleans the build directory, removes all object files and shared libs -->\r
+ <target name="clean">\r
+ <delete includeemptydirs="true" quiet="true">\r
+ <fileset dir="${buildDir}"/>\r
+ <fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>\r
+ </delete>\r
+ </target>\r
+ \r
+ <target name="clean-objfiles">\r
+ <delete>\r
+ <fileset dir="${buildDir}">\r
+ <include name="**/*.o"/>\r
+ </fileset>\r
+ </delete>\r
+ </target>\r
+ \r
+ <target name="create-build-dir">\r
+ <!-- FIXME this is pretty nasty :/ -->\r
+ <copy todir="${buildDir}">\r
+ <fileset refid="g++-files"/>\r
+ <fileset refid="gcc-files"/>\r
+ </copy>\r
+ <delete>\r
+ <fileset dir="${buildDir}">\r
+ <include name="*"/>\r
+ <exclude name="*.o"/>\r
+ </fileset>\r
+ </delete>\r
+ </target>\r
+\r
+ <!-- compiles all C and C++ files to object files in the build directory, for 386 builds-->\r
+ <target name="compile-386" depends="clean,create-build-dir">\r
+ <mkdir dir="${buildDir}"/>\r
+ <apply failonerror="true" executable="${iphonesimulator-platform}/${g++}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphonesimulator-sdk} -arch i386 ${g++-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ \r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="g++-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.cpp" to="*.o"/>\r
+ <mapper type="glob" from="*.mm" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ <apply failonerror="true" executable="${iphonesimulator-platform}/${gcc}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphonesimulator-sdk} -arch i386 ${gcc-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ \r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="gcc-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.c" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ </target> \r
+\r
+ <!-- links the shared library based on the previously compiled object files -->\r
+ <target name="link-386" depends="compile-386">\r
+ <fileset dir="${buildDir}" id="objFileSet">\r
+ <patternset>\r
+ <include name="**/*.o" />\r
+ </patternset>\r
+ </fileset>\r
+ <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />\r
+ <mkdir dir="${libsDir}" />\r
+ <exec executable="${iphonesimulator-platform}/${linker}" failonerror="true" dir="${buildDir}">\r
+ <arg line="${linker-opts}" />\r
+ <arg path="${libsDir}/${libName}.386" />\r
+ <arg line="${objFiles}"/>\r
+ <arg line="${libraries}" />\r
+ </exec>\r
+ </target>\r
+ \r
+ <!-- compiles all C and C++ files to object files in the build directory, for 386 builds-->\r
+ <target name="compile-arm" depends="create-build-dir,clean-objfiles">\r
+ <mkdir dir="${buildDir}"/>\r
+ <apply failonerror="true" executable="${iphoneos-platform}/${g++}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphoneos-sdk} -arch armv7 ${g++-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ \r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="g++-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.cpp" to="*.o"/>\r
+ <mapper type="glob" from="*.mm" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ <apply failonerror="true" executable="${iphoneos-platform}/${gcc}" dest="${buildDir}" verbose="true">\r
+ <arg line="-isysroot ${iphoneos-sdk} -arch armv7 ${gcc-opts}"/>\r
+ <arg value="-Ijni-headers"/>\r
+ <arg value="-Ijni-headers/${jniPlatform}"/>\r
+ <arg value="-I."/>\r
+ \r
+ <srcfile/>\r
+ <arg value="-o"/>\r
+ <targetfile/>\r
+ <fileset refid="gcc-files"/>\r
+ <compositemapper>\r
+ <mapper type="glob" from="*.c" to="*.o"/>\r
+ </compositemapper>\r
+ </apply>\r
+ </target> \r
+\r
+ <!-- links the shared library based on the previously compiled object files -->\r
+ <target name="link-arm" depends="compile-arm">\r
+ <fileset dir="${buildDir}" id="objFileSet">\r
+ <patternset>\r
+ <include name="**/*.o" />\r
+ </patternset>\r
+ </fileset>\r
+ <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />\r
+ <mkdir dir="${libsDir}" />\r
+ <exec executable="${iphoneos-platform}/${linker}" failonerror="true" dir="${buildDir}">\r
+ <arg line="${linker-opts}" />\r
+ <arg path="${libsDir}/${libName}.armv7" />\r
+ <arg line="${objFiles}"/>\r
+ <arg line="${libraries}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="link-fat">\r
+ <exec executable="lipo" failonerror="true" dir="${libsDir}">\r
+ <arg line="-create -output ${libName} ${libName}.386 ${libName}.armv7"/>\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="postcompile" depends="link-386,link-arm,link-fat">\r
+ \r
+ </target>\r
+</project>\r
<fileset dir="../libs/linux32" includes="libgdx.so"/>
<fileset dir="../libs/linux64" includes="libgdx64.so"/>
<fileset dir="../libs/android32" includes="libgdx.so"/>
+ <fileset dir="../libs/ios32" includes="libgdx.a"/>
</jar>
</target>
JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_physics_box2d_ChainShape_newChainShape(JNIEnv* env, jobject object) {
-//@line:31
+//@line:32
\r
return (jlong)(new b2ChainShape());\r
float* verts = (float*)env->GetPrimitiveArrayCritical(obj_verts, 0);
-//@line:55
+//@line:57
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
b2Vec2* verticesOut = new b2Vec2[numVertices];\r
float* verts = (float*)env->GetPrimitiveArrayCritical(obj_verts, 0);
-//@line:75
+//@line:78
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
b2Vec2* verticesOut = new b2Vec2[numVertices];\r
JNIEXPORT void JNICALL Java_com_badlogic_gdx_physics_box2d_ChainShape_jniSetPrevVertex(JNIEnv* env, jobject object, jlong addr, jfloat x, jfloat y) {
-//@line:94
+//@line:97
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
chain->SetPrevVertex(b2Vec2(x, y));\r
JNIEXPORT void JNICALL Java_com_badlogic_gdx_physics_box2d_ChainShape_jniSetNextVertex(JNIEnv* env, jobject object, jlong addr, jfloat x, jfloat y) {
-//@line:109
+//@line:112
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
chain->SetNextVertex(b2Vec2(x, y));\r
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_physics_box2d_ChainShape_jniGetVertexCount(JNIEnv* env, jobject object, jlong addr) {
-//@line:119
+//@line:122
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
return chain->GetVertexCount();\r
float* verts = (float*)env->GetPrimitiveArrayCritical(obj_verts, 0);
-//@line:135
+//@line:138
\r
b2ChainShape* chain = (b2ChainShape*)addr;\r
const b2Vec2 v = chain->GetVertex( index );\r
BuildTarget lin64 = BuildTarget.newDefaultTarget(TargetOs.Linux, true);\r
BuildTarget android = BuildTarget.newDefaultTarget(TargetOs.Android, false);\r
BuildTarget mac = BuildTarget.newDefaultTarget(TargetOs.MacOsX, false);\r
+ BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);\r
new AntScriptGenerator().generate(new BuildConfig("gdx", "../target/native", LIBS_DIR, JNI_DIR), mac, win32home, win32,\r
- win64, lin32, lin64, android);\r
+ win64, lin32, lin64, android, ios);\r
\r
// build natives\r
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");\r