merged p5 3.0a1

This commit is contained in:
Darius Morawiec
2014-07-31 15:17:43 +02:00
2641 changed files with 37957 additions and 390279 deletions

View File

@@ -422,7 +422,7 @@ public class JavaBuild {
String entry = (dot == -1) ? item : item.substring(0, dot);
// System.out.print(entry + " => ");
if (item.startsWith("static ")) {
if (item.startsWith("static ")) {
// import static - https://github.com/processing/processing/issues/8
// Remove more stuff.
int dot2 = item.lastIndexOf('.');
@@ -472,8 +472,8 @@ public class JavaBuild {
javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1);
}
classPath += File.pathSeparator + javaClassPath;
// But make sure that there isn't anything in there that's missing,
// But make sure that there isn't anything in there that's missing,
// otherwise ECJ will complain and die. For instance, Java 1.7 (or maybe
// it's appbundler?) adds Java/Classes to the path, which kills us.
//String[] classPieces = PApplet.split(classPath, File.pathSeparator);
@@ -549,7 +549,7 @@ public class JavaBuild {
if (pkg.startsWith("processing.data.")) return true;
if (pkg.startsWith("processing.event.")) return true;
if (pkg.startsWith("processing.opengl.")) return true;
// if (pkg.startsWith("com.jogamp.")) return true;
// // ignore core, data, and opengl packages
@@ -1113,11 +1113,11 @@ public class JavaBuild {
File folder = null;
for (String platformName : PConstants.platformNames) {
int platform = Base.getPlatformIndex(platformName);
// Can only embed Java on the native platform
boolean embedJava = (platform == PApplet.platform) &&
boolean embedJava = (platform == PApplet.platform) &&
Preferences.getBoolean("export.application.embed_java");
if (Preferences.getBoolean("export.application.platform." + platformName)) {
if (Library.hasMultipleArch(platform, importedLibraries)) {
// export the 32-bit version
@@ -1216,41 +1216,41 @@ public class JavaBuild {
File jdkFolder = new File(Base.getJavaHome(), "../../..");
String jdkFolderName = jdkFolder.getCanonicalFile().getName();
jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>";
jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName + ".jdk").getAbsolutePath();
jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName).getAbsolutePath();
}
File contentsFolder = new File(dotAppFolder, "Contents");
contentsFolder.mkdirs();
// Info.plist will be written later
// set the jar folder to a different location than windows/linux
//jarFolder = new File(dotAppFolder, "Contents/Resources/Java");
jarFolder = new File(contentsFolder, "Java");
File macosFolder = new File(contentsFolder, "MacOS");
macosFolder.mkdirs();
Base.copyFile(new File(contentsOrig, "MacOS/Processing"),
Base.copyFile(new File(contentsOrig, "MacOS/Processing"),
new File(contentsFolder, "MacOS/" + sketch.getName()));
File pkgInfo = new File(contentsFolder, "PkgInfo");
PrintWriter writer = PApplet.createWriter(pkgInfo);
writer.println("APPL????");
writer.flush();
writer.close();
// Use faster(?) native copy here (also to do sym links)
if (embedJava) {
Base.copyDirNative(new File(contentsOrig, "PlugIns"),
new File(contentsFolder, "PlugIns"));
}
File resourcesFolder = new File(contentsFolder, "Resources");
Base.copyDir(new File(contentsOrig, "Resources/en.lproj"),
Base.copyDir(new File(contentsOrig, "Resources/en.lproj"),
new File(resourcesFolder, "en.lproj"));
Base.copyFile(mode.getContentFile("application/sketch.icns"),
new File(resourcesFolder, "sketch.icns"));
/*
String stubName = "Contents/MacOS/JavaApplicationStub";
// need to set the stub to executable
@@ -1279,7 +1279,7 @@ public class JavaBuild {
if (embedJava) {
Base.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
}
} else if (exportPlatform == PConstants.WINDOWS) {
if (embedJava) {
Base.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
@@ -1312,7 +1312,7 @@ public class JavaBuild {
}
*/
/// start copying all jar files
Vector<String> jarListVector = new Vector<String>();
@@ -1446,7 +1446,11 @@ public class JavaBuild {
}
// https://github.com/processing/processing/issues/2239
runOptions.add("-Djna.nosys=true");
// https://github.com/processing/processing/issues/2559
if (exportPlatform == PConstants.WINDOWS) {
runOptions.add("-Djava.library.path=\"%EXEDIR%\\lib\"");
}
/// macosx: write out Info.plist (template for classpath, etc)
@@ -1457,7 +1461,7 @@ public class JavaBuild {
runOptionsXML.append(opt);
runOptionsXML.append("</string>");
runOptionsXML.append('\n');
}
}
String PLIST_TEMPLATE = "Info.plist.tmpl";
File plistTemplate = new File(sketch.getFolder(), PLIST_TEMPLATE);
@@ -1500,10 +1504,10 @@ public class JavaBuild {
// attempt to code sign if the Xcode tools appear to be installed
if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) {
if (embedJava) {
ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath);
ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath);
}
String appPath = dotAppFolder.getAbsolutePath();
ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath);
ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath);
}
} else if (exportPlatform == PConstants.WINDOWS) {
@@ -1513,27 +1517,27 @@ public class JavaBuild {
XML project = new XML("project");
XML target = project.addChild("target");
target.setString("name", "windows");
XML taskdef = target.addChild("taskdef");
taskdef.setString("name", "launch4j");
taskdef.setString("classname", "net.sf.launch4j.ant.Launch4jTask");
String launchPath = mode.getContentFile("application/launch4j").getAbsolutePath();
taskdef.setString("classpath", launchPath + "/launch4j.jar:" + launchPath + "/lib/xstream.jar");
XML launch4j = target.addChild("launch4j");
// not all launch4j options are available when embedded inside the ant
// build file (i.e. the icon param doesn't work), so use a config file
//<launch4j configFile="windows/work/config.xml" />
launch4j.setString("configFile", configFile.getAbsolutePath());
XML config = new XML("launch4jConfig");
config.addChild("headerType").setContent("gui");
config.addChild("dontWrapJar").setContent("true");
config.addChild("downloadUrl").setContent("http://java.com/download");
File exeFile = new File(destFolder, sketch.getName() + ".exe");
config.addChild("outfile").setContent(exeFile.getAbsolutePath());
File iconFile = mode.getContentFile("application/sketch.ico");
config.addChild("icon").setContent(iconFile.getAbsolutePath());
@@ -1550,7 +1554,7 @@ public class JavaBuild {
for (String opt : runOptions) {
jre.addChild("opt").setContent(opt);
}
/*
XML config = launch4j.addChild("config");
config.setString("headerType", "gui");
@@ -1558,10 +1562,10 @@ public class JavaBuild {
config.setString("outfile", exeFile.getAbsolutePath());
config.setString("dontWrapJar", "true");
config.setString("jarPath", "lib\\" + jarList[0]);
File iconFile = mode.getContentFile("application/sketch.ico");
config.addChild("icon").setContent(iconFile.getAbsolutePath());
XML clazzPath = config.addChild("classPath");
clazzPath.setString("mainClass", sketch.getName());
for (int i = 1; i < jarList.length; i++) {
@@ -1575,11 +1579,11 @@ public class JavaBuild {
jre.addChild("opt").setContent(opt);
}
*/
config.save(configFile);
project.save(buildFile);
if (!buildWindowsLauncher(buildFile, "windows")) {
// don't delete the build file, might be useful for debugging
// don't delete the build file, might be useful for debugging
return false;
}
configFile.delete();
@@ -1597,10 +1601,10 @@ public class JavaBuild {
// another fix for bug #234, LD_LIBRARY_PATH ignored on some platforms
//ps.print("LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR\n");
if (embedJava) {
// https://github.com/processing/processing/issues/2349
// https://github.com/processing/processing/issues/2349
pw.print("$APPDIR/java/bin/");
}
String runOptionsStr =
String runOptionsStr =
PApplet.join(runOptions.toArray(new String[0]), " ");
pw.print("java " + runOptionsStr +
" -Djava.library.path=\"$APPDIR:$APPDIR/lib\"" +
@@ -1646,7 +1650,7 @@ public class JavaBuild {
}
/**
/**
* Run the launch4j build.xml file through ant to create the exe.
* Most of this code was lifted from Android mode.
*/

View File

@@ -289,6 +289,11 @@ public class JavaEditor extends Editor {
}
});
// Only possible to export OS X applications on OS X
if (!Base.isMacOS()) {
// Make sure they don't have a previous 'true' setting for this
Preferences.setBoolean("export.application.platform.macosx", false);
}
final JCheckBox macosxButton = new JCheckBox("Mac OS X");
macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
macosxButton.addItemListener(new ItemListener() {
@@ -296,6 +301,10 @@ public class JavaEditor extends Editor {
Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
}
});
if (!Base.isMacOS()) {
macosxButton.setEnabled(false);
macosxButton.setToolTipText("Mac OS X export is only available on Mac OS X");
}
final JCheckBox linuxButton = new JCheckBox("Linux");
//linuxButton.setMnemonic(KeyEvent.VK_L);

View File

@@ -46,7 +46,7 @@ public class JavaMode extends Mode {
public String getTitle() {
return "Java";
return "Java (2.0)";
}

View File

@@ -194,6 +194,9 @@ public class PdeKeyListener {
textarea.setSelectedText(spaces(tabSize));
event.consume();
return true;
} else if (!Preferences.getBoolean("editor.tabs.expand")) {
textarea.setSelectedText("\t");
event.consume();
}
break;

View File

@@ -63,19 +63,6 @@ public class Runner implements MessageConsumer {
// Thread transferring remote output stream to our output stream
protected Thread outThread = null;
// Mode for tracing the Trace program (default= 0 off)
// protected int debugTraceMode = 0;
// Do we want to watch assignments to fields
// protected boolean watchFields = false;
// // Class patterns for which we don't want events
// protected String[] excludes = {
// "java.*", "javax.*", "sun.*", "com.sun.*",
// "apple.*",
// "processing.*"
// };
protected SketchException exception;
protected Editor editor;
protected JavaBuild build;
@@ -138,60 +125,6 @@ public class Runner implements MessageConsumer {
// Everyone works the same under Java 7 (also on OS X)
String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg };
/*
String[] commandArgs = null;
if (!Base.isMacOS()) {
commandArgs = new String[] {
Base.getJavaPath(),
jdwpArg
};
} else {
// Decided to just set this to 1.6 only, because otherwise it's gonna
// be a shitshow if folks are getting Apple's 1.6 with 32-bit and
// Oracle's 1.7 when run in 64-bit mode. ("Why does my sketch suck in
// 64-bit? Why is retina broken?)
// The --request flag will prompt to install Apple's 1.6 JVM if none is
// available. We're specifying 1.6 so that we can get support for both
// 32- and 64-bit, because Oracle won't be releasing Java 1.7 in 32-bit.
// Helpfully, the --request flag is not present on Mac OS X 10.6
// (luckily it is also not needed, because 1.6 is installed by default)
// but it requires an additional workaround to not use that flag,
// otherwise will see an error about an unsupported option. The flag is
// available with 10.7 and 10.8, the only other supported versions of
// OS X at this point, because we require 10.6.8 and higher. That also
// means we don't need to check for any other OS versions, the user is
// a douchebag and modifies Info.plist to get around the restriction.
if (false) {
if (System.getProperty("os.version").startsWith("10.6")) {
commandArgs = new String[] {
"/usr/libexec/java_home",
"--version", "1.6",
"--exec", "java",
"-d" + Base.getNativeBits(),
jdwpArg
};
} else { // for 10.7, 10.8, etc
commandArgs = new String[] {
"/usr/libexec/java_home",
"--request", // install on-demand
"--version", "1.6",
"--exec", "java",
"-d" + Base.getNativeBits(),
// debugArg,
jdwpArg
};
}
} else {
// testing jdk-7u40
commandArgs = new String[] {
//"/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java",
Base.getJavaPath(),
jdwpArg
};
}
}
*/
commandArgs = PApplet.concat(commandArgs, vmParams);
commandArgs = PApplet.concat(commandArgs, sketchParams);
// PApplet.println(commandArgs);
@@ -482,153 +415,6 @@ public class Runner implements MessageConsumer {
}
/*
protected VirtualMachine launchVirtualMachine(String[] vmParams,
String[] classParams) {
//vm = launchTarget(sb.toString());
LaunchingConnector connector = (LaunchingConnector)
findConnector("com.sun.jdi.RawCommandLineLaunch");
//PApplet.println(connector); // gets the defaults
//Map arguments = connectorArguments(connector, mainArgs);
Map arguments = connector.defaultArguments();
Connector.Argument commandArg =
(Connector.Argument)arguments.get("command");
// Using localhost instead of 127.0.0.1 sometimes causes a
// "Transport Error 202" error message when trying to run.
// http://dev.processing.org/bugs/show_bug.cgi?id=895
// String addr = "127.0.0.1:" + (8000 + (int) (Math.random() * 1000));
//String addr = "localhost:" + (8000 + (int) (Math.random() * 1000));
// Better yet, host is not needed, so using just the port for the address
String addr = "" + (8000 + (int) (Math.random() * 1000));
String commandArgs =
"java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
if (Base.isMacOS()) {
// Decided to just set this to 1.6 only, because otherwise it's gonna
// be a shitshow if folks are getting Apple's 1.6 with 32-bit and
// Oracle's 1.7 when run in 64-bit mode. ("Why does my sketch suck in
// 64-bit? Why is retina broken?)
// The --request flag will prompt to install Apple's 1.6 JVM if none is
// available. We're specifying 1.6 so that we can get support for both
// 32- and 64-bit, because Oracle won't be releasing Java 1.7 in 32-bit.
// Helpfully, the --request flag is not present on Mac OS X 10.6
// (luckily it is also not needed, because 1.6 is installed by default)
// but it requires an additional workaround to not use that flag,
// otherwise will see an error about an unsupported option. The flag is
// available with 10.7 and 10.8, the only other supported versions of
// OS X at this point, because we require 10.6.8 and higher. That also
// means we don't need to check for any other OS versions, unless
// is a douchebag and modifies Info.plist to get around the restriction.
addr = "" + (8000 + (int) (Math.random() * 1000));
commandArgs =
"/usr/libexec/java_home " +
(System.getProperty("os.version").startsWith("10.6") ? "" : "--request ") +
"--version 1.6 " +
"--exec java " +
"-d" + Base.getNativeBits() + " " +
"-Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
}
for (int i = 0; i < vmParams.length; i++) {
commandArgs = addArgument(commandArgs, vmParams[i], ' ');
}
if (classParams != null) {
for (int i = 0; i < classParams.length; i++) {
commandArgs = addArgument(commandArgs, classParams[i], ' ');
}
}
System.out.println("commandArgs is " + commandArgs);
commandArg.setValue(commandArgs);
Connector.Argument addressArg =
(Connector.Argument)arguments.get("address");
addressArg.setValue(addr);
//PApplet.println(connector); // prints the current
//com.sun.tools.jdi.AbstractLauncher al;
//com.sun.tools.jdi.RawCommandLineLauncher rcll;
//System.out.println(PApplet.javaVersion);
// http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html#sunlaunch
try {
return connector.launch(arguments);
} catch (IOException exc) {
throw new Error("Unable to launch target VM: " + exc);
} catch (IllegalConnectorArgumentsException exc) {
throw new Error("Internal error: " + exc);
} catch (VMStartException exc) {
Process p = exc.process();
//System.out.println(p);
String[] errorStrings = PApplet.loadStrings(p.getErrorStream());
//String[] inputStrings =
PApplet.loadStrings(p.getInputStream());
if (errorStrings != null && errorStrings.length > 1) {
if (errorStrings[0].indexOf("Invalid maximum heap size") != -1) {
Base.showWarning("Way Too High",
"Please lower the value for \u201Cmaximum available memory\u201D in the\n" +
"Preferences window. For more information, read Help \u2192 Troubleshooting.",
exc);
} else {
PApplet.println(errorStrings);
System.err.println("Using startup command:");
PApplet.println(arguments);
}
} else {
exc.printStackTrace();
System.err.println("Could not run the sketch (Target VM failed to initialize).");
if (Preferences.getBoolean("run.options.memory")) {
// Only mention this if they've even altered the memory setup
System.err.println("Make sure that you haven't set the maximum available memory too high.");
}
System.err.println("For more information, read revisions.txt and Help \u2192 Troubleshooting.");
}
// changing this to separate editor and listener [091124]
//if (editor != null) {
listener.statusError("Could not run the sketch.");
//}
return null;
}
}
private static boolean hasWhitespace(String string) {
int length = string.length();
for (int i = 0; i < length; i++) {
if (Character.isWhitespace(string.charAt(i))) {
return true;
}
}
return false;
}
private static String addArgument(String string, String argument, char sep) {
if (hasWhitespace(argument) || argument.indexOf(',') != -1) {
// Quotes were stripped out for this argument, add 'em back.
StringBuffer buffer = new StringBuffer(string);
buffer.append('"');
for (int i = 0; i < argument.length(); i++) {
char c = argument.charAt(i);
if (c == '"') {
buffer.append('\\');
// buffer.append("\\\\");
}
buffer.append(c);
}
buffer.append('"');
buffer.append(sep);
return buffer.toString();
} else {
return string + argument + String.valueOf(sep);
}
}
*/
/**
* Generate the trace.
* Enable events, start thread to display events,
@@ -639,9 +425,6 @@ public class Runner implements MessageConsumer {
//vm.setDebugTraceMode(debugTraceMode);
// vm.setDebugTraceMode(VirtualMachine.TRACE_ALL);
// vm.setDebugTraceMode(VirtualMachine.TRACE_NONE); // formerly, seems to have no effect
// For internal debugging
PrintWriter writer = null;
// Calling this seems to set something internally to make the
// Eclipse JDI wake up. Without it, an ObjectCollectedException
@@ -735,7 +518,6 @@ public class Runner implements MessageConsumer {
// we don't interrupt
}
//System.out.println("and leaving");
if (writer != null) writer.close();
}