Skip to content

Commit

Permalink
Only build and include svm-foreign when building with JDK > 21
Browse files Browse the repository at this point in the history
Since oracle/graal#7980 the foreign API is only
available for JDK >= 22 builds.
  • Loading branch information
zakkak committed Jan 26, 2024
1 parent 77d917b commit 81a8e4e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ public static void main(String... args) throws IOException
FileSystem.copy(mandrelRepo.resolve(
Path.of("sdk", "mxbuild", PLATFORM, "native-image.exe.image-bash", "native-image.export-list")), nativeImageExport);
}
logger.debugf("Copy svm-preview...");
final Path svmForeign = mandrelJavaHome.resolve(Path.of("lib", "svm-preview", "builder", "svm-foreign.jar"));
final Path svmForeignSource = PathFinder.getFirstExisting(mandrelRepo.resolve(Path.of("substratevm", "mxbuild")).toString(), "svm-foreign.jar");
FileSystem.copy(svmForeignSource, svmForeign);
if (Runtime.version().feature() > 21)
{
logger.debugf("Copy svm-preview...");
final Path svmForeign = mandrelJavaHome.resolve(Path.of("lib", "svm-preview", "builder", "svm-foreign.jar"));
final Path svmForeignSource = PathFinder.getFirstExisting(mandrelRepo.resolve(Path.of("substratevm", "mxbuild")).toString(), "svm-foreign.jar");
FileSystem.copy(svmForeignSource, svmForeign);
}
}

if (!options.skipNative)
Expand Down Expand Up @@ -855,7 +858,7 @@ class Mx
Pattern.compile("\"version\"\\s*:\\s*\"([0-9.]*)\"");

static final List<BuildArgs> BUILD_JAVA_STEPS = List.of(
BuildArgs.of("--no-native", "--dependencies", "SVM,SVM_FOREIGN,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT")
BuildArgs.of("--no-native", "--dependencies", "SVM,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT" + (Runtime.version().feature() > 21 ? ",SVM_FOREIGN" : ""))
, BuildArgs.of("--only",
build.IS_WINDOWS ?
"native-image.exe.image-bash," +
Expand Down

0 comments on commit 81a8e4e

Please sign in to comment.