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 c1eaa23
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 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 @@ -854,20 +857,34 @@ class Mx
private static final Pattern DEPENDENCY_VERSION_PATTERN =
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("--only",
build.IS_WINDOWS ?
"native-image.exe.image-bash," +
"native-image-agent-library_native-image.properties," +
"native-image-launcher_native-image.properties," +
"native-image-diagnostics-agent-library_native-image.properties"
:
"native-image.image-bash," +
"native-image-agent-library_native-image.properties," +
"native-image-launcher_native-image.properties," +
"native-image-diagnostics-agent-library_native-image.properties")
);
static final List<BuildArgs> BUILD_JAVA_STEPS;

static {
String dependencies;
if (Runtime.version().feature() > 21)
{
dependencies = "SVM,SVM_FOREIGN,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT";
}
else
{
dependencies = "SVM,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT";
}

BUILD_JAVA_STEPS = List.of(
BuildArgs.of("--no-native", "--dependencies", dependencies)
, BuildArgs.of("--only",
build.IS_WINDOWS ?
"native-image.exe.image-bash," +
"native-image-agent-library_native-image.properties," +
"native-image-launcher_native-image.properties," +
"native-image-diagnostics-agent-library_native-image.properties"
:
"native-image.image-bash," +
"native-image-agent-library_native-image.properties," +
"native-image-launcher_native-image.properties," +
"native-image-diagnostics-agent-library_native-image.properties")
);
}

static final List<BuildArgs> BUILD_NATIVE_STEPS;

Expand Down

0 comments on commit c1eaa23

Please sign in to comment.