From 0f5eb4b357e4ceb52cd84757feb0edfb186ff124 Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Mon, 10 Jun 2024 12:49:45 +0200 Subject: [PATCH 1/2] Added support for polyglot isolates for specific platform. --- README.md | 1 + pom.xml | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88effc1..e56750b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Download Maven or import as Maven project into your IDE. * `mvn -Pnative package` to build a native-image * `mvn -Passembly package` to build an uber JAR containing all dependencies using the Maven Assembly Plugin. The resulting JAR can be executed using `java -jar embedding-1.0-SNAPSHOT-jar-with-dependencies.jar`. We do recommend not using shading whenever possible. * `mvn -Pshade package` to build an uber JAR containing all dependencies using the Maven Shade Plugin. The resulting JAR can be executed using `java -jar embedding-1.0-SNAPSHOT.jar`. We do recommend not using shading whenever possible. +* `mvn -Pisolated package` to install native isolate versions of languages for the current platform Please see the [pom.xml](./pom.xml) file for further details on the configuration. diff --git a/pom.xml b/pom.xml index ae68eb9..6ddbe63 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,8 @@ Switch to community licenses by adding a `-community` suffix to the artefact id (e.g. `js-communtiy`). Switch to native isolate versions of languages by adding a `-isolate` suffix. (`js-isolate`). + Since Polyglot version 24.1, native isolate versions of languages for specific platforms are supported. + Refer to the `isolate` profiles for instructions on how to activate them. Any dependency in the org.graalvm.polyglot group is intended for use by polyglot embeddings. --> @@ -401,8 +403,90 @@ + + + + isolate-linux-amd64 + + + unix + linux + amd64 + + + + linux-amd64 + + + + + isolate-linux-aarch64 + + + unix + linux + aarch64 + + + + linux-aarch64 + + + + + isolate-darwin-amd64 + + + mac + x86_64 + + + + darwin-amd64 + + + + + isolate-darwin-aarch64 + + + mac + aarch64 + + + + darwin-aarch64 + + + + + isolate-windows-amd64 + + + windows + x86_64 + + + + windows-amd64 + + + + isolated + + + org.graalvm.polyglot + js-isolate-${isolate.platform} + ${graalvm.version} + pom + + + - - From ce1ce6888fd88b6da8a76c0e8d16375e2dc14480 Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Thu, 13 Jun 2024 11:06:59 +0200 Subject: [PATCH 2/2] Resolved review comments. --- README.md | 5 +- pom.xml | 138 ++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 121 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e56750b..94c5861 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,12 @@ https://www.graalvm.org/latest/reference-manual/embed-languages/ Download Maven or import as Maven project into your IDE. -* `mvn package` build using javac +* `mvn package` build using `javac`. Starting from GraalVM Polyglot API version 24.1.0, you can use `mvn -Pisolated package` to build with the native isolate version of a guest language. By default, only the native isolate library for the current platform is installed. To install native isolate libraries for all supported platforms, use `mvn -Pisolated -Disolated.all.platforms package`. * `mvn test` to run the tests -* `mvn exec:exec` to run the Main application +* `mvn exec:exec` to run the application. Starting from GraalVM Polyglot API version 24.1.0, you can use `mvn -Pisolated exec:exec` to embed the native isolate version of a guest language. * `mvn -Pnative package` to build a native-image * `mvn -Passembly package` to build an uber JAR containing all dependencies using the Maven Assembly Plugin. The resulting JAR can be executed using `java -jar embedding-1.0-SNAPSHOT-jar-with-dependencies.jar`. We do recommend not using shading whenever possible. * `mvn -Pshade package` to build an uber JAR containing all dependencies using the Maven Shade Plugin. The resulting JAR can be executed using `java -jar embedding-1.0-SNAPSHOT.jar`. We do recommend not using shading whenever possible. -* `mvn -Pisolated package` to install native isolate versions of languages for the current platform Please see the [pom.xml](./pom.xml) file for further details on the configuration. diff --git a/pom.xml b/pom.xml index 6ddbe63..8a39545 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ Switch to community licenses by adding a `-community` suffix to the artefact id (e.g. `js-communtiy`). Switch to native isolate versions of languages by adding a `-isolate` suffix. (`js-isolate`). - Since Polyglot version 24.1, native isolate versions of languages for specific platforms are supported. + Starting from GraalVM Polyglot API version 24.1.0, native isolate versions of languages for specific platforms are supported. Refer to the `isolate` profiles for instructions on how to activate them. Any dependency in the org.graalvm.polyglot group is intended for use by polyglot embeddings. @@ -108,8 +108,10 @@ ${java.home}/bin/java - + --module-path -m @@ -121,8 +123,10 @@ ${java.home}/bin/java - + --module-path -m @@ -225,7 +229,7 @@ copy-dependencies @@ -404,14 +408,14 @@ - isolate-linux-amd64 + isolated-linux-amd64 unix @@ -420,12 +424,12 @@ - linux-amd64 + -linux-amd64 - isolate-linux-aarch64 + isolated-linux-aarch64 unix @@ -434,12 +438,12 @@ - linux-aarch64 + -linux-aarch64 - isolate-darwin-amd64 + isolated-darwin-amd64 mac @@ -447,12 +451,12 @@ - darwin-amd64 + -darwin-amd64 - isolate-darwin-aarch64 + isolated-darwin-aarch64 mac @@ -460,12 +464,12 @@ - darwin-aarch64 + -darwin-aarch64 - isolate-windows-amd64 + isolated-windows-amd64 windows @@ -473,20 +477,116 @@ - windows-amd64 + -windows-amd64 + + + isolated-all-platforms + + + isolated.all.platforms + + + + + + + isolated + + js + org.graalvm.polyglot - js-isolate-${isolate.platform} + js-isolate${isolate.platform.suffix} + ${graalvm.version} + pom + + + + org.graalvm.polyglot + js ${graalvm.version} pom + provided + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + + ${isolated.language.id} + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + + exec + + + + no-runtime-compilation + + exec + + + ${java.home}/bin/java + + -Dpolyglot.engine.SpawnIsolate=${isolated.language.id} + + --module-path + + -m + embedding/org.example.embedding.Main + + + + + + ${java.home}/bin/java + + -Dpolyglot.engine.SpawnIsolate=${isolated.language.id} + + --module-path + + -m + embedding/org.example.embedding.Main + + + + + -