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

com.badlogic.gdx.jnigen.resources.scripts.build-target.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%" />
	<!-- output directory for the shared library -->
	<property name="libsDir" value="%libsDir%" />
	<!-- the name of the shared library -->
	<property name="libName" value="%libName%"/>
	<!-- the jni header jniPlatform to use -->
	<property name="jniPlatform" value="%jniPlatform%"/>
	<!-- 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%" />
	
	<!-- 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="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
	<property name="linker-opts" value="%linkerFlags%"/>
	<property name="libraries" value="%libraries%"/>

	<!-- define stripper -->
	<property name="stripper" value="${compilerPrefix}strip${compilerSuffix}"/>
	
	<!-- 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="**/*" excludes="**/.svn"/>
		</delete>
	</target>
	
	<target name="precompile">
		<condition property="compiler-found">
			<and>
				<or>
					<!-- Include both b/c Windows might be either -->
					<available file="${g++}" filepath="${env.PATH}"/>
					<available file="${g++}" filepath="${env.Path}"/>
				</or>
				<or>
					<!-- Include both b/c Windows might be either -->
					<available file="${gcc}" filepath="${env.PATH}"/>
					<available file="${gcc}" filepath="${env.Path}"/>
				</or>
			</and>
		</condition>
		<condition property="has-compiler">
			<equals arg1="${compiler-found}" arg2="true"/>
		</condition>
		<condition property="stripper-found">
			<or>
				<!-- Include both b/c Windows might be either -->
				<available file="${stripper}" filepath="${env.PATH}"/>
				<available file="${stripper}" filepath="${env.Path}"/>
			</or>
		</condition>
		<condition property="should-strip">
			<and>
				<equals arg1="${stripper-found}" arg2="true"/>
				<equals arg1="${release}" arg2="true"/>
				<!-- Don't strip mac osx libs -->
				<not>
					<contains string="${libName}" substring="dylib"/>
				</not>
			</and>
		</condition>
        <fail message="Compiler ${gcc} or ${g++} not found." unless="has-compiler"/>
		%precompile%
	</target>
	
	<target name="create-build-dir" depends="precompile" if="has-compiler">
		<!-- FIXME this is pretty nasty :/ -->
		<copy todir="${buildDir}">
			<fileset refid="g++-files"/>
			<fileset refid="gcc-files"/>
		</copy>
		<delete>
			<fileset dir="${buildDir}">
				<include name="*"/>
				<exclude name="*.o"/>
			</fileset>
		</delete>
	</target>

	<!-- compiles all C and C++ files to object files in the build directory -->
	<target name="compile" depends="create-build-dir" if="has-compiler">
		<mkdir dir="${buildDir}"/>
		<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
			<arg line="${g++-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			%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}" verbose="true">
			<arg line="${gcc-opts}"/>
			<arg value="-Ijni-headers"/>
			<arg value="-Ijni-headers/${jniPlatform}"/>
			<arg value="-I."/>
			%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" depends="compile" if="has-compiler">
		<fileset dir="${buildDir}" id="objFileSet">
			<patternset>
				<include name="**/*.o" />
			</patternset>
		</fileset>
		<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
		<mkdir dir="${libsDir}" />
		<exec executable="${linker}" failonerror="true" dir="${buildDir}">
			<arg line="${linker-opts}" />
			<arg value="-o" />
			<arg path="${libsDir}/${libName}" />
			<arg line="${objFiles}"/>
			<arg line="${libraries}" />
		</exec>
	</target>	

	<!-- strips the shared library of debug symbols -->
	<target name="strip" depends="link" if="should-strip">
		<exec executable="${stripper}" failonerror="true" dir="${buildDir}">
			<arg value="--strip-unneeded"/>
			<arg path="${libsDir}/${libName}" />
		</exec>
	</target>
	
	<target name="postcompile" depends="strip">
		%postcompile%
	</target>
</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy