get Commander working on OS X, addl updates

This commit is contained in:
Ben Fry
2013-10-25 15:43:33 -04:00
parent d291df309b
commit 935c509abc
6 changed files with 52 additions and 51 deletions
+24 -8
View File
@@ -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";
+3 -1
View File
@@ -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);
@@ -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();
+10 -25
View File
@@ -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);
}
}
+1 -1
View File
@@ -570,7 +570,7 @@
</bundleapp>
<copy todir="macosx/work/Processing.app/Contents/Java">
<fileset dir=".." includes="core/library/**" />
<fileset dir=".." includes="core/library/**" /> <!-- why this? -->
<fileset dir="shared" includes="launch4j/**" />
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />