From d1d5b76b3cb363fcd189105a21b14c4bb6d75cf8 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 19 Oct 2013 22:57:54 -0400 Subject: [PATCH] new export now handles embedding the JRE on OS X --- app/src/processing/mode/java/JavaBuild.java | 68 ++++++++++++------- java/application/Info.plist.tmpl | 75 +++++++++++++++++++++ todo.txt | 3 + 3 files changed, 121 insertions(+), 25 deletions(-) create mode 100644 java/application/Info.plist.tmpl diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index cb80b60e2..aa1fdb83e 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -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 runOptions = new ArrayList(); 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(" "); + jvmOptionsList.append(opt); + jvmOptionsList.append(""); + 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 = "x86_64\n i386"; - if (exportBits == 32) { - arch = "i386"; - } else if (exportBits == 64) { - arch = "x86_64"; - } - 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 = "x86_64\n i386"; +// if (exportBits == 32) { +// arch = "i386"; +// } else if (exportBits == 64) { +// arch = "x86_64"; +// } +// sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch); +// } lines[i] = sb.toString(); } diff --git a/java/application/Info.plist.tmpl b/java/application/Info.plist.tmpl new file mode 100644 index 000000000..787f56ed2 --- /dev/null +++ b/java/application/Info.plist.tmpl @@ -0,0 +1,75 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + @@sketch@@ + CFBundleIconFile + sketch.icns + CFBundleIdentifier + @@sketch@@ + CFBundleDisplayName + @@sketch@@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + @@sketch@@ + CFBundlePackageType + APPL + + + CFBundleShortVersionString + 1 + CFBundleVersion + 1 + CFBundleSignature + ???? + NSHumanReadableCopyright + Your copyright here + CFBundleGetInfoString + Created with Processing + + + JVMRuntime + @@jdk_folder@@ + + JVMMainClassName + @@sketch@@ + + LSMinimumSystemVersion + 10.7.3 + + NSHighResolutionCapable + + + LSArchitecturePriority + + x86_64 + + + LSEnvironment + + LC_CTYPE + UTF-8 + + + LSUIPresentationMode + @@lsuipresentationmode@@ + + JVMOptions + + @@jvm_options_list@@ + -Xdock:icon=Contents/Resources/sketch.icns + -Dapple.laf.useScreenMenuBar=true + -Dcom.apple.macos.use-file-dialog-packages=true + -Dcom.apple.macos.useScreenMenuBar=true + -Dcom.apple.mrj.application.apple.menu.about.name=@@sketch@@ + -Dcom.apple.smallTabs=true + + JVMArguments + + + + diff --git a/todo.txt b/todo.txt index 5557df2eb..53cc4c78f 100644 --- a/todo.txt +++ b/todo.txt @@ -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§ion=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