mirror of
https://github.com/processing/processing4.git
synced 2026-02-15 11:25:38 +01:00
Add option to not embed the Java runtime
This commit is contained in:
@@ -48,6 +48,7 @@ public class Commander implements RunnerListener {
|
||||
static final String forceArg = "--force";
|
||||
static final String outputArg = "--output=";
|
||||
static final String exportApplicationArg = "--export";
|
||||
static final String noJavaArg = "--export";
|
||||
static final String platformArg = "--platform=";
|
||||
static final String bitsArg = "--bits=";
|
||||
// static final String preferencesArg = "--preferences=";
|
||||
@@ -109,6 +110,7 @@ public class Commander implements RunnerListener {
|
||||
int platform = PApplet.platform; // default to this platform
|
||||
int platformBits = 0;
|
||||
int task = HELP;
|
||||
boolean embedJava = true;
|
||||
|
||||
// Turns out the output goes as MacRoman or something else useless.
|
||||
// http://code.google.com/p/processing/issues/detail?id=1418
|
||||
@@ -145,6 +147,9 @@ public class Commander implements RunnerListener {
|
||||
|
||||
} else if (arg.equals(exportApplicationArg)) {
|
||||
task = EXPORT;
|
||||
|
||||
} else if (arg.equals(noJavaArg)) {
|
||||
embedJava = false;
|
||||
|
||||
} else if (arg.startsWith(platformArg)) {
|
||||
complainAndQuit("The --platform option has been removed from Processing 2.1.", false);
|
||||
@@ -156,7 +161,7 @@ public class Commander implements RunnerListener {
|
||||
// }
|
||||
|
||||
} else if (arg.startsWith(bitsArg)) {
|
||||
complainAndQuit("The --platform option has been removed from Processing 2.1.", false);
|
||||
complainAndQuit("The --bits option has been removed from Processing 2.1.", false);
|
||||
// String bitsStr = arg.substring(bitsArg.length());
|
||||
// if (bitsStr.equals("32")) {
|
||||
// platformBits = 32;
|
||||
@@ -279,7 +284,7 @@ public class Commander implements RunnerListener {
|
||||
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);
|
||||
success = build.exportApplication(outputFolder, platform, platformBits, embedJava);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,6 +374,7 @@ public class Commander implements RunnerListener {
|
||||
out.println("--present Preprocess, compile, and run a sketch full screen.");
|
||||
out.println();
|
||||
out.println("--export Export an application.");
|
||||
out.println("--no-java Do not embed Java. Use at your own risk!");
|
||||
// out.println("--platform Specify the platform (export to application only).");
|
||||
// out.println(" Should be one of 'windows', 'macosx', or 'linux'.");
|
||||
// out.println("--bits Must be specified if libraries are used that are");
|
||||
|
||||
@@ -1118,23 +1118,24 @@ public class JavaBuild {
|
||||
|
||||
File folder = null;
|
||||
String platformName = Base.getPlatformName();
|
||||
boolean embedJava = Preferences.getBoolean("export.application.embed_java");
|
||||
if (Library.hasMultipleArch(PApplet.platform, importedLibraries)) {
|
||||
if (Base.getNativeBits() == 32) {
|
||||
// export the 32-bit version
|
||||
folder = new File(sketch.getFolder(), "application." + platformName + "32");
|
||||
if (!exportApplication(folder, PApplet.platform, 32)) {
|
||||
if (!exportApplication(folder, PApplet.platform, 32, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
} else if (Base.getNativeBits() == 64) {
|
||||
// export the 64-bit version
|
||||
folder = new File(sketch.getFolder(), "application." + platformName + "64");
|
||||
if (!exportApplication(folder, PApplet.platform, 64)) {
|
||||
if (!exportApplication(folder, PApplet.platform, 64, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else { // just make a single one for this platform
|
||||
folder = new File(sketch.getFolder(), "application." + platformName);
|
||||
if (!exportApplication(folder, PApplet.platform, 0)) {
|
||||
if (!exportApplication(folder, PApplet.platform, 0, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1148,8 @@ public class JavaBuild {
|
||||
*/
|
||||
protected boolean exportApplication(File destFolder,
|
||||
int exportPlatform,
|
||||
int exportBits) throws IOException, SketchException {
|
||||
int exportBits,
|
||||
boolean embedJava) throws IOException, SketchException {
|
||||
// TODO this should probably be a dialog box instead of a warning
|
||||
// on the terminal. And the message should be written better than this.
|
||||
// http://code.google.com/p/processing/issues/detail?id=884
|
||||
@@ -1178,13 +1180,18 @@ 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;
|
||||
// String jdkFolderName = null;
|
||||
String jvmRuntime = "";
|
||||
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();
|
||||
|
||||
if (embedJava) {
|
||||
File jdkFolder = new File(Base.getJavaHome(), "../../..");
|
||||
String jdkFolderName = jdkFolder.getCanonicalFile().getName();
|
||||
jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>";
|
||||
}
|
||||
|
||||
// File dotAppSkeleton = mode.getContentFile("application/template.app");
|
||||
// Base.copyDir(dotAppSkeleton, dotAppFolder);
|
||||
@@ -1209,8 +1216,10 @@ public class JavaBuild {
|
||||
writer.close();
|
||||
|
||||
// Use faster(?) native copy here (also to do sym links)
|
||||
Base.copyDirNative(new File(contentsOrig, "PlugIns"),
|
||||
new File(contentsFolder, "PlugIns"));
|
||||
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"),
|
||||
@@ -1243,10 +1252,14 @@ public class JavaBuild {
|
||||
}
|
||||
*/
|
||||
} else if (exportPlatform == PConstants.LINUX) {
|
||||
Base.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
if (embedJava) {
|
||||
Base.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
}
|
||||
|
||||
} else if (exportPlatform == PConstants.WINDOWS) {
|
||||
Base.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
if (embedJava) {
|
||||
Base.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1480,9 +1493,9 @@ public class JavaBuild {
|
||||
if (lines[i].indexOf("@@") != -1) {
|
||||
StringBuffer sb = new StringBuffer(lines[i]);
|
||||
int index = 0;
|
||||
while ((index = sb.indexOf("@@jdk_folder@@")) != -1) {
|
||||
sb.replace(index, index + "@@jdk_folder@@".length(),
|
||||
jdkFolderName);
|
||||
while ((index = sb.indexOf("@@jvm_runtime@@")) != -1) {
|
||||
sb.replace(index, index + "@@jvm_runtime@@".length(),
|
||||
jvmRuntime);
|
||||
}
|
||||
while ((index = sb.indexOf("@@jvm_options_list@@")) != -1) {
|
||||
sb.replace(index, index + "@@jvm_options_list@@".length(),
|
||||
|
||||
@@ -266,7 +266,9 @@ public class JavaEditor extends Editor {
|
||||
label2.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
panel.add(label1);
|
||||
panel.add(label2);
|
||||
int wide = label1.getPreferredSize().width;
|
||||
// The longer line is different between Windows and OS X.
|
||||
int wide = Math.max(label1.getPreferredSize().width,
|
||||
label2.getPreferredSize().width);
|
||||
panel.add(Box.createVerticalStrut(12));
|
||||
|
||||
/*
|
||||
@@ -312,6 +314,9 @@ public class JavaEditor extends Editor {
|
||||
panel.add(platformPanel);
|
||||
*/
|
||||
|
||||
//int indent = new JCheckBox().getPreferredSize().width;
|
||||
int indent = 0;
|
||||
|
||||
final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
|
||||
showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
|
||||
showStopButton.addItemListener(new ItemListener() {
|
||||
@@ -320,7 +325,7 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
});
|
||||
showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13 + indent, 6, 13));
|
||||
|
||||
final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
|
||||
fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
|
||||
@@ -333,10 +338,33 @@ public class JavaEditor extends Editor {
|
||||
});
|
||||
fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
boolean embed = Preferences.getBoolean("export.application.embed_java");
|
||||
final String embedWarning = "Embedding Java makes larger applications";
|
||||
final String nopeWarning = "Users will have to install the latest Java 7";
|
||||
final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning);
|
||||
warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13));
|
||||
|
||||
final JCheckBox embedJavaButton = new JCheckBox("Embed Java");
|
||||
embedJavaButton.setSelected(embed);
|
||||
embedJavaButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean selected = embedJavaButton.isSelected();
|
||||
Preferences.setBoolean("export.application.embed_java", selected);
|
||||
if (selected) {
|
||||
warningLabel.setText(embedWarning);
|
||||
} else {
|
||||
warningLabel.setText(nopeWarning);
|
||||
}
|
||||
}
|
||||
});
|
||||
embedJavaButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
JPanel optionPanel = new JPanel();
|
||||
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
|
||||
optionPanel.add(fullScreenButton);
|
||||
optionPanel.add(showStopButton);
|
||||
optionPanel.add(embedJavaButton);
|
||||
optionPanel.add(warningLabel);
|
||||
optionPanel.setBorder(new TitledBorder("Options"));
|
||||
// wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
@@ -351,7 +379,7 @@ public class JavaEditor extends Editor {
|
||||
// good = new Dimension(wide, platformPanel.getPreferredSize().height);
|
||||
// platformPanel.setMaximumSize(good);
|
||||
good = new Dimension(wide, optionPanel.getPreferredSize().height);
|
||||
optionPanel.setMaximumSize(good);
|
||||
// optionPanel.setMaximumSize(good);
|
||||
|
||||
String[] options = { "Export", "Cancel" };
|
||||
final JOptionPane optionPane = new JOptionPane(panel,
|
||||
|
||||
Reference in New Issue
Block a user