public static void main(String[] args) throws Exception { BuildTarget win32 = BuildTarget.newDefaultTarget(TargetOs.Windows, false); BuildTarget win64 = BuildTarget.newDefaultTarget(TargetOs.Windows, true); BuildTarget lin32 = BuildTarget.newDefaultTarget(TargetOs.Linux, false); BuildTarget lin64 = BuildTarget.newDefaultTarget(TargetOs.Linux, true); BuildTarget android = BuildTarget.newDefaultTarget(TargetOs.Android, false); BuildTarget mac32 = BuildTarget.newDefaultTarget(TargetOs.MacOsX, false); BuildTarget mac64 = BuildTarget.newDefaultTarget(TargetOs.MacOsX, true); BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false); new NativeCodeGenerator().generate("src", "bin" + File.pathSeparator + "../../../gdx/bin", "jni"); new AntScriptGenerator().generate(new BuildConfig("gdx-box2d"), win32, win64, lin32, lin64, mac32, mac64, android, ios); } }
/** Execute ndk-build in the given directory * @param directory */ public static void executeNdk (String directory) { FileDescriptor build = new FileDescriptor(directory); String command = "ndk-build"; startProcess(command, build.file()); }
/** Creates a new BuildConfig. All paths are relative to the application's working directory. * @param sharedLibName the shared library name, without prefix or suffix, e.g. 'gdx', 'bullet' * @param temporaryDir * @param libsDir * @param jniDir */ public BuildConfig (String sharedLibName, String temporaryDir, String libsDir, String jniDir) { this.sharedLibName = sharedLibName; this.buildDir = new FileDescriptor(temporaryDir); this.libsDir = new FileDescriptor(libsDir); this.jniDir = new FileDescriptor(jniDir); } }
/** Generates .h/.cpp files from the Java files found in "src/", with their .class files being in "bin/". The generated files * will be stored in "jni/". All paths are relative to the applications working directory. * @throws Exception */ public void generate () throws Exception { generate("src", "bin", "jni", null, null); }
private void copyJniHeaders (String jniDir) { final String pack = "com/badlogic/gdx/jnigen/resources/headers"; String files[] = {"classfile_constants.h", "jawt.h", "jdwpTransport.h", "jni.h", "linux/jawt_md.h", "linux/jni_md.h", "mac/jni_md.h", "win32/jawt_md.h", "win32/jni_md.h"}; for (String file : files) { new FileDescriptor(pack, FileType.Classpath).child(file).copyTo( new FileDescriptor(jniDir).child("jni-headers").child(file)); } }
/** Reads the entire file into a string using the platform's default charset. * @throw RuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */ public String readString () { return readString(null); }
/** Returns a writer for writing to this file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throw RuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * FileType#Internal file, or if it could not be written. */ public Writer writer (boolean append) { return writer(append, null); }
/** Writes the specified string to the file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throw RuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * FileType#Internal file, or if it could not be written. */ public void writeString (String string, boolean append) { writeString(string, append, null); }
public boolean match (String file, String[] patterns) { if (patterns == null || patterns.length == 0) return true; for (String pattern : patterns) { if (match(pattern, file)) { return true; } } return false; }
/** Generates .h/.cpp fiels from the Java files found in <code>sourceDir</code>, with their .class files being in * <code>classpath</code>. The generated files will be stored in <code>jniDir</code>. All paths are relative to the * applications working directory. * @param sourceDir the directory containing the Java files * @param classpath the directory containing the .class files * @param jniDir the output directory * @throws Exception */ public void generate (String sourceDir, String classpath, String jniDir) throws Exception { generate(sourceDir, classpath, jniDir, null, null); }
/** Execute ndk-build in the given directory * @param directory */ public static void executeNdk (String directory) { FileDescriptor build = new FileDescriptor(directory); String command = "ndk-build"; startProcess(command, build.file()); }
/** Creates a new BuildConfig. The build directory, the libs directory and the jni directory are assumed to be "target", "libs" * and "jni". All paths are relative to the application's working directory. * @param sharedLibName the shared library name, without prefix or suffix, e.g. 'gdx', 'bullet' */ public BuildConfig (String sharedLibName) { this.sharedLibName = sharedLibName; this.buildDir = new FileDescriptor("target"); this.libsDir = new FileDescriptor("libs"); this.jniDir = new FileDescriptor("jni"); }
/** Reads the entire file into a string using the platform's default charset. * @throw RuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */ public String readString () { return readString(null); }
/** Returns a writer for writing to this file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throw RuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * FileType#Internal file, or if it could not be written. */ public Writer writer (boolean append) { return writer(append, null); }
/** Writes the specified string to the file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throw RuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * FileType#Internal file, or if it could not be written. */ public void writeString (String string, boolean append) { writeString(string, append, null); }
public boolean match (String file, String[] patterns) { if (patterns == null || patterns.length == 0) return true; for (String pattern : patterns) { if (match(pattern, file)) { return true; } } return false; }
/** Generates .h/.cpp fiels from the Java files found in <code>sourceDir</code>, with their .class files being in * <code>classpath</code>. The generated files will be stored in <code>jniDir</code>. All paths are relative to the * applications working directory. * @param sourceDir the directory containing the Java files * @param classpath the directory containing the .class files * @param jniDir the output directory * @throws Exception */ public void generate (String sourceDir, String classpath, String jniDir) throws Exception { generate(sourceDir, classpath, jniDir, null, null); }
/** Creates a new BuildConfig. All paths are relative to the application's working directory. * @param sharedLibName the shared library name, without prefix or suffix, e.g. 'gdx', 'bullet' * @param temporaryDir * @param libsDir * @param jniDir */ public BuildConfig (String sharedLibName, String temporaryDir, String libsDir, String jniDir) { this.sharedLibName = sharedLibName; this.buildDir = new FileDescriptor(temporaryDir); this.libsDir = new FileDescriptor(libsDir); this.jniDir = new FileDescriptor(jniDir); } }
/** Generates .h/.cpp files from the Java files found in "src/", with their .class files being in "bin/". The generated files * will be stored in "jni/". All paths are relative to the applications working directory. * @throws Exception */ public void generate () throws Exception { generate("src", "bin", "jni", null, null); }
/** Creates a new BuildConfig. The build directory, the libs directory and the jni directory are assumed to be "target", "libs" * and "jni". All paths are relative to the application's working directory. * @param sharedLibName the shared library name, without prefix or suffix, e.g. 'gdx', 'bullet' */ public BuildConfig (String sharedLibName) { this.sharedLibName = sharedLibName; this.buildDir = new FileDescriptor("target"); this.libsDir = new FileDescriptor("libs"); this.jniDir = new FileDescriptor("jni"); }