new export now handles embedding the JRE on OS X

This commit is contained in:
Ben Fry
2013-10-19 22:57:54 -04:00
parent 9d0bfd3f9d
commit d1d5b76b3c
3 changed files with 121 additions and 25 deletions
+43 -25
View File
@@ -1160,10 +1160,13 @@ public class JavaBuild {
/// on macosx, need to copy .app skeleton since that's
/// also where the jar files will be placed
File dotAppFolder = null;
String jdkFolderName = null;
if (exportPlatform == PConstants.MACOSX) {
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
File jdkFolder = new File(Base.getJavaHome(), "../../..");
jdkFolderName = jdkFolder.getCanonicalFile().getName();
// File dotAppSkeleton = mode.getContentFile("application/template.app");
// Base.copyDir(dotAppSkeleton, dotAppFolder);
@@ -1409,13 +1412,22 @@ public class JavaBuild {
/// figure out run options for the VM
String runOptions = Preferences.get("run.options");
// this is too vague. if anyone is using it, we can bring it back
// String runOptions = Preferences.get("run.options");
List<String> runOptions = new ArrayList<String>();
if (Preferences.getBoolean("run.options.memory")) {
runOptions += " -Xms" +
Preferences.get("run.options.memory.initial") + "m";
runOptions += " -Xmx" +
Preferences.get("run.options.memory.maximum") + "m";
runOptions.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
runOptions.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
}
StringBuilder jvmOptionsList = new StringBuilder();
for (String opt : runOptions) {
jvmOptionsList.append(" <string>");
jvmOptionsList.append(opt);
jvmOptionsList.append("</string>");
jvmOptionsList.append('\n');
}
// if (exportPlatform == PConstants.MACOSX) {
// // If no bits specified (libs are all universal, or no native libs)
// // then exportBits will be 0, and can be controlled via "Get Info".
@@ -1430,10 +1442,12 @@ public class JavaBuild {
/// macosx: write out Info.plist (template for classpath, etc)
if (exportPlatform == PConstants.MACOSX) {
String PLIST_TEMPLATE = "template.plist";
//String PLIST_TEMPLATE = "template.plist";
String PLIST_TEMPLATE = "Info.plist.tmpl";
File plistTemplate = new File(sketch.getFolder(), PLIST_TEMPLATE);
if (!plistTemplate.exists()) {
plistTemplate = mode.getContentFile("application/template.plist");
//plistTemplate = mode.getContentFile("application/template.plist");
plistTemplate = mode.getContentFile("application/Info.plist.tmpl");
}
File plistFile = new File(dotAppFolder, "Contents/Info.plist");
PrintWriter pw = PApplet.createWriter(plistFile);
@@ -1443,33 +1457,37 @@ public class JavaBuild {
if (lines[i].indexOf("@@") != -1) {
StringBuffer sb = new StringBuffer(lines[i]);
int index = 0;
while ((index = sb.indexOf("@@vmoptions@@")) != -1) {
sb.replace(index, index + "@@vmoptions@@".length(),
runOptions);
while ((index = sb.indexOf("@@jdk_folder@@")) != -1) {
sb.replace(index, index + "@@jdk_folder@@".length(),
jdkFolderName);
}
while ((index = sb.indexOf("@@jvm_options_list@@")) != -1) {
sb.replace(index, index + "@@jvm_options_list@@".length(),
jvmOptionsList.toString());
}
while ((index = sb.indexOf("@@sketch@@")) != -1) {
sb.replace(index, index + "@@sketch@@".length(),
sketch.getName());
}
while ((index = sb.indexOf("@@classpath@@")) != -1) {
sb.replace(index, index + "@@classpath@@".length(),
exportClassPath.toString());
}
// while ((index = sb.indexOf("@@classpath@@")) != -1) {
// sb.replace(index, index + "@@classpath@@".length(),
// exportClassPath.toString());
// }
while ((index = sb.indexOf("@@lsuipresentationmode@@")) != -1) {
sb.replace(index, index + "@@lsuipresentationmode@@".length(),
Preferences.getBoolean("export.application.fullscreen") ? "4" : "0");
}
while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
// More about this mess: http://support.apple.com/kb/TS2827
// First default to exportBits == 0 case
String arch = "<string>x86_64</string>\n <string>i386</string>";
if (exportBits == 32) {
arch = "<string>i386</string>";
} else if (exportBits == 64) {
arch = "<string>x86_64</string>";
}
sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
}
// while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
// // More about this mess: http://support.apple.com/kb/TS2827
// // First default to exportBits == 0 case
// String arch = "<string>x86_64</string>\n <string>i386</string>";
// if (exportBits == 32) {
// arch = "<string>i386</string>";
// } else if (exportBits == 64) {
// arch = "<string>x86_64</string>";
// }
// sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
// }
lines[i] = sb.toString();
}
+75
View File
@@ -0,0 +1,75 @@
<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@@sketch@@</string>
<key>CFBundleIconFile</key>
<string>sketch.icns</string>
<key>CFBundleIdentifier</key>
<string>@@sketch@@</string>
<key>CFBundleDisplayName</key>
<string>@@sketch@@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@@sketch@@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<!-- Customize this set as you wish -->
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
<string>Your copyright here</string>
<key>CFBundleGetInfoString</key>
<string>Created with Processing</string>
<!-- End of the set that can be customized -->
<key>JVMRuntime</key>
<string>@@jdk_folder@@</string>
<key>JVMMainClassName</key>
<string>@@sketch@@</string>
<key>LSMinimumSystemVersion</key>
<string>10.7.3</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
</array>
<key>LSEnvironment</key>
<dict>
<key>LC_CTYPE</key>
<string>UTF-8</string>
</dict>
<key>LSUIPresentationMode</key>
<integer>@@lsuipresentationmode@@</integer>
<key>JVMOptions</key>
<array>
@@jvm_options_list@@
<string>-Xdock:icon=Contents/Resources/sketch.icns</string>
<string>-Dapple.laf.useScreenMenuBar=true</string>
<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>
<string>-Dcom.apple.mrj.application.apple.menu.about.name=@@sketch@@</string>
<string>-Dcom.apple.smallTabs=true</string>
</array>
<key>JVMArguments</key>
<array>
</array>
</dict>
</plist>
+3
View File
@@ -161,6 +161,9 @@ _ and where the font is needed most
_ make note of this on the platforms page
_ also make note re: only JRE needed (instead of JDK)
_ http://wiki.processing.org/index.php?title=Supported_Platforms&action=edit&section=4
_ now Info.plist.tmpl instead of template.plist
_ can be embedded in a sketch
_ name change due to major modifications
7u40 macosx
X make OS X launch from its local JRE