Top Description Constructors Methods
com.badlogic.gdx.jnigen

public Class AntScriptGenerator

extends Object
Class Inheritance
Imports
java.util.ArrayList, com.badlogic.gdx.utils.Os, com.badlogic.gdx.jnigen.FileDescriptor.FileType

Generates Ant scripts for multiple native build targets based on the given BuildConfig. For each build target, an Ant build script is created that will compile C/C++ files to a shared library for a specific platform. A master build script is generated that will execute the build scripts for each platform and bundles their shared libraries into a Jar file containing all shared libraries for all desktop platform targets, and armeabi/ and armeabi-v7a/ folders containing the shard libraries for Android. The scripts can be executed from the command line or via the BuildExecutor. The resulting shared libraries can be loaded with the SharedLibraryLoader which will load the correct shared library from the natives jar/arm folders based on the platform the application is running on

A common use case looks like this:
BuildTarget win32 = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._32);
BuildTarget win64 = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64);
BuildTarget linux32 = BuildTarget.newDefaultTarget(Os.Linux, Architecture.Bitness._32);
BuildTarget linux64 = BuildTarget.newDefaultTarget(Os.Linux, Architecture.Bitness._64);
BuildTarget mac = BuildTarget.newDefaultTarget(Os.MacOsX, Architecture.Bitness._32);
BuildTarget android = BuildTarget.newDefaultTarget(Os.Android, Architecture.Bitness._32);
BuildConfig config = new BuildConfig("mysharedlibrary");

new AntScriptGenerator().generate(config, win32, win64, linux32, linux64, mac, android);
BuildExecutor.executeAnt("jni/build.xml", "clean", "all", "-v");

// assuming the natives jar is on the classpath of the application 
new SharedLibraryLoader().load("mysharedlibrary)

This will create the build scripts and execute the build of the shared libraries for each platform, provided that the compilers are available on the system. Mac OS X might have to be treated separately as there are no cross-compilers for it.

The generator will also copy the necessary JNI headers to the jni/jni-headers folder for Windows, Linux and Mac OS X.

Author
mzechner

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public void
generate(BuildConfig config, BuildTarget...
list of BuildTarget instances
targets
)

Creates a master build script and one build script for each target to generated native shared libraries.

private String
public static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AntScriptGeneratorback to summary
public AntScriptGenerator()

Method Detail

copyJniHeadersback to summary
private void copyJniHeaders(String jniDir)
generateback to summary
public void generate(BuildConfig config, BuildTarget... targets)

Creates a master build script and one build script for each target to generated native shared libraries.

Parameters
config:BuildConfig

the BuildConfig

targets:BuildTarget[]

list of BuildTarget instances

generateBuildTargetTemplateback to summary
private String generateBuildTargetTemplate(BuildConfig config, BuildTarget target)
getLibsDirectoryback to summary
public static String getLibsDirectory(BuildConfig config, BuildTarget target)