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
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.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | generate(BuildConfig
the config, BuildTarget... BuildConfiglist of targets)BuildTarget instancesCreates a master build script and one build script for each target to generated native shared libraries. |
| private String | |
| public static String |
| AntScriptGenerator | back to summary |
|---|---|
| public AntScriptGenerator() | |
| copyJniHeaders | back to summary |
|---|---|
| private void copyJniHeaders(String jniDir) | |
| generate | back 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.
| |
| generateBuildTargetTemplate | back to summary |
|---|---|
| private String generateBuildTargetTemplate(BuildConfig config, BuildTarget target) | |
| getLibsDirectory | back to summary |
|---|---|
| public static String getLibsDirectory(BuildConfig config, BuildTarget target) | |