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)); } }
/** Returns the paths to the children of this directory. Returns an empty list if this file handle represents a file and not a * directory. On the desktop, an FileType#Internal handle to a directory on the classpath will return a zero length array. * @throw RuntimeException if this file is an {@link FileType#Classpath} file. */ public FileDescriptor[] list () { if (type == FileType.Classpath) throw new RuntimeException("Cannot list a classpath directory: " + file); String[] relativePaths = file().list(); if (relativePaths == null) return new FileDescriptor[0]; FileDescriptor[] handles = new FileDescriptor[relativePaths.length]; for (int i = 0, n = relativePaths.length; i < n; i++) handles[i] = child(relativePaths[i]); return handles; }
/** Returns the paths to the children of this directory. Returns an empty list if this file handle represents a file and not a * directory. On the desktop, an FileType#Internal handle to a directory on the classpath will return a zero length array. * @throw RuntimeException if this file is an {@link FileType#Classpath} file. */ public FileDescriptor[] list () { if (type == FileType.Classpath) throw new RuntimeException("Cannot list a classpath directory: " + file); String[] relativePaths = file().list(); if (relativePaths == null) return new FileDescriptor[0]; FileDescriptor[] handles = new FileDescriptor[relativePaths.length]; for (int i = 0, n = relativePaths.length; i < n; i++) handles[i] = child(relativePaths[i]); return handles; }
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)); } }
private String getLibsDirectory (BuildConfig config, BuildTarget target) { String targetName = target.osFileName; if (targetName == null) targetName = target.os.toString().toLowerCase() + (target.is64Bit ? "64" : "32"); return config.libsDir.child(targetName).path().replace('\\', '/'); }
private String getLibsDirectory (BuildConfig config, BuildTarget target) { String targetName = target.osFileName; if (targetName == null) targetName = target.os.toString().toLowerCase() + (target.is64Bit ? "64" : "32"); return config.libsDir.child(targetName).path().replace('\\', '/'); }
/** Returns the paths to the children of this directory with the specified suffix. Returns an empty list if this file handle * represents a file and not a directory. On the desktop, an FileType#Internal handle to a directory on the classpath will * return a zero length array. * @throw RuntimeException if this file is an {@link FileType#Classpath} file. */ public FileDescriptor[] list (String suffix) { if (type == FileType.Classpath) throw new RuntimeException("Cannot list a classpath directory: " + file); String[] relativePaths = file().list(); if (relativePaths == null) return new FileDescriptor[0]; FileDescriptor[] handles = new FileDescriptor[relativePaths.length]; int count = 0; for (int i = 0, n = relativePaths.length; i < n; i++) { String path = relativePaths[i]; if (!path.endsWith(suffix)) continue; handles[count] = child(path); count++; } if (count < relativePaths.length) { FileDescriptor[] newHandles = new FileDescriptor[count]; System.arraycopy(handles, 0, newHandles, 0, count); handles = newHandles; } return handles; }
/** Returns the paths to the children of this directory with the specified suffix. Returns an empty list if this file handle * represents a file and not a directory. On the desktop, an FileType#Internal handle to a directory on the classpath will * return a zero length array. * @throw RuntimeException if this file is an {@link FileType#Classpath} file. */ public FileDescriptor[] list (String suffix) { if (type == FileType.Classpath) throw new RuntimeException("Cannot list a classpath directory: " + file); String[] relativePaths = file().list(); if (relativePaths == null) return new FileDescriptor[0]; FileDescriptor[] handles = new FileDescriptor[relativePaths.length]; int count = 0; for (int i = 0, n = relativePaths.length; i < n; i++) { String path = relativePaths[i]; if (!path.endsWith(suffix)) continue; handles[count] = child(path); count++; } if (count < relativePaths.length) { FileDescriptor[] newHandles = new FileDescriptor[count]; System.arraycopy(handles, 0, newHandles, 0, count); handles = newHandles; } return handles; }
FileDescriptor application = config.jniDir.child("Application.mk"); application.writeString(new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/Application.mk.template", FileType.Classpath).readString(), false); template = template.replace("%srcFiles%", srcFiles); config.jniDir.child("Android.mk").writeString(template, false);
template = template.replace("%buildDir%", config.buildDir.child(targetFolder).path().replace('\\', '/')); template = template.replace("%libsDir%", "../" + getLibsDirectory(config, target)); template = template.replace("%libName%", libName);
FileDescriptor application = config.jniDir.child("Application.mk"); application.writeString(new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/Application.mk.template", FileType.Classpath).readString(), false); template = template.replace("%srcFiles%", srcFiles); config.jniDir.child("Android.mk").writeString(template, false);
template = template.replace("%buildDir%", config.buildDir.child(targetFolder).path().replace('\\', '/')); template = template.replace("%libsDir%", "../" + getLibsDirectory(config, target)); template = template.replace("%libName%", libName);
if (config.jniDir.child("memcpy_wrap.c").exists() == false) { new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/memcpy_wrap.c", FileType.Classpath).copyTo(config.jniDir .child("memcpy_wrap.c")); config.jniDir.child(buildFileName).writeString(buildFile, false); System.out.println("Wrote target '" + target.os + (target.is64Bit ? "64" : "") + "' build script '" + config.jniDir.child(buildFileName) + "'"); template = template.replace("<pack/>", pack); config.jniDir.child("build.xml").writeString(template, false); System.out.println("Wrote master build script '" + config.jniDir.child("build.xml") + "'");
if (config.jniDir.child("memcpy_wrap.c").exists() == false) { new FileDescriptor("com/badlogic/gdx/jnigen/resources/scripts/memcpy_wrap.c", FileType.Classpath).copyTo(config.jniDir .child("memcpy_wrap.c")); config.jniDir.child(buildFileName).writeString(buildFile, false); System.out.println("Wrote target '" + target.os + (target.is64Bit ? "64" : "") + "' build script '" + config.jniDir.child(buildFileName) + "'"); template = template.replace("<pack/>", pack); config.jniDir.child("build.xml").writeString(template, false); System.out.println("Wrote master build script '" + config.jniDir.child("build.xml") + "'");
/** Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a * file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination * doesn't exist, {@link #mkdirs()} is called on the destination's parent and this file is copied into it with a new name. If * this handle is a directory, then 1) if the destination is a file, RuntimeException is thrown, or 2) if the destination is a * directory, this directory is copied recursively into it as a subdirectory, overwriting existing files, or 3) if the * destination doesn't exist, {@link #mkdirs()} is called on the destination and this directory is copied recursively into it * as a subdirectory. * @throw RuntimeException if the destination file handle is a {@link FileType#Classpath} or FileType#Internal file, or copying * failed. */ public void copyTo (FileDescriptor dest) { if (!isDirectory()) { if (dest.isDirectory()) dest = dest.child(name()); copyFile(this, dest); return; } if (dest.exists()) { if (!dest.isDirectory()) throw new RuntimeException("Destination exists but is not a directory: " + dest); } else { dest.mkdirs(); if (!dest.isDirectory()) throw new RuntimeException("Destination directory cannot be created: " + dest); } dest = dest.child(name()); copyDirectory(this, dest); }
/** Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a * file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination * doesn't exist, {@link #mkdirs()} is called on the destination's parent and this file is copied into it with a new name. If * this handle is a directory, then 1) if the destination is a file, RuntimeException is thrown, or 2) if the destination is a * directory, this directory is copied recursively into it as a subdirectory, overwriting existing files, or 3) if the * destination doesn't exist, {@link #mkdirs()} is called on the destination and this directory is copied recursively into it * as a subdirectory. * @throw RuntimeException if the destination file handle is a {@link FileType#Classpath} or FileType#Internal file, or copying * failed. */ public void copyTo (FileDescriptor dest) { if (!isDirectory()) { if (dest.isDirectory()) dest = dest.child(name()); copyFile(this, dest); return; } if (dest.exists()) { if (!dest.isDirectory()) throw new RuntimeException("Destination exists but is not a directory: " + dest); } else { dest.mkdirs(); if (!dest.isDirectory()) throw new RuntimeException("Destination directory cannot be created: " + dest); } dest = dest.child(name()); copyDirectory(this, dest); }
static private void copyDirectory (FileDescriptor sourceDir, FileDescriptor destDir) { destDir.mkdirs(); FileDescriptor[] files = sourceDir.list(); for (int i = 0, n = files.length; i < n; i++) { FileDescriptor srcFile = files[i]; FileDescriptor destFile = destDir.child(srcFile.name()); if (srcFile.isDirectory()) copyDirectory(srcFile, destFile); else copyFile(srcFile, destFile); } } }
static private void copyDirectory (FileDescriptor sourceDir, FileDescriptor destDir) { destDir.mkdirs(); FileDescriptor[] files = sourceDir.list(); for (int i = 0, n = files.length; i < n; i++) { FileDescriptor srcFile = files[i]; FileDescriptor destFile = destDir.child(srcFile.name()); if (srcFile.isDirectory()) copyDirectory(srcFile, destFile); else copyFile(srcFile, destFile); } } }
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)); } }
private String getLibsDirectory (BuildConfig config, BuildTarget target) { String targetName = target.osFileName; if (targetName == null) targetName = target.os.toString().toLowerCase() + (target.is64Bit ? "64" : "32"); return config.libsDir.child(targetName).path().replace('\\', '/'); }