Skip to content

Commit 8dc8968

Browse files
committed
add 32/64 bit preference on OS X, tweak library errors for bit depths
1 parent 1634027 commit 8dc8968

7 files changed

Lines changed: 113 additions & 34 deletions

File tree

android/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
0201 android
2+
X lots of updates to PGraphics et al, especially on the 3D side
3+
X change export menu/key/toolbar ordering
24

35

46
_ if a sketch asks for android mode but it's not available

app/src/processing/app/Library.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public boolean accept(File dir, String name) {
7373
return lc.endsWith(".jar") || lc.endsWith(".zip");
7474
}
7575
};
76-
76+
77+
7778
public Library(File folder, String subfolder) {
7879
super(folder, Library.propertiesFileName);
7980
this.group = subfolder;
@@ -122,35 +123,24 @@ public Library(File folder, String subfolder) {
122123
String platformName32 = platformName + "32";
123124
String platformName64 = platformName + "64";
124125

126+
// First check for things like 'application.macosx=' or 'application.windows32' in the export.txt file.
127+
// These will override anything in the platform-specific subfolders.
125128
String platformAll = exportTable.get("application." + platformName);
126129
String[] platformList = platformAll == null ? null : PApplet.splitTokens(platformAll, ", ");
127-
128130
String platform32 = exportTable.get("application." + platformName + "32");
129131
String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", ");
130-
131132
String platform64 = exportTable.get("application." + platformName + "64");
132133
String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", ");
133134

135+
// If nothing specified in the export.txt entries, look for the platform-specific folders.
134136
if (platformAll == null) {
135137
platformList = listPlatformEntries(libraryFolder, platformName, baseList);
136-
// File folderAll = new File(libraryFolder, platformName);
137-
// if (folderAll.exists()) {
138-
// platformList = PApplet.concat(baseList, folderAll.list(standardFilter));
139-
// }
140138
}
141139
if (platform32 == null) {
142140
platformList32 = listPlatformEntries(libraryFolder, platformName32, baseList);
143-
// File folder32 = new File(libraryFolder, platformName32);
144-
// if (folder32.exists()) {
145-
// platformList32 = PApplet.concat(baseList, folder32.list(standardFilter));
146-
// }
147141
}
148142
if (platform64 == null) {
149143
platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList);
150-
// File folder64 = new File(libraryFolder, platformName64);
151-
// if (folder64.exists()) {
152-
// platformList64 = PApplet.concat(baseList, folder64.list(standardFilter));
153-
// }
154144
}
155145

