From 935c509abcf1b0dfb7a045f0d65aac71f44787a8 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 25 Oct 2013 15:43:33 -0400 Subject: [PATCH] get Commander working on OS X, addl updates --- app/src/processing/app/Base.java | 32 ++++++++++++----- app/src/processing/app/Preferences.java | 4 ++- .../app/tools/InstallCommander.java | 30 ++++++++-------- app/src/processing/mode/java/Commander.java | 35 ++++++------------- build/build.xml | 2 +- .../lib/{preferences.txt => defaults.txt} | 0 6 files changed, 52 insertions(+), 51 deletions(-) rename build/shared/lib/{preferences.txt => defaults.txt} (100%) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index f74c6dc00..c5dc98d02 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1592,18 +1592,29 @@ public class Base { } - /** - * Return whether sketches will run as 32- or 64-bits. On Linux and Windows, - * this is the bit depth of the machine, while on OS X it's determined by the - * setting from preferences, since both 32- and 64-bit are supported. + // Because the Oracle JDK is 64-bit only, we lose this ability, feature, + // edge case, headache. +// /** +// * Return whether sketches will run as 32- or 64-bits. On Linux and Windows, +// * this is the bit depth of the machine, while on OS X it's determined by the +// * setting from preferences, since both 32- and 64-bit are supported. +// */ +// static public int getNativeBits() { +// if (Base.isMacOS()) { +// return Preferences.getInteger("run.options.bits"); //$NON-NLS-1$ +// } +// return nativeBits; +// } + + /** + * Return whether sketches will run as 32- or 64-bits based + * on the JVM that's in use. */ static public int getNativeBits() { - if (Base.isMacOS()) { - return Preferences.getInteger("run.options.bits"); //$NON-NLS-1$ - } return nativeBits; } + /* static public String getPlatformName() { String osname = System.getProperty("os.name"); @@ -2419,7 +2430,12 @@ public class Base { /** Get the path to the embedded Java executable. */ static public String getJavaPath() { String javaPath = "bin/java" + (isWindows() ? ".exe" : ""); - return new File(getJavaHome(), javaPath).getAbsolutePath(); + File javaFile = new File(getJavaHome(), javaPath); + try { + return javaFile.getCanonicalPath(); + } catch (IOException e) { + return javaFile.getAbsolutePath(); + } /* if (isMacOS()) { //return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java"; diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 77eb15c42..8c5d6dcde 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -145,7 +145,9 @@ public class Preferences { // start by loading the defaults, in case something // important was deleted from the user prefs try { - load(Base.getLibStream("preferences.txt")); //$NON-NLS-1$ + // Name changed for 2.1b2 to avoid problems with users modifying or + // replacing the file after doing a search for "preferences.txt". + load(Base.getLibStream("defaults.txt")); //$NON-NLS-1$ } catch (Exception e) { Base.showError(null, "Could not read default settings.\n" + "You'll need to reinstall Processing.", e); diff --git a/app/src/processing/app/tools/InstallCommander.java b/app/src/processing/app/tools/InstallCommander.java index 461a80dba..c3133de1b 100644 --- a/app/src/processing/app/tools/InstallCommander.java +++ b/app/src/processing/app/tools/InstallCommander.java @@ -80,30 +80,28 @@ public class InstallCommander implements Tool { writer.println("#!/bin/sh"); String[] jarList = new String[] { - "lib/pde.jar", - "lib/antlr.jar", - "lib/jna.jar", - "lib/ant.jar", - "lib/ant-launcher.jar", + "pde.jar", + "antlr.jar", + "jna.jar", + "ant.jar", + "ant-launcher.jar", // extra libraries for new JDI setup - "lib/org-netbeans-swing-outline.jar", - "lib/com.ibm.icu_4.4.2.v20110823.jar", - "lib/jdi.jar", - "lib/jdimodel.jar", - "lib/org.eclipse.osgi_3.8.1.v20120830-144521.jar", + "org-netbeans-swing-outline.jar", + "com.ibm.icu_4.4.2.v20110823.jar", + "jdi.jar", + "jdimodel.jar", + "org.eclipse.osgi_3.8.1.v20120830-144521.jar", "core/library/core.jar" }; String classPath = PApplet.join(jarList, ":"); - String javaRoot = System.getProperty("javaroot"); + //String javaRoot = System.getProperty("javaroot"); + String javaRoot = Base.getContentFile(".").getCanonicalPath(); writer.println("cd \"" + javaRoot + "\" && " + - "/usr/libexec/java_home " + - "--request " + - "--version 1.6 " + - "--exec java " + - "-cp " + classPath + + Base.getJavaPath() + + " -cp \"" + classPath + "\"" + " processing.mode.java.Commander \"$@\""); writer.flush(); writer.close(); diff --git a/app/src/processing/mode/java/Commander.java b/app/src/processing/mode/java/Commander.java index 72dff1808..e77f8c80d 100644 --- a/app/src/processing/mode/java/Commander.java +++ b/app/src/processing/mode/java/Commander.java @@ -67,26 +67,7 @@ public class Commander implements RunnerListener { PrintStream systemErr; - static public void main(String[] args) { - /* - if (args == null || args.length == 0) { -// System.out.println(System.getProperty("user.dir")); - args = new String[] { - "--export", -// "--build", -// "--run", -// "--present", - "--force", -// "--platform=windows", - "--platform=macosx", - "--bits=64", - "--sketch=/Users/fry/coconut/processing/java/examples/Basics/Lights/Directional", -// "--sketch=/Users/fry/coconut/sketchbook/sketchbook_libraries_test", - "--output=/Users/fry/Desktop/test-build" - }; - } - */ - + static public void main(String[] args) { // Do this early so that error messages go to the console Base.setCommandLine(); // init the platform so that prefs and other native code is ready to go @@ -108,7 +89,8 @@ public class Commander implements RunnerListener { boolean force = false; // replace that no good output folder // String preferencesPath = null; int platform = PApplet.platform; // default to this platform - int platformBits = 0; +// int platformBits = 0; + int platformBits = Base.getNativeBits(); int task = HELP; boolean embedJava = true; @@ -123,6 +105,9 @@ public class Commander implements RunnerListener { System.exit(1); } +// File preferencesFile = Base.getSettingsFile("preferences.txt"); +// System.out.println("Preferences file at " + preferencesFile.getAbsolutePath()); + for (String arg : args) { if (arg.length() == 0) { // ignore it, just the crappy shell script @@ -280,10 +265,10 @@ public class Commander implements RunnerListener { // if (platformBits == 0) { // platformBits = Base.getNativeBits(); // } - if (platformBits == 0 && - Library.hasMultipleArch(platform, build.getImportedLibraries())) { - complainAndQuit("This sketch can be exported for 32- or 64-bit, please specify one.", true); - } +// if (platformBits == 0 && +// Library.hasMultipleArch(platform, build.getImportedLibraries())) { +// complainAndQuit("This sketch can be exported for 32- or 64-bit, please specify one.", true); +// } success = build.exportApplication(outputFolder, platform, platformBits, embedJava); } } diff --git a/build/build.xml b/build/build.xml index f538c898e..f53bda25a 100755 --- a/build/build.xml +++ b/build/build.xml @@ -570,7 +570,7 @@ - + diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/defaults.txt similarity index 100% rename from build/shared/lib/preferences.txt rename to build/shared/lib/defaults.txt