Skip to content

Commit 1ccd012

Browse files
committed
new export now handles embedding the JRE on OS X
1 parent 1e87b76 commit 1ccd012

File tree

3 files changed

+121
-25
lines changed

3 files changed

+121
-25
lines changed

app/src/processing/mode/java/JavaBuild.java

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,10 +1160,13 @@ protected boolean exportApplication(File destFolder,
11601160
/// on macosx, need to copy .app skeleton since that's
11611161
/// also where the jar files will be placed
11621162
File dotAppFolder = null;
1163+
String jdkFolderName = null;
11631164
if (exportPlatform == PConstants.MACOSX) {
11641165
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
11651166

11661167
File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
1168+
File jdkFolder = new File(Base.getJavaHome(), "../../..");
1169+
jdkFolderName = jdkFolder.getCanonicalFile().getName();
11671170

11681171
// File dotAppSkeleton = mode.getContentFile("application/template.app");
11691172
// Base.copyDir(dotAppSkeleton, dotAppFolder);
@@ -1409,13 +1412,22 @@ protected boolean exportApplication(File destFolder,
14091412

14101413
/// figure out run options for the VM
14111414

1412-
String runOptions = Preferences.get("run.options");
1415+
// this is too vague. if anyone is using it, we can bring it back
1416+
// String runOptions = Preferences.get("run.options");
1417+
List<String> runOptions = new ArrayList<String>();
14131418
if (Preferences.getBoolean("run.options.memory")) {
1414-
runOptions += " -Xms" +
1415-
Preferences.get("run.options.memory.initial") + "m";
1416-
runOptions += " -Xmx" +
1417-
Preferences.get("run.options.memory.maximum") + "m";
1419+
runOptions.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
1420+
runOptions.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
14181421
}
1422+
1423+
StringBuilder jvmOptionsList = new StringBuilder();
1424+
for (String opt : runOptions) {
1425+
jvmOptionsList.append(" <string>");
1426+
jvmOptionsList.append(opt);
1427+
jvmOptionsList.append("</string>");
1428+
jvmOptionsList.append('\n');
1429+
}
1430+
14191431
// if (exportPlatform == PConstants.MACOSX) {
14201432
// // If no bits specified (libs are all universal, or no native libs)
14211433
// // then exportBits will be 0, and can be controlled via "Get Info".
@@ -1430,10 +1442,12 @@ protected boolean exportApplication(File destFolder,
14301442
/// macosx: write out Info.plist (template for classpath, etc)
14311443

14321444
if (exportPlatform == PConstants.MACOSX) {
1433-
String PLIST_TEMPLATE = "template.plist";
1445+
//String PLIST_TEMPLATE = "template.plist";
1446+
String PLIST_TEMPLATE = "Info.plist.tmpl";
14341447
File plistTemplate = new File(sketch.getFolder(), PLIST_TEMPLATE);
14351448
if (!plistTemplate.exists()) {
1436-
plistTemplate = mode.getContentFile("application/template.plist");
1449+
//plistTemplate = mode.getContentFile("application/template.plist");
1450+
plistTemplate = mode.getContentFile("application/Info.plist.tmpl");
14371451
}
14381452
File plistFile = new File(dotAppFolder, "Contents/Info.plist");
14391453
PrintWriter pw = PApplet.createWriter(plistFile);
@@ -1443,33 +1457,37 @@ protected boolean exportApplication(File destFolder,
14431457
if (lines[i].indexOf("@@") != -1) {
14441458
StringBuffer sb = new StringBuffer(lines[i]);
14451459
int index = 0;
1446-
while ((index = sb.indexOf("@@vmoptions@@")) != -1) {
1447-
sb.replace(index, index + "@@vmoptions@@".length(),
1448-
runOptions);
1460+
while ((index = sb.indexOf("@@jdk_folder@@")) != -1) {
1461+
sb.replace(index, index + "@@jdk_folder@@".length(),
1462+
jdkFolderName);
1463+
}
1464+
while ((index = sb.indexOf("@@jvm_options_list@@")) != -1) {
1465+
sb.replace(index, index + "@@jvm_options_list@@".length(),
1466+
jvmOptionsList.toString());
14491467
}
14501468
while ((index = sb.indexOf("@@sketch@@")) != -1) {
14511469
sb.replace(index, index + "@@sketch@@".length(),
14521470
sketch.getName());
14531471
}
1454-
while ((index = sb.indexOf("@@classpath@@")) != -1) {
1455-
sb.replace(index, index + "@@classpath@@".length(),
1456-
exportClassPath.toString());
1457-
}
1472+
// while ((index = sb.indexOf("@@classpath@@")) != -1) {
1473+
// sb.replace(index, index + "@@classpath@@".length(),
1474+
// exportClassPath.toString());
1475+
// }
14581476
while ((index = sb.indexOf("@@lsuipresentationmode@@")) != -1) {
14591477
sb.replace(index, index + "@@lsuipresentationmode@@".length(),
14601478
Preferences.getBoolean("export.application.fullscreen") ? "4" : "0");
14611479
}
1462-
while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
1463-
// More about this mess: http://support.apple.com/kb/TS2827
1464-
// First default to exportBits == 0 case
1465-
String arch = "<string>x86_64</string>\n <string>i386</string>";
1466-
if (exportBits == 32) {
1467-
arch = "<string>i386</string>";
1468-
} else if (exportBits == 64) {
1469-
arch = "<string>x86_64</string>";
1470-
}
1471-
sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
1472-
}
1480+
// while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
1481+
// // More about this mess: http://support.apple.com/kb/TS2827
1482+
// // First default to exportBits == 0 case
1483+
// String arch = "<string>x86_64</string>\n <string>i386</string>";
1484+
// if (exportBits == 32) {
1485+
// arch = "<string>i386</string>";
1486+
// } else if (exportBits == 64) {
1487+
// arch = "<string>x86_64</string>";
1488+
// }
1489+
// sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
1490+
// }
14731491

14741492
lines[i] = sb.toString();
14751493
}

java/application/Info.plist.tmpl

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" ?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleExecutable</key>
8+
<string>@@sketch@@</string>
9+
<key>CFBundleIconFile</key>
10+
<string>sketch.icns</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>@@sketch@@</string>
13+
<key>CFBundleDisplayName</key>
14+
<string>@@sketch@@</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundleName</key>
18+
<string>@@sketch@@</string>
19+
<key>CFBundlePackageType</key>
20+
<string>APPL</string>
21+
22+
<!-- Customize this set as you wish -->
23+
<key>CFBundleShortVersionString</key>
24+
<string>1</string>
25+
<key>CFBundleVersion</key>
26+
<string>1</string>
27+
<key>CFBundleSignature</key>
28+
<string>????</string>
29+
<key>NSHumanReadableCopyright</key>
30+
<string>Your copyright here</string>
31+
<key>CFBundleGetInfoString</key>
32+
<string>Created with Processing</string>
33+
<!-- End of the set that can be customized -->
34+
35+
<key>JVMRuntime</key>
36+
<string>@@jdk_folder@@</string>
37+
38+
<key>JVMMainClassName</key>
39+
<string>@@sketch@@</string>
40+
41+
<key>LSMinimumSystemVersion</key>
42+
<string>10.7.3</string>
43+
44+
<key>NSHighResolutionCapable</key>
45+
<true/>
46+
47+
<key>LSArchitecturePriority</key>
48+
<array>
49+
<string>x86_64</string>
50+
</array>
51+
52+
<key>LSEnvironment</key>
53+
<dict>
54+
<key>LC_CTYPE</key>
55+
<string>UTF-8</string>
56+
</dict>
57+
58+
<key>LSUIPresentationMode</key>
59+
<integer>@@lsuipresentationmode@@</integer>
60+
61+
<key>JVMOptions</key>
62+
<array>
63+
@@jvm_options_list@@
64+
<string>-Xdock:icon=Contents/Resources/sketch.icns</string>
65+
<string>-Dapple.laf.useScreenMenuBar=true</string>
66+
<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>
67+
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>
68+
<string>-Dcom.apple.mrj.application.apple.menu.about.name=@@sketch@@</string>
69+
<string>-Dcom.apple.smallTabs=true</string>
70+
</array>
71+
<key>JVMArguments</key>
72+
<array>
73+
</array>
74+
</dict>
75+
</plist>

todo.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ _ and where the font is needed most
161161
_ make note of this on the platforms page
162162
_ also make note re: only JRE needed (instead of JDK)
163163
_ http://wiki.processing.org/index.php?title=Supported_Platforms&action=edit&section=4
164+
_ now Info.plist.tmpl instead of template.plist
165+
_ can be embedded in a sketch
166+
_ name change due to major modifications
164167

165168
7u40 macosx
166169
X make OS X launch from its local JRE

0 commit comments

Comments
 (0)