156146
if (platformList32 != null || platformList64 != null) {
@@ -355,6 +345,15 @@ public String[] getApplicationExportList(int platform, int bits) {
355345
public boolean hasMultipleArch(int platform) {
356346
return multipleArch[platform];
357347
}
348+
349+
350+
public boolean supportsArch(int platform, int bits) {
351+
// If this is a universal library, or has no natives, then we're good.
352+
if (multipleArch[platform] == false) {
353+
return true;
354+
}
355+
return getApplicationExportList(platform, bits) != null;
356+
}
358357

359358

360359
// static boolean hasMultipleArch(String platformName, ArrayList<LibraryFolder> libraries) {

app/src/processing/app/Preferences.java

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public class Preferences {
119119
JCheckBox checkUpdatesBox;
120120
JTextField fontSizeField;
121121
JCheckBox autoAssociateBox;
122+
JRadioButton bitsThirtyTwoButton;
123+
JRadioButton bitsSixtyFourButton;
122124

123125

124126
// the calling editor, so updates can be applied
@@ -360,7 +362,29 @@ public void actionPerformed(ActionEvent e) {
360362
right = Math.max(right, left + d.width);
361363
top += d.height + GUI_BETWEEN;
362364
}
363-
365+
366+
367+
// Launch programs as [ ] 32-bit [ ] 64-bit (Mac OS X only)
368+
369+
if (Base.isMacOS()) {
370+
box = Box.createHorizontalBox();
371+
label = new JLabel("Launch programs in ");
372+
box.add(label);
373+
bitsThirtyTwoButton = new JRadioButton("32-bit mode ");
374+
box.add(bitsThirtyTwoButton);
375+
bitsSixtyFourButton = new JRadioButton("64-bit mode");
376+
box.add(bitsSixtyFourButton);
377+
378+
ButtonGroup bg = new ButtonGroup();
379+
bg.add(bitsThirtyTwoButton);
380+
bg.add(bitsSixtyFourButton);
381+
382+
pain.add(box);
383+
d = box.getPreferredSize();
384+
box.setBounds(left, top, d.width, d.height);
385+
top += d.height + GUI_BETWEEN;
386+
}
387+
364388

365389
// More preferences are in the ...
366390

@@ -546,6 +570,10 @@ protected void applyFrame() {
546570
}
547571
*/
548572

573+
if (Base.isMacOS()) {
574+
set("run.options.bits", bitsThirtyTwoButton.isSelected() ? "32" : "64");
575+
}
576+
549577
String newSizeText = fontSizeField.getText();
550578
try {
551579
int newSize = Integer.parseInt(newSizeText.trim());
@@ -595,6 +623,18 @@ protected void showFrame(Editor editor) {
595623
memoryField.
596624
setText(get("run.options.memory.maximum"));
597625

626+
String bits = Preferences.get("run.options.bits");
627+
if (bits.equals("32")) {
628+
bitsThirtyTwoButton.setSelected(true);
629+
} else if (bits.equals("64")) {
630+
bitsSixtyFourButton.setSelected(true);
631+
}
632+
// in case we go back and support OS X 10.5...
633+
if (System.getProperty("os.version").startsWith("10.5")) {
634+
bitsSixtyFourButton.setSelected(true);
635+
bitsThirtyTwoButton.setEnabled(false);
636+
}
637+
598638
if (autoAssociateBox != null) {
599639
autoAssociateBox.
600640
setSelected(getBoolean("platform.auto_file_type_associations"));
@@ -604,6 +644,22 @@ protected void showFrame(Editor editor) {
604644
}
605645

606646

647+
// Workaround for Apple bullsh*t caused by their not releasing a 32-bit
648+
// version of Java for Mac OS X 10.5.
649+
// static public String checkBits() {
650+
// String bits = Preferences.get("run.options.bits");
651+
// if (bits == null) {
652+
// if (System.getProperty("os.version").startsWith("10.5")) {
653+
// bits = "64";
654+
// } else {
655+
// bits = "32";
656+
// }
657+
// Preferences.set("run.options.bits", bits);
658+
// }
659+
// return bits;
660+
// }
661+
662+
607663
// .................................................................
608664

609665

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,23 @@ protected boolean exportApplication() throws IOException, SketchException {
10951095
private boolean exportApplication(File destFolder,
10961096
int exportPlatform,
10971097
int exportBits) throws IOException, SketchException {
1098+
// TODO this should probably be a dialog box instead of a warning
1099+
// on the terminal. And the message should be written better than this.
1100+
// http://code.google.com/p/processing/issues/detail?id=884
1101+
for (Library library : importedLibraries) {
1102+
if (!library.supportsArch(exportPlatform, exportBits)) {
1103+
String pn = PConstants.platformNames[exportPlatform];
1104+
System.err.println("The application." + pn + exportBits +
1105+
" folder will not be created because no " +
1106+
exportBits + "-bit version of " +
1107+
library.getName() +
1108+
" is available for " + pn);
1109+
return true; // don't cancel export for this, just move along
1110+
}
1111+
}
1112+
1113+
/// prep the output directory
1114+
10981115
mode.prepareExportFolder(destFolder);
10991116

11001117

app/src/processing/mode/java/runner/Runner.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,9 @@ protected VirtualMachine launchVirtualMachine(String[] vmParams,
280280
commandArgs =
281281
"java -Xrunjdwp:transport=dt_shmem,address=" + addr + ",suspend=y ";
282282
} else if (Base.isMacOS()) {
283-
if (System.getProperty("os.version").startsWith("10.4")) {
284-
// -d32 not understood by 10.4 (and not needed)
285-
commandArgs =
286-
"java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
287-
} else {
288-
commandArgs =
289-
// "java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
290-
"java -d32 -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
291-
}
283+
commandArgs =
284+
"java -d" + Preferences.get("run.options.bits") +
285+
" -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
292286
}
293287

294288
for (int i = 0; i < vmParams.length; i++) {

build/shared/lib/preferences.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ run.options.memory = false
163163
run.options.memory.initial = 64
164164
run.options.memory.maximum = 256
165165

166+
# By default, Mac OS X 10.6 launches applications in 32-bit mode.
167+
# Changing this doesn't do anything on other platforms. On OS X 10.5,
168+
# only 64-bit is supported, because Apple didn't release a 32-bit
169+
# version of Java 1.6 for OS X 10.5.
170+
run.options.bits.macosx = 32
171+
166172
# example of increasing the memory size for applets run externally
167173
#run.options = -Xms128m -Xmx1024m
168174

todo.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ X make application the default instead of applet
88
X subfolders of windows32 & friends aren't being included (gsvideo problem)
99
X on Windows, move the exported DLLs et al inside 'lib'
1010
X requires change to export/launcher.cpp to include the exe dir
11-
_ this will cause trouble with ...
1211
X change Linux script to handle the 'lib' dir as part of the lib path
13-
X changed Mac OS X launchers, also requiring Java 1.6.
14-
X write .bat file for windows64
12+
X changed Mac OS X launchers to use Java 1.6
13+
+ Java 1.6 required for the PDE and for exported applications
14+
X write .bat file for windows64 application exports
1515
_ document that this is temporary / file a bug
1616
X gstreamer has a million DLLs, so it's gross to have them in the main fldr
1717
o how would launch4j deal with this?
18+
X print a message in a console when trying to export a lib for unsupported arch
19+
X add a preferences option for whether to run in 32 or 64-bit
20+
X gsvideo sometimes needs to run as 64 instead of 32
21+
X notes about bit depth
22+
X If no bits specified (libs are all universal, or no native libs)
23+
X then exportBits will be 0, and can be controlled via "Get Info".
24+
X Otherwise, need to specify the bits as a VM option.
1825

19-
// If no bits specified (libs are all universal, or no native libs)
20-
// then exportBits will be 0, and can be controlled via "Get Info".
21-
// Otherwise, need to specify the bits as a VM option.
2226

23-
_ add a preferences option for whether to run in 32 or 64-bit
24-
_ also make note of when library is not available (serial) with error msg
25-
_ gsvideo sometimes needs to run as 64 instead of 32
27+
_ make note of when library is not available (serial) with error msg
28+
_ i.e. if running in 64-bit mode on OS X, can't do serial
2629

2730
_ Commenting via menu or shortcut does not set sketch to "need save"
2831
_ http://code.google.com/p/processing/issues/detail?id=860
@@ -1534,6 +1537,8 @@ _ and include an md5hash to see if the file is correct
15341537

15351538
DIST / Windows
15361539

1540+
_ exe instead of bat to make exported apps run in 64-bit
1541+
_ http://code.google.com/p/processing/issues/detail?id=885
15371542
_ Update Windows icons for multiple sizes, implement them in the PDE
15381543
_ http://code.google.com/p/processing/issues/detail?id=632
15391544
_ http://code.google.com/p/processing/issues/detail?id=138

0 commit comments

Comments
 (0)