diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 090cf4c50..0bf8ff6ab 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -98,6 +98,8 @@ public class Base { } } + static String nativeArch = System.getProperty("os.arch"); + static private boolean commandLine; // A single instance of the preferences window @@ -1546,6 +1548,30 @@ public class Base { return nativeBits; } + /** + * Return the value of the os.arch propery + */ + static public String getNativeArch() { + return nativeArch; + } + + /* + * Return a string that identifies the variant of a platform + * e.g. "32" or "64" on Intel + */ + static public String getVariant() { + return getVariant(PApplet.platform, getNativeArch(), getNativeBits()); + } + + static public String getVariant(int platform, String arch, int bits) { + if (platform == PConstants.LINUX && bits == 32 && "arm".equals(Base.getNativeArch())) { + // assume armv6hf for now + return "armv6hf"; + } else { + // 32 or 64 + return Integer.toString(bits); + } + } /* static public String getPlatformName() { diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java index 69966b637..8f90d7b25 100644 --- a/app/src/processing/app/Library.java +++ b/app/src/processing/app/Library.java @@ -173,6 +173,7 @@ public class Library extends LocalContribution { String platformName = platformNames[i]; String platformName32 = platformName + "32"; String platformName64 = platformName + "64"; + String platformNameArmv6hh = platformName + "-armv6hf"; // First check for things like 'application.macosx=' or 'application.windows32' in the export.txt file. // These will override anything in the platform-specific subfolders. @@ -182,6 +183,8 @@ public class Library extends LocalContribution { String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", "); String platform64 = exportTable.get("application." + platformName + "64"); String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", "); + String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf"); + String[] platformListArmv6hf = platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", "); // If nothing specified in the export.txt entries, look for the platform-specific folders. if (platformAll == null) { @@ -193,14 +196,17 @@ public class Library extends LocalContribution { if (platform64 == null) { platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList); } + if (platformListArmv6hf == null) { + platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList); + } - if (platformList32 != null || platformList64 != null) { + if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) { multipleArch[i] = true; } // if there aren't any relevant imports specified or in their own folders, // then use the baseList (root of the library folder) as the default. - if (platformList == null && platformList32 == null && platformList64 == null) { + if (platformList == null && platformList32 == null && platformList64 == null && platformListArmv6hf == null) { exportList.put(platformName, baseList); } else { @@ -215,6 +221,9 @@ public class Library extends LocalContribution { if (platformList64 != null) { exportList.put(platformName64, platformList64); } + if (platformListArmv6hf != null) { + exportList.put(platformNameArmv6hh, platformListArmv6hf); + } } } // for (String p : exportList.keySet()) { @@ -369,8 +378,8 @@ public class Library extends LocalContribution { } - public File[] getApplicationExports(int platform, int bits) { - String[] list = getApplicationExportList(platform, bits); + public File[] getApplicationExports(int platform, String variant) { + String[] list = getApplicationExportList(platform, variant); return wrapFiles(list); } @@ -380,14 +389,17 @@ public class Library extends LocalContribution { * If no 32 or 64-bit version of the exports exists, it returns the version * that doesn't specify bit depth. */ - public String[] getApplicationExportList(int platform, int bits) { + public String[] getApplicationExportList(int platform, String variant) { String platformName = PConstants.platformNames[platform]; - if (bits == 32) { + if (variant.equals("32")) { String[] pieces = exportList.get(platformName + "32"); if (pieces != null) return pieces; - } else if (bits == 64) { + } else if (variant.equals("64")) { String[] pieces = exportList.get(platformName + "64"); if (pieces != null) return pieces; + } else if (variant.equals("armv6hf")) { + String[] pieces = exportList.get(platformName + "-armv6hf"); + if (pieces != null) return pieces; } return exportList.get(platformName); } @@ -408,12 +420,12 @@ public class Library extends LocalContribution { } - public boolean supportsArch(int platform, int bits) { + public boolean supportsArch(int platform, String variant) { // If this is a universal library, or has no natives, then we're good. if (multipleArch[platform] == false) { return true; } - return getApplicationExportList(platform, bits) != null; + return getApplicationExportList(platform, variant) != null; } diff --git a/core/library/export.txt b/core/library/export.txt index 308d1a35a..88d0bc274 100644 --- a/core/library/export.txt +++ b/core/library/export.txt @@ -8,3 +8,4 @@ application.windows32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-wind application.windows64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-windows-amd64.jar,gluegen-rt-natives-windows-amd64.jar application.linux32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-i586.jar,gluegen-rt-natives-linux-i586.jar application.linux64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-amd64.jar,gluegen-rt-natives-linux-amd64.jar +application.linux-armv6hf=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-armv6hf.jar,gluegen-rt-natives-linux-armv6hf.jar \ No newline at end of file diff --git a/java/src/processing/mode/java/Commander.java b/java/src/processing/mode/java/Commander.java index 4d3ecf0e4..fc46ba66d 100644 --- a/java/src/processing/mode/java/Commander.java +++ b/java/src/processing/mode/java/Commander.java @@ -35,6 +35,7 @@ import processing.app.SketchException; import processing.app.Util; import processing.app.contrib.ModeContribution; import processing.core.PApplet; +import processing.core.PConstants; import processing.mode.java.runner.Runner; @@ -280,14 +281,9 @@ public class Commander implements RunnerListener { JavaBuild build = new JavaBuild(sketch); build.build(true); if (build != null) { -// if (platformBits == 0) { -// platformBits = Base.getNativeBits(); -// } -// if (platformBits == 0 && -// 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, embedJava); + + String variant = Base.getVariant(); + success = build.exportApplication(outputFolder, platform, variant, embedJava); } } } diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index deda39941..3950a6831 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -796,17 +796,24 @@ public class JavaBuild { if (Library.hasMultipleArch(platform, importedLibraries)) { // export the 32-bit version folder = new File(sketch.getFolder(), "application." + platformName + "32"); - if (!exportApplication(folder, platform, 32, embedJava && Base.getNativeBits() == 32)) { + if (!exportApplication(folder, platform, "32", embedJava && Base.getNativeBits() == 32 && "x86".equals(Base.getNativeArch()))) { return false; } // export the 64-bit version folder = new File(sketch.getFolder(), "application." + platformName + "64"); - if (!exportApplication(folder, platform, 64, embedJava && Base.getNativeBits() == 64)) { + if (!exportApplication(folder, platform, "64", embedJava && Base.getNativeBits() == 64 && "x86".equals(Base.getNativeArch()))) { return false; } + if (platform == PConstants.LINUX) { + // export the armv6hf version as well + folder = new File(sketch.getFolder(), "application.linux-armv6hf"); + if (!exportApplication(folder, platform, "armv6hf", embedJava && Base.getNativeBits() == 32 && "arm".equals(Base.getNativeArch()))) { + return false; + } + } } else { // just make a single one for this platform folder = new File(sketch.getFolder(), "application." + platformName); - if (!exportApplication(folder, platform, 0, embedJava)) { + if (!exportApplication(folder, platform, "", embedJava)) { return false; } } @@ -847,18 +854,18 @@ public class JavaBuild { */ protected boolean exportApplication(File destFolder, int exportPlatform, - int exportBits, + String exportVariant, 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 for (Library library : importedLibraries) { - if (!library.supportsArch(exportPlatform, exportBits)) { + if (!library.supportsArch(exportPlatform, exportVariant)) { String pn = PConstants.platformNames[exportPlatform]; Base.showWarning("Quibbles 'n Bits", - "The application." + pn + exportBits + + "The application." + pn + exportVariant + " folder will not be created\n" + - "because no " + exportBits + "-bit version of " + + "because no " + exportVariant + " version of " + library.getName() + " is available for " + pn, null); return true; // don't cancel all exports for this, just move along } @@ -1062,7 +1069,7 @@ public class JavaBuild { /// add contents of 'library' folders to the export for (Library library : importedLibraries) { // add each item from the library folder / export list to the output - for (File exportFile : library.getApplicationExports(exportPlatform, exportBits)) { + for (File exportFile : library.getApplicationExports(exportPlatform, exportVariant)) { // System.out.println("export: " + exportFile); String exportName = exportFile.getName(); if (!exportFile.exists()) { diff --git a/java/src/processing/mode/java/runner/Runner.java b/java/src/processing/mode/java/runner/Runner.java index 6ae25ecf1..2e910b93a 100644 --- a/java/src/processing/mode/java/runner/Runner.java +++ b/java/src/processing/mode/java/runner/Runner.java @@ -90,9 +90,11 @@ public class Runner implements MessageConsumer { // Make sure all the imported libraries will actually run with this setup. int bits = Base.getNativeBits(); + String variant = Base.getVariant(); + for (Library library : build.getImportedLibraries()) { - if (!library.supportsArch(PApplet.platform, bits)) { - sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode."); + if (!library.supportsArch(PApplet.platform, variant)) { + sketchErr.println(library.getName() + " does not run on this architecture: " + variant); int opposite = (bits == 32) ? 64 : 32; if (Base.isMacOS()) { //if (library.supportsArch(PConstants.MACOSX, opposite)) { // should always be true