Skip to content

Commit 85e136f

Browse files
committed
more reworking of export, but ui still unfinished
1 parent 1a49263 commit 85e136f

File tree

3 files changed

+90
-56
lines changed

3 files changed

+90
-56
lines changed

app/src/processing/app/Library.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ protected File[] wrapFiles(String[] list) {
428428
}
429429

430430

431+
public File[] getApplicationExports(String variant) {
432+
String[] list = getApplicationExportList(variant);
433+
return wrapFiles(list);
434+
}
435+
436+
431437
/*
432438
public File[] getApplicationExports(int platform, String variant) {
433439
String[] list = getApplicationExportList(platform, variant);

app/src/processing/app/Platform.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@
4141
public class Platform {
4242
static DefaultPlatform inst;
4343

44+
/*
4445
static Map<Integer, String> platformNames = new HashMap<>();
4546
static {
4647
platformNames.put(PConstants.WINDOWS, "windows"); //$NON-NLS-1$
47-
platformNames.put(PConstants.MACOS, "macosx"); //$NON-NLS-1$
48+
platformNames.put(PConstants.MACOS, "macos"); //$NON-NLS-1$
4849
platformNames.put(PConstants.LINUX, "linux"); //$NON-NLS-1$
4950
}
51+
*/
5052

5153
static Map<String, Integer> platformIndices = new HashMap<>();
5254
static {
5355
platformIndices.put("windows", PConstants.WINDOWS); //$NON-NLS-1$
54-
platformIndices.put("macosx", PConstants.MACOS); //$NON-NLS-1$
56+
platformIndices.put("macos", PConstants.MACOS); //$NON-NLS-1$
5557
platformIndices.put("linux", PConstants.LINUX); //$NON-NLS-1$
5658
}
5759

