All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.badlogic.gdx.jnigen.resources.scripts.build-ios.xml.template Maven / Gradle / Ivy

The newest version!
<project name="%projectName%" basedir="." default="postcompile">
	<!-- include the environment -->
	<property environment="env"/>	
	<!-- output directory for temporary object files -->
	<property name="buildDir" value="%buildDir%" />
	<property name="absolute.buildDir" location="${buildDir}"/>
	<!-- output directory for the shared library -->
	<property name="libsDir" value="%libsDir%" />
	<!-- the name of the shared library -->
	<property name="libName" value="%libName%"/>
    <!-- the name of the xcframework library -->
    <property name="xcframeworkName" value="%xcframeworkName%"/>
    <!-- the bundle identifier of the xcframework library -->
    <property name="xcframeworkBundleIdentifier" value="%xcframeworkBundleIdentifier%"/>
    <!-- The minimum iOS version -->
    <property name="minIOSVersion" value="%minIOSVersion%"/>
	<!-- the jni header jniPlatform to use -->
	<property name="jniPlatform" value="mac"/>
	<!-- the compiler to use when compiling c files -->
	<property name="cCompiler" value="%cCompiler%"/>
	<!-- the compiler to use when compiling c++ files -->
	<property name="cppCompiler" value="%cppCompiler%"/>
	<!-- the command to use when archiving files -->
	<property name="archiver" value="%archiver%"/>
	<!-- the compilerPrefix for the C & C++ compilers -->
	<property name="compilerPrefix" value="%compilerPrefix%"/>
	<!-- the compilerSuffix for the C & C++ compilers -->
	<property name="compilerSuffix" value="%compilerSuffix%" />
	
	<property name="iphoneos-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/"/>
	<property name="iphonesimulator-sdk" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"/>
	
	
	<!-- define gcc compiler, options and files to compile -->
	<property name="gcc" value="${compilerPrefix}${cCompiler}${compilerSuffix}"/>
	<property name="gcc-opts" value="%cFlags%"/>
	<fileset id="gcc-files" dir="./">
		<exclude name="target/"/>		
		%cIncludes%
		%cExcludes%
	</fileset>
	
	<!-- define g++ compiler, options and files to compile -->
	<property name="g++" value="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
	<property name="g++-opts" value="%cppFlags%"/>
	<fileset id="g++-files" dir="./">
		<exclude name="target/"/>
		%cppIncludes%
		%cppExcludes%
	</fileset>

	<!-- define linker and options -->
    <property name="linker" value="${cppCompiler}" />
	<property name="linker-opts" value="%linkerFlags% -install_name @rpath/${libName}.framework/${libName}"/>
	<property name="libraries" value="%libraries%"/>
	
	<!-- cleans the build directory, removes all object files and shared libs -->
	<target name="clean">
		<delete includeemptydirs="true" quiet="true">
			<fileset dir="${buildDir}"/>
			<fileset dir="${libsDir}" includes="**/*"/>
		</delete>
	</target>
	
	<target name="create-build-dir">
		<!-- FIXME this is pretty nasty :/
		     The source files are copied to the output folders
		     thereby creating the directory hiearchy.
		     -->
		<copy todir="${buildDir}">
			<fileset refid="g++-files"/>
			<fileset refid="gcc-files"/>
		</copy>
		<copy todir="${buildDir}/x86_64">
			<fileset refid="g++-files"/>
			<fileset refid="gcc-files"/>
		</copy>
        <copy todir="${buildDir}/arm64-simulator">
            <fileset refid="g++-files"/>
            <fileset refid="gcc-files"/>
        </copy>
		<copy todir="${buildDir}/arm64">
			<fileset refid="g++-files"/>
			<fileset refid="gcc-files"/>
		</copy>
		<delete>
			<fileset dir="${buildDir}/x86_64">
				<include name="*"/>
			</fileset>
            <fileset dir="${buildDir}/arm64-simulator">
				<include name="*"/>
            </fileset>
			<fileset dir="${buildDir}/arm64">
				<include name="*"/>
			</fileset>
		</delete>
		<mkdir dir="${libsDir}"/>
	</target>
	
	<!-- compiles all C and C++ files to object files in the build directory, for x86_64 builds-->
	<target name="compile-x86_64" depends="create-build-dir">
		<apply failonerror="true" executable="${g++}" dest="${buildDir}/x86_64" verbose="true">
			<arg line="-isysroot ${iphonesimulator-sdk} -arch x86_64 -mios-simulator-version-min=${minIOSVersion} ${g++-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			<arg value="-g"/>
			%headerDirs%
			<srcfile/>
			<arg value="-o"/>
			<targetfile/>
			<fileset refid="g++-files"/>
			<compositemapper>
				<mapper type="glob" from="*" to="*.o"/>
			</compositemapper>
		</apply>
		<apply failonerror="true" executable="${gcc}" dest="${buildDir}/x86_64" verbose="true">
			<arg line="-isysroot ${iphonesimulator-sdk} -arch x86_64 -mios-simulator-version-min=${minIOSVersion} ${gcc-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			<arg value="-g"/>
			%headerDirs%
			<srcfile/>
			<arg value="-o"/>
			<targetfile/>
			<fileset refid="gcc-files"/>
			<compositemapper>
				<mapper type="glob" from="*" to="*.o"/>
			</compositemapper>
		</apply>
	</target>

    <!-- links the shared library based on the previously compiled object files -->
    <target name="link-x86_64" depends="compile-x86_64">
        <fileset dir="${buildDir}/x86_64" id="objFileSet">
            <patternset>
                <include name="**/*.o" />
            </patternset>
        </fileset>
        <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
        <mkdir dir="${libsDir}" />
        <exec executable="${linker}" failonerror="true" dir="${buildDir}/x86_64">
			<arg line="-isysroot ${iphonesimulator-sdk} -arch x86_64 -mios-simulator-version-min=${minIOSVersion} ${linker-opts}"/>
            <arg value="-o" />
            <arg path="${buildDir}/x86_64/${libName}" />
            <arg line="${objFiles}"/>
            <arg line="${libraries}" />
        </exec>
    </target>


    <!-- compiles all C and C++ files to object files in the build directory, for arm64 simulator builds-->
    <target name="compile-arm64-simulator" depends="create-build-dir">
        <apply failonerror="true" executable="${g++}" dest="${buildDir}/arm64-simulator" verbose="true">
            <arg line="-isysroot ${iphonesimulator-sdk} -arch arm64 -mios-simulator-version-min=${minIOSVersion} ${g++-opts}"/>
            <arg value="-Ijni-headers"/>
            <arg value="-Ijni-headers/${jniPlatform}"/>
            <arg value="-I."/>
            <arg value="-g"/>
            %headerDirs%
            <srcfile/>
            <arg value="-o"/>
            <targetfile/>
            <fileset refid="g++-files"/>
            <compositemapper>
                <mapper type="glob" from="*" to="*.o"/>
            </compositemapper>
        </apply>
        <apply failonerror="true" executable="${gcc}" dest="${buildDir}/arm64-simulator" verbose="true">
            <arg line="-isysroot ${iphonesimulator-sdk} -arch arm64 -mios-simulator-version-min=${minIOSVersion} ${gcc-opts}"/>
            <arg value="-Ijni-headers"/>
            <arg value="-Ijni-headers/${jniPlatform}"/>
            <arg value="-I."/>
            <arg value="-g"/>
            %headerDirs%
            <srcfile/>
            <arg value="-o"/>
            <targetfile/>
            <fileset refid="gcc-files"/>
            <compositemapper>
                <mapper type="glob" from="*" to="*.o"/>
            </compositemapper>
        </apply>
    </target>

    <!-- links the shared library based on the previously compiled object files -->
    <target name="link-arm64-simulator" depends="compile-arm64-simulator">
        <fileset dir="${buildDir}/arm64-simulator" id="objFileSetArm64Simulator">
            <patternset>
                <include name="**/*.o" />
            </patternset>
        </fileset>
        <pathconvert pathsep=" " property="objFilesArm64Simulator" refid="objFileSetArm64Simulator" />
        <mkdir dir="${libsDir}" />
        <exec executable="${linker}" failonerror="true" dir="${buildDir}/arm64-simulator">
            <arg line="-isysroot ${iphonesimulator-sdk} -arch arm64 -mios-simulator-version-min=${minIOSVersion} ${linker-opts}"/>
            <arg value="-o" />
            <arg path="${buildDir}/arm64-simulator/${libName}" />
            <arg line="${objFilesArm64Simulator}"/>
            <arg line="${libraries}" />
        </exec>
    </target>
	
	<!-- compiles all C and C++ files to object files in the build directory, for arm64 builds-->
	<target name="compile-arm64" depends="create-build-dir">
		<apply failonerror="true" executable="${g++}" dest="${buildDir}/arm64" verbose="true">
			<arg line="-isysroot ${iphoneos-sdk} -arch arm64 -miphoneos-version-min=${minIOSVersion} ${g++-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			<arg value="-g"/>
			%headerDirs%
			<srcfile/>
			<arg value="-o"/>
			<targetfile/>
			<fileset refid="g++-files"/>
			<compositemapper>
				<mapper type="glob" from="*" to="*.o"/>
			</compositemapper>
		</apply>
		<apply failonerror="true" executable="${gcc}" dest="${buildDir}/arm64" verbose="true">
			<arg line="-isysroot ${iphoneos-sdk} -arch arm64 -miphoneos-version-min=${minIOSVersion} ${gcc-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			<arg value="-g"/>
			%headerDirs%
			<srcfile/>
			<arg value="-o"/>
			<targetfile/>
			<fileset refid="gcc-files"/>
			<compositemapper>
				<mapper type="glob" from="*" to="*.o"/>
			</compositemapper>
		</apply>
	</target>

    <!-- links the shared library based on the previously compiled object files -->
    <target name="link-arm64" depends="compile-arm64">
        <fileset dir="${buildDir}/arm64" id="objFileSetArm64">
            <patternset>
                <include name="**/*.o" />
            </patternset>
        </fileset>
        <pathconvert pathsep=" " property="objFilesArm64" refid="objFileSetArm64" />
        <mkdir dir="${libsDir}" />
        <exec executable="${linker}" failonerror="true" dir="${buildDir}/arm64">
			<arg line="-isysroot ${iphoneos-sdk} -arch arm64 -miphoneos-version-min=${minIOSVersion} ${linker-opts}"/>
            <arg value="-o" />
            <arg path="${buildDir}/arm64/${libName}" />
            <arg line="${objFilesArm64}"/>
            <arg line="${libraries}" />
        </exec>
    </target>

	<target name="archive-fat" depends="link-x86_64,link-arm64-simulator,link-arm64">
	    <mkdir dir="${buildDir}/device/${libName}.framework/"/>
		<copy file="${buildDir}/arm64/${libName}" tofile="${buildDir}/device/${libName}.framework/${libName}"/>
	    <mkdir dir="${buildDir}/simulator/${libName}.framework/"/>
        <exec executable="lipo" failonerror="true" dir="${buildDir}">
            <arg line="-create -output simulator/${libName}.framework/${libName} x86_64/${libName} arm64-simulator/${libName}"/>
        </exec>
	</target>

    <target name="build-plist-device" depends="archive-fat">
        <copy file="Info.plist" tofile="${buildDir}/device/${libName}.framework/Info.plist"/>
        <exec executable="/usr/libexec/PlistBuddy" failonerror="true" dir="${buildDir}">
            <arg value="-c"/>
            <arg value="Set :CFBundleName ${libName}"/>
            <arg value="-c"/>
            <arg value="Set :CFBundleExecutable ${libName}"/>
            <arg value="-c"/>
            <arg value="Set :DTPlatformName iphoneos"/>
            <arg value="-c"/>
            <arg value="Set :CFBundleIdentifier ${xcframeworkBundleIdentifier}"/>
            <arg value="-c"/>
            <arg value="Set :MinimumOSVersion ${minIOSVersion}"/>
            <arg value="${absolute.buildDir}/device/${libName}.framework/Info.plist"/>
        </exec>
        <exec executable="plutil" failonerror="true" dir="${buildDir}">
            <arg line="-convert"/>
            <arg line="binary1"/>
            <arg line="${absolute.buildDir}/device/${libName}.framework/Info.plist"/>
        </exec>
    </target>

    <target name="build-plist-simulator" depends="archive-fat">
        <copy file="Info.plist" tofile="${buildDir}/simulator/${libName}.framework/Info.plist"/>
        <exec executable="/usr/libexec/PlistBuddy" failonerror="true" dir="${buildDir}">
            <arg value="-c"/>
            <arg value="Set :CFBundleName ${libName}"/>
            <arg value="-c"/>
            <arg value="Set :CFBundleExecutable ${libName}"/>
            <arg value="-c"/>
            <arg value="Set :DTPlatformName iphonesimulator"/>
            <arg value="-c"/>
            <arg value="Set :CFBundleIdentifier ${xcframeworkBundleIdentifier}"/>
            <arg value="-c"/>
            <arg value="Set :MinimumOSVersion ${minIOSVersion}"/>
            <arg value="${absolute.buildDir}/simulator/${libName}.framework/Info.plist"/>
        </exec>
        <exec executable="plutil" failonerror="true" dir="${buildDir}">
            <arg line="-convert"/>
            <arg line="binary1"/>
            <arg line="${absolute.buildDir}/simulator/${libName}.framework/Info.plist"/>
        </exec>
    </target>

    <target name="generate-dsyms" depends="build-plist-device,build-plist-simulator">
		<exec executable="dsymutil" failonerror="true" dir="${buildDir}">
			<arg line="${absolute.buildDir}/simulator/${libName}.framework/${libName}"/>
			<arg line="-o"/>
			<arg line="${absolute.buildDir}/simulator/${libName}.framework.dSYM"/>
		</exec>
		<exec executable="dsymutil" failonerror="true" dir="${buildDir}">
			<arg line="${absolute.buildDir}/device/${libName}.framework/${libName}"/>
			<arg line="-o"/>
			<arg line="${absolute.buildDir}/device/${libName}.framework.dSYM"/>
		</exec>
	</target>


    <target name="strip" depends="generate-dsyms">
		<exec executable="strip" failonerror="true" dir="${buildDir}">
			<arg line="-x"/>
			<arg line="${absolute.buildDir}/simulator/${libName}.framework/${libName}"/>
		</exec>
		<exec executable="strip" failonerror="true" dir="${buildDir}">
			<arg line="-x"/>
			<arg line="${absolute.buildDir}/device/${libName}.framework/${libName}"/>
		</exec>
	</target>

	<target name="create-xcframework" depends="strip">
        <exec executable="xcodebuild" failonerror="true">
            <arg line="-create-xcframework"/>

			<arg line="-framework"/>
			<arg line="${buildDir}/device/${libName}.framework"/>
			<arg line="-debug-symbols"/>
			<arg line="${absolute.buildDir}/device/${libName}.framework.dSYM"/>

			<arg line="-framework"/>
			<arg line="${buildDir}/simulator/${libName}.framework"/>
			<arg line="-debug-symbols"/>
			<arg line="${absolute.buildDir}/simulator/${libName}.framework.dSYM"/>

			<arg line="-output"/>
			<arg line="${libsDir}/${xcframeworkName}.xcframework"/>
		</exec>
	</target>

	<target name="postcompile" depends="create-xcframework">
		%postcompile%
	</target>
</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy