Skip to content

Commit 8d7c537

Browse files
committed
Sketch export for armv6hf (v2)
Includes a lot of improvements suggested by Ben.
1 parent e5e2ba0 commit 8d7c537

File tree

6 files changed

+71
-27
lines changed

6 files changed

+71
-27
lines changed

app/src/processing/app/Base.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public class Base {
9898
}
9999
}
100100

101+
static String nativeArch = System.getProperty("os.arch");
102+
101103
static private boolean commandLine;
102104

103105
// A single instance of the preferences window
@@ -1546,6 +1548,30 @@ static public int getNativeBits() {
15461548
return nativeBits;
15471549
}
15481550

1551+
/**
1552+
* Return the value of the os.arch propery
1553+
*/
1554+
static public String getNativeArch() {
1555+
return nativeArch;
1556+
}
1557+
1558+
/*
1559+
* Return a string that identifies the variant of a platform
1560+
* e.g. "32" or "64" on Intel
1561+
*/
1562+
static public String getVariant() {
1563+
return getVariant(PApplet.platform, getNativeArch(), getNativeBits());
1564+
}
1565+
1566+
static public String getVariant(int platform, String arch, int bits) {
1567+
if (platform == PConstants.LINUX && bits == 32 && "arm".equals(Base.getNativeArch())) {
1568+
// assume armv6hf for now
1569+
return "armv6hf";
1570+
} else {
1571+
// 32 or 64
1572+
return Integer.toString(bits);
1573+
}
1574+
}
15491575

