From 317459a1c260b9dccce1888e2ebb2f2d86427545 Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 18 Feb 2022 09:24:19 +0100 Subject: [PATCH 1/4] Check GraalVM version before returning macos/darwin platform. This closes #1121 --- .../substrate/model/InternalProjectConfiguration.java | 2 +- .../substrate/target/AbstractTargetConfiguration.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/model/InternalProjectConfiguration.java b/src/main/java/com/gluonhq/substrate/model/InternalProjectConfiguration.java index fac96e4d..d8553e4e 100644 --- a/src/main/java/com/gluonhq/substrate/model/InternalProjectConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/model/InternalProjectConfiguration.java @@ -117,7 +117,7 @@ public Path getGraalPath() { return Objects.requireNonNull(this.publicConfig.getGraalPath(), "GraalVM Path is not defined"); } - private Version getGraalVersion() throws IOException { + public Version getGraalVersion() throws IOException { String pattern = "GraalVM .*?(\\d\\d.\\d.\\d)"; ProcessRunner graalJava; try { diff --git a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java index 3ff4d718..84eeb5e8 100644 --- a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java @@ -38,6 +38,7 @@ import com.gluonhq.substrate.util.Logger; import com.gluonhq.substrate.util.ProcessRunner; import com.gluonhq.substrate.util.Strings; +import com.gluonhq.substrate.util.Version; import java.io.BufferedWriter; import java.io.File; @@ -359,6 +360,14 @@ private String getJniPlatformArg() { private String getJniPlatform() { Triplet target = projectConfiguration.getTargetTriplet(); + boolean graalVM221 = false; + try { + Version graalVersion = projectConfiguration.getGraalVersion(); + if ((graalVersion.getMajor() > 21) && (graalVersion.getMinor() >0)) graalVM221 = true; + } catch (IOException ex) { + ex.printStackTrace(); + Logger.logSevere("Could not detect GraalVM version, assuming lower than 22.1"); + } String os = target.getOs(); String arch = target.getArch(); switch (os) { @@ -380,7 +389,7 @@ private String getJniPlatform() { } return "IOS_AARCH64"; case Constants.OS_DARWIN: - return "DARWIN_AMD64"; + return graalVM221 ? "MACOS_AMD64" : "DARWIN_AMD64"; case Constants.OS_WINDOWS: return "WINDOWS_AMD64"; case Constants.OS_ANDROID: From a38628270012dbfa3b633f98af1635871e67f833 Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 18 Feb 2022 10:43:25 +0100 Subject: [PATCH 2/4] Process reviewer comments --- .../gluonhq/substrate/target/AbstractTargetConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java index 84eeb5e8..0f9a2d46 100644 --- a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java @@ -363,7 +363,7 @@ private String getJniPlatform() { boolean graalVM221 = false; try { Version graalVersion = projectConfiguration.getGraalVersion(); - if ((graalVersion.getMajor() > 21) && (graalVersion.getMinor() >0)) graalVM221 = true; + graalVM221 = ((graalVersion.getMajor() > 21) && (graalVersion.getMinor() >0)); } catch (IOException ex) { ex.printStackTrace(); Logger.logSevere("Could not detect GraalVM version, assuming lower than 22.1"); From 21738c5935d2676f264d0319c54e86c83b996180 Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 18 Feb 2022 10:45:52 +0100 Subject: [PATCH 3/4] if we can't get the Graal version, we have to stop now. --- .../gluonhq/substrate/target/AbstractTargetConfiguration.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java index 0f9a2d46..8b671777 100644 --- a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java @@ -365,8 +365,7 @@ private String getJniPlatform() { Version graalVersion = projectConfiguration.getGraalVersion(); graalVM221 = ((graalVersion.getMajor() > 21) && (graalVersion.getMinor() >0)); } catch (IOException ex) { - ex.printStackTrace(); - Logger.logSevere("Could not detect GraalVM version, assuming lower than 22.1"); + Logger.logFatal(ex, "Could not detect GraalVM version, assuming lower than 22.1"); } String os = target.getOs(); String arch = target.getArch(); From 3ef3765f3a7b44703425c342087b467f878204a0 Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 18 Feb 2022 10:46:42 +0100 Subject: [PATCH 4/4] change wordings of fatal error --- .../gluonhq/substrate/target/AbstractTargetConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java index 8b671777..d2618ea4 100644 --- a/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AbstractTargetConfiguration.java @@ -365,7 +365,7 @@ private String getJniPlatform() { Version graalVersion = projectConfiguration.getGraalVersion(); graalVM221 = ((graalVersion.getMajor() > 21) && (graalVersion.getMinor() >0)); } catch (IOException ex) { - Logger.logFatal(ex, "Could not detect GraalVM version, assuming lower than 22.1"); + Logger.logFatal(ex, "Could not detect GraalVM version, stopping now."); } String os = target.getOs(); String arch = target.getArch();