Skip to content

Commit cc9cffa

Browse files
committed
ARM: Add arm64 support to app, core & mode
Currently untested.
1 parent c8f5b2c commit cc9cffa

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

app/src/processing/app/Library.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public boolean accept(File dir, String name) {
7171
if (name.equals("linux32")) return false;
7272
if (name.equals("linux64")) return false;
7373
if (name.equals("linux-armv6hf")) return false;
74+
if (name.equals("linux-arm64")) return false;
7475
if (name.equals("android")) return false;
7576
}
7677
return true;
@@ -173,6 +174,12 @@ protected void handle() {
173174
nativeLibraryFolder = hostLibrary;
174175
}
175176
}
177+
if (hostPlatform.equals("linux") && System.getProperty("os.arch").equals("aarch64")) {
178+
hostLibrary = new File(libraryFolder, "linux-arm64");
179+
if (hostLibrary.exists()) {
180+
nativeLibraryFolder = hostLibrary;
181+
}
182+
}
176183

177184
// save that folder for later use
178185
nativeLibraryPath = nativeLibraryFolder.getAbsolutePath();
@@ -183,6 +190,7 @@ protected void handle() {
183190
String platformName32 = platformName + "32";
184191
String platformName64 = platformName + "64";
185192
String platformNameArmv6hh = platformName + "-armv6hf";
193+
String platformNameArm64 = platformName + "-arm64";
186194

187195
// First check for things like 'application.macosx=' or 'application.windows32' in the export.txt file.
188196
// These will override anything in the platform-specific subfolders.
@@ -194,6 +202,8 @@ protected void handle() {
194202
String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", ");
195203
String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf");
196204
String[] platformListArmv6hf = platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", ");
205+
String platformArm64 = exportTable.get("application." + platformName + "-arm64");
206+
String[] platformListArm64 = platformArm64 == null ? null : PApplet.splitTokens(platformArm64, ", ");
197207

198208
// If nothing specified in the export.txt entries, look for the platform-specific folders.
199209
if (platformAll == null) {
@@ -208,14 +218,17 @@ protected void handle() {
208218
if (platformListArmv6hf == null) {
209219
platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList);
210220
}
221+
if (platformListArm64 == null) {
222+
platformListArm64 = listPlatformEntries(libraryFolder, platformNameArm64, baseList);
223+
}
211224

212-
if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) {
225+
if (platformList32 != null || platformList64 != null || platformListArmv6hf != null || platformListArm64 != null) {
213226
multipleArch[i] = true;
214227
}
215228

216229
// if there aren't any relevant imports specified or in their own folders,
217230
// then use the baseList (root of the library folder) as the default.
218-
if (platformList == null && platformList32 == null && platformList64 == null && platformListArmv6hf == null) {
231+
if (platformList == null && platformList32 == null && platformList64 == null && platformListArmv6hf == null && platformListArm64 == null) {
219232
exportList.put(platformName, baseList);
220233

221234
} else {
@@ -233,6 +246,9 @@ protected void handle() {
233246
if (platformListArmv6hf != null) {
234247
exportList.put(platformNameArmv6hh, platformListArmv6hf);
235248
}
249+
if (platformListArm64 != null) {
250+
exportList.put(platformNameArm64, platformListArm64);
251+
}
236252
}
237253
}
238254
// for (String p : exportList.keySet()) {
@@ -412,6 +428,9 @@ public String[] getApplicationExportList(int platform, String variant) {
412428
} else if (variant.equals("armv6hf")) {
413429
String[] pieces = exportList.get(platformName + "-armv6hf");
414430
if (pieces != null) return pieces;
431+
} else if (variant.equals("arm64")) {
432+
String[] pieces = exportList.get(platformName + "-arm64");
433+
if (pieces != null) return pieces;
415434
}
416435
return exportList.get(platformName);
417436
}

app/src/processing/app/Platform.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static public int getNativeBits() {
195195
* Return the value of the os.arch property
196196
*/
197197
static public String getNativeArch() {
198+
// This will return "arm" for 32-bit ARM, "aarch64" for 64-bit ARM (both on Linux)
198199
return System.getProperty("os.arch");
199200
}
200201

@@ -211,8 +212,12 @@ static public String getVariant() {
211212
static public String getVariant(int platform, String arch, int bits) {
212213
if (platform == PConstants.LINUX &&
213214
bits == 32 && "arm".equals(Platform.getNativeArch())) {
214-
return "armv6hf"; // assume armv6hf for now
215+
return "armv6hf"; // assume armv6hf
216+
} else if (platform == PConstants.LINUX &&
217+
bits == 64 && "aarch64".equals(Platform.getNativeArch())) {
218+
return "arm64";
215219
}
220+
216221
return Integer.toString(bits); // 32 or 64
217222
}
218223

core/library/export.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ 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
11+
application.linux-armv6hf=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-armv6hf.jar,gluegen-rt-natives-linux-armv6hf.jar
12+
# XXX: needs JOGL build
13+
application.linux-arm64=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/JavaBuild.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,15 @@ protected boolean exportApplication() throws IOException, SketchException {
709709
return false;
710710
}
711711
if (platform == PConstants.LINUX) {
712-
// export the armv6hf version as well
712+
// export the arm versions as well
713713
folder = new File(sketch.getFolder(), "application.linux-armv6hf");
714714
if (!exportApplication(folder, platform, "armv6hf", embedJava && (bits == 32) && "arm".equals(arch))) {
715715
return false;
716716
}
717+
folder = new File(sketch.getFolder(), "application.linux-arm64");
718+
if (!exportApplication(folder, platform, "arm64", embedJava && (bits == 64) && "aarch64".equals(arch))) {
719+
return false;
720+
}
717721
}
718722
} else { // just make a single one for this platform
719723
folder = new File(sketch.getFolder(), "application." + platformName);

0 commit comments

Comments
 (0)