Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check GraalVM version before returning macos/darwin platform. #1123

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if and assign graalVM221directly?

} catch (IOException ex) {
ex.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need an stacktrace here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? This should never happen, so if it happens, we at least need a detailed reason (or we should call System.exit())

Logger.logSevere("Could not detect GraalVM version, assuming lower than 22.1");
}
String os = target.getOs();
String arch = target.getArch();
switch (os) {
Expand All @@ -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:
Expand Down