15501576
/*
15511577
static public String getPlatformName() {

app/src/processing/app/Library.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ private Library(File folder, String groupName) {
173173
String platformName = platformNames[i];
174174
String platformName32 = platformName + "32";
175175
String platformName64 = platformName + "64";
176+
String platformNameArmv6hh = platformName + "-armv6hf";
176177

177178
// First check for things like 'application.macosx=' or 'application.windows32' in the export.txt file.
178179
// These will override anything in the platform-specific subfolders.
@@ -182,6 +183,8 @@ private Library(File folder, String groupName) {
182183
String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", ");
183184
String platform64 = exportTable.get("application." + platformName + "64");
184185
String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", ");
186+
String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf");
187+
String[] platformListArmv6hf = platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", ");
185188

186189
// If nothing specified in the export.txt entries, look for the platform-specific folders.
187190
if (platformAll == null) {
@@ -193,14 +196,17 @@ private Library(File folder, String groupName) {
193196
if (platform64 == null) {
194197
platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList);
195198
}
199+
if (platformListArmv6hf == null) {
200+
platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList);
201+
}
196202

197-
if (platformList32 != null || platformList64 != null) {
203+
if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) {
198204
multipleArch[i] = true;
199205
}
200206

201207
// if there aren't any relevant imports specified or in their own folders,
202208
// then use the baseList (root of the library folder) as the default.
203-
if (platformList == null && platformList32 == null && platformList64 == null) {
209+
if (platformList == null && platformList32 == null && platformList64 == null && platformListArmv6hf == null) {
204210
exportList.put(platformName, baseList);
205211

206212
} else {
@@ -215,6 +221,9 @@ private Library(File folder, String groupName) {
215221
if (platformList64 != null) {
216222
exportList.put(platformName64, platformList64);
217223
}
224+
if (platformListArmv6hf != null) {
225+
exportList.put(platformNameArmv6hh, platformListArmv6hf);
226+
}
218227
}
219228
}
220229
// for (String p : exportList.keySet()) {
@@ -369,8 +378,8 @@ public File[] getAppletExports() {
369378
}
370379

371380

372-
public File[] getApplicationExports(int platform, int bits) {
373-
String[] list = getApplicationExportList(platform, bits);
381+
public File[] getApplicationExports(int platform, String variant) {
382+
String[] list = getApplicationExportList(platform, variant);
374383
return wrapFiles(list);
375384
}
376385

@@ -380,14 +389,17 @@ public File[] getApplicationExports(int platform, int bits) {
380389
* If no 32 or 64-bit version of the exports exists, it returns the version
381390
* that doesn't specify bit depth.
382391
*/
383-
public String[] getApplicationExportList(int platform, int bits) {
392+
public String[] getApplicationExportList(int platform, String variant) {
384393
String platformName = PConstants.platformNames[platform];
385-
if (bits == 32) {
394+
if (variant.equals("32")) {
386395
String[] pieces = exportList.get(platformName + "32");
387396
if (pieces != null) return pieces;
388-
} else if (bits == 64) {
397+
} else if (variant.equals("64")) {
389398
String[] pieces = exportList.get(platformName + "64");
390399
if (pieces != null) return pieces;
400+
} else if (variant.equals("armv6hf")) {
401+
String[] pieces = exportList.get(platformName + "-armv6hf");
402+
if (pieces != null) return pieces;
391403
}
392404
return exportList.get(platformName);
393405
}
@@ -408,12 +420,12 @@ public boolean hasMultipleArch(int platform) {
408420
}
409421

410422

411-
public boolean supportsArch(int platform, int bits) {
423+
public boolean supportsArch(int platform, String variant) {
412424
// If this is a universal library, or has no natives, then we're good.
413425
if (multipleArch[platform] == false) {
414426
return true;
415427
}
416-
return getApplicationExportList(platform, bits) != null;
428+
return getApplicationExportList(platform, variant) != null;
417429
}
418430

419431

core/library/export.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ application.windows32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-wind
88
application.windows64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-windows-amd64.jar,gluegen-rt-natives-windows-amd64.jar
99
application.linux32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-i586.jar,gluegen-rt-natives-linux-i586.jar
1010
application.linux64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-amd64.jar,gluegen-rt-natives-linux-amd64.jar
11+
application.linux-armv6hf=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-armv6hf.jar,gluegen-rt-natives-linux-armv6hf.jar

java/src/processing/mode/java/Commander.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import processing.app.Util;
3636
import processing.app.contrib.ModeContribution;
3737
import processing.core.PApplet;
38+
import processing.core.PConstants;
3839
import processing.mode.java.runner.Runner;
3940

4041

@@ -280,14 +281,9 @@ public Commander(String[] args) {
280281
JavaBuild build = new JavaBuild(sketch);
281282
build.build(true);
282283
if (build != null) {
283-
// if (platformBits == 0) {
284-
// platformBits = Base.getNativeBits();
285-
// }
286-
// if (platformBits == 0 &&
287-
// Library.hasMultipleArch(platform, build.getImportedLibraries())) {
288-
// complainAndQuit("This sketch can be exported for 32- or 64-bit, please specify one.", true);
289-
// }
290-
success = build.exportApplication(outputFolder, platform, platformBits, embedJava);
284+
285+
String variant = Base.getVariant();
286+
success = build.exportApplication(outputFolder, platform, variant, embedJava);
291287
}
292288
}
293289
}

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -796,17 +796,24 @@ protected boolean exportApplication() throws IOException, SketchException {
796796
if (Library.hasMultipleArch(platform, importedLibraries)) {
797797
// export the 32-bit version
798798
folder = new File(sketch.getFolder(), "application." + platformName + "32");
799-
if (!exportApplication(folder, platform, 32, embedJava && Base.getNativeBits() == 32)) {
799+
if (!exportApplication(folder, platform, "32", embedJava && Base.getNativeBits() == 32 && "x86".equals(Base.getNativeArch()))) {
800800
return false;
801801
}
802802
// export the 64-bit version
803803
folder = new File(sketch.getFolder(), "application." + platformName + "64");
804-
if (!exportApplication(folder, platform, 64, embedJava && Base.getNativeBits() == 64)) {
804+
if (!exportApplication(folder, platform, "64", embedJava && Base.getNativeBits() == 64 && "x86".equals(Base.getNativeArch()))) {
805805
return false;
806806
}
807+
if (platform == PConstants.LINUX) {
808+
// export the armv6hf version as well
809+
folder = new File(sketch.getFolder(), "application.linux-armv6hf");
810+
if (!exportApplication(folder, platform, "armv6hf", embedJava && Base.getNativeBits() == 32 && "arm".equals(Base.getNativeArch()))) {
811+
return false;
812+
}
813+
}
807814
} else { // just make a single one for this platform
808815
folder = new File(sketch.getFolder(), "application." + platformName);
809-
if (!exportApplication(folder, platform, 0, embedJava)) {
816+
if (!exportApplication(folder, platform, "", embedJava)) {
810817
return false;
811818
}
812819
}
@@ -847,18 +854,18 @@ protected boolean exportApplication() throws IOException, SketchException {
847854
*/
848855
protected boolean exportApplication(File destFolder,
849856
int exportPlatform,
850-
int exportBits,
857+
String exportVariant,
851858
boolean embedJava) throws IOException, SketchException {
852859
// TODO this should probably be a dialog box instead of a warning
853860
// on the terminal. And the message should be written better than this.
854861
// http://code.google.com/p/processing/issues/detail?id=884
855862
for (Library library : importedLibraries) {
856-
if (!library.supportsArch(exportPlatform, exportBits)) {
863+
if (!library.supportsArch(exportPlatform, exportVariant)) {
857864
String pn = PConstants.platformNames[exportPlatform];
858865
Base.showWarning("Quibbles 'n Bits",
859-
"The application." + pn + exportBits +
866+
"The application." + pn + exportVariant +
860867
" folder will not be created\n" +
861-
"because no " + exportBits + "-bit version of " +
868+
"because no " + exportVariant + " version of " +
862869
library.getName() + " is available for " + pn, null);
863870
return true; // don't cancel all exports for this, just move along
864871
}
@@ -1062,7 +1069,7 @@ protected boolean exportApplication(File destFolder,
10621069
/// add contents of 'library' folders to the export
10631070
for (Library library : importedLibraries) {
10641071
// add each item from the library folder / export list to the output
1065-
for (File exportFile : library.getApplicationExports(exportPlatform, exportBits)) {
1072+
for (File exportFile : library.getApplicationExports(exportPlatform, exportVariant)) {
10661073
// System.out.println("export: " + exportFile);
10671074
String exportName = exportFile.getName();
10681075
if (!exportFile.exists()) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
9090

9191
// Make sure all the imported libraries will actually run with this setup.
9292
int bits = Base.getNativeBits();
93+
String variant = Base.getVariant();
94+
9395
for (Library library : build.getImportedLibraries()) {
94-
if (!library.supportsArch(PApplet.platform, bits)) {
95-
sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode.");
96+
if (!library.supportsArch(PApplet.platform, variant)) {
97+
sketchErr.println(library.getName() + " does not run on this architecture: " + variant);
9698
int opposite = (bits == 32) ? 64 : 32;
9799
if (Base.isMacOS()) {
98100
//if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true

0 commit comments

Comments
 (0)