@@ -263,12 +265,16 @@ static public String getName() {
263265
// static public String getName(int which) {
264266
// return platformNames.get(which);
265267
// }
266-
//
267-
//
268-
// static public int getIndex(String what) {
269-
// Integer entry = platformIndices.get(what);
270-
// return (entry == null) ? -1 : entry;
271-
// }
268+
269+
270+
static public int getIndex(String platformName) {
271+
// if this has os.arch at the end, remove it
272+
int index = platformName.indexOf('-');
273+
if (index != -1) {
274+
platformName = platformName.substring(0, index);
275+
}
276+
return platformIndices.getOrDefault(platformName, -1);
277+
}
272278

273279

274280
// These were changed to no longer rely on PApplet and PConstants because

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

Lines changed: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ public String preprocess(File srcFolder,
391391
* for libraries that begin with a prefix like javax, since that includes
392392
* the OpenGL library, even though we're just returning true here, hrm...
393393
*/
394+
@SuppressWarnings("RedundantIfStatement")
394395
protected boolean ignorableImport(String pkg) {
395396
if (pkg.startsWith("java.")) return true;
396397
if (pkg.startsWith("javax.")) return true;
@@ -572,59 +573,78 @@ protected boolean exportApplication() throws IOException, SketchException {
572573
return false;
573574
}
574575

575-
File folder = null;
576-
for (String platformName : PConstants.platformNames) {
577-
// int platform = Platform.getIndex(platformName);
576+
/*
577+
for (StringDict.Entry entry : Platform.getSupportedVariants().entries()) {
578+
String variant = entry.key;
579+
String name = entry.value;
580+
}
581+
*/
578582

583+
final String hostVariant = Platform.getVariant();
584+
for (String variant : Preferences.get("export.variants").split(",")) {
579585
// Can only embed Java on the native platform
580-
boolean embedJava = (platform == PApplet.platform) &&
586+
boolean embedJava = variant.equals(hostVariant) &&
581587
Preferences.getBoolean("export.application.embed_java");
582588

583-
if (Preferences.getBoolean(JavaEditor.EXPORT_PREFIX + platformName)) {
584-
final int bits = Platform.getNativeBits();
585-
final String arch = Platform.getNativeArch();
586-
587-
if (Library.hasMultipleArch(platform, importedLibraries)) {
588-
// removing 32-bit export for 4.0 alpha 3
589-
/*
590-
// Don't try to export 32-bit on macOS, because it doesn't exist.
591-
if (platform != PConstants.MACOS) {
592-
// export the 32-bit version
593-
folder = new File(sketch.getFolder(), "application." + platformName + "32");
594-
if (!exportApplication(folder, platform, "32", embedJava && (bits == 32) && ("x86".equals(arch) || "i386".equals(arch)))) {
595-
return false;
596-
}
597-
}
598-
*/
599-
// export the 64-bit version
600-
//folder = new File(sketch.getFolder(), "application." + platformName + "64");
601-
// No longer including the 64 suffix in 4.0a3 because it's all 64-bit
602-
folder = new File(sketch.getFolder(), "application." + platformName);
603-
if (!exportApplication(folder, platform, "64", embedJava && (bits == 64) && "amd64".equals(arch))) {
604-
return false;
605-
}
606-
/*
607-
if (platform == PConstants.LINUX) {
608-
// export the arm versions as well
609-
folder = new File(sketch.getFolder(), "application.linux-armv6hf");
610-
if (!exportApplication(folder, platform, "armv6hf", embedJava && (bits == 32) && "arm".equals(arch))) {
611-
return false;
612-
}
613-
folder = new File(sketch.getFolder(), "application.linux-arm64");
614-
if (!exportApplication(folder, platform, "arm64", embedJava && (bits == 64) && "aarch64".equals(arch))) {
615-
return false;
616-
}
617-
}
618-
*/
619-
} else { // just make a single one for this platform
620-
folder = new File(sketch.getFolder(), "application." + platformName);
621-
if (!exportApplication(folder, platform, "", embedJava)) {
622-
return false;
623-
}
624-
}
589+
File folder = new File(sketch.getFolder(), variant);
590+
if (!exportApplication(folder, variant, embedJava)) {
591+
return false;
625592
}
626593
}
627594

595+
// File folder = null;
596+
// for (String platformName : PConstants.platformNames) {
597+
//// int platform = Platform.getIndex(platformName);
598+
//
599+
// // Can only embed Java on the native platform
600+
// boolean embedJava = (platform == PApplet.platform) &&
601+
// Preferences.getBoolean("export.application.embed_java");
602+
//
603+
// if (Preferences.getBoolean(JavaEditor.EXPORT_PREFIX + platformName)) {
604+
// final int bits = Platform.getNativeBits();
605+
// final String arch = Platform.getNativeArch();
606+
//
607+
// if (Library.hasMultipleArch(platform, importedLibraries)) {
608+
// // removing 32-bit export for 4.0 alpha 3
609+
// /*
610+
// // Don't try to export 32-bit on macOS, because it doesn't exist.
611+
// if (platform != PConstants.MACOS) {
612+
// // export the 32-bit version
613+
// folder = new File(sketch.getFolder(), "application." + platformName + "32");
614+
// if (!exportApplication(folder, platform, "32", embedJava && (bits == 32) && ("x86".equals(arch) || "i386".equals(arch)))) {
615+
// return false;
616+
// }
617+
// }
618+
// */
619+
// // export the 64-bit version
620+
// //folder = new File(sketch.getFolder(), "application." + platformName + "64");
621+
// // No longer including the 64 suffix in 4.0a3 because it's all 64-bit
622+
// folder = new File(sketch.getFolder(), "application." + platformName);
623+
// if (!exportApplication(folder, platform, "64", embedJava && (bits == 64) && "amd64".equals(arch))) {
624+
// return false;
625+
// }
626+
// /*
627+
// if (platform == PConstants.LINUX) {
628+
// // export the arm versions as well
629+
// folder = new File(sketch.getFolder(), "application.linux-armv6hf");
630+
// if (!exportApplication(folder, platform, "armv6hf", embedJava && (bits == 32) && "arm".equals(arch))) {
631+
// return false;
632+
// }
633+
// folder = new File(sketch.getFolder(), "application.linux-arm64");
634+
// if (!exportApplication(folder, platform, "arm64", embedJava && (bits == 64) && "aarch64".equals(arch))) {
635+
// return false;
636+
// }
637+
// }
638+
// */
639+
// } else { // just make a single one for this platform
640+
// folder = new File(sketch.getFolder(), "application." + platformName);
641+
// if (!exportApplication(folder, platform, "", embedJava)) {
642+
// return false;
643+
// }
644+
// }
645+
// }
646+
// }
647+
628648
return true; // all good
629649
}
630650

@@ -646,8 +666,10 @@ protected boolean exportApplication(File destFolder,
646666
}
647667
}
648668

649-
/// prep the output directory
650669

670+
/// getting started
671+
672+
int exportPlatform = Platform.getIndex(exportVariant);
651673
mode.prepareExportFolder(destFolder);
652674

653675

@@ -781,7 +803,7 @@ protected boolean exportApplication(File destFolder,
781803
/// add contents of 'library' folders to the export
782804
for (Library library : importedLibraries) {
783805
// add each item from the library folder / export list to the output
784-
for (File exportFile : library.getApplicationExports(exportPlatform, exportVariant)) {
806+
for (File exportFile : library.getApplicationExports(exportVariant)) {
785807
String exportName = exportFile.getName();
786808
if (!exportFile.exists()) {
787809
System.err.println(exportFile.getName() +

0 commit comments

Comments
 (0)