Skip to content

Commit

Permalink
feat: support for latest gvm release → 23.1.0
Browse files Browse the repository at this point in the history
- feat: add necessary support to mapping generator for new release
- fix: ambiguity with original gvm `21.0.0` release
- fix: `graalvm-ce-20` test was using oracle
- test: add ce test for `java21`
- test: add oracle test for `java21`
- chore: regenerate bindist mappings
- chore: deprecate components via `components=` property (only on
  new version)

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Sep 20, 2023
1 parent e892b52 commit 8c5edef
Show file tree
Hide file tree
Showing 29 changed files with 793 additions and 600 deletions.
32 changes: 12 additions & 20 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,10 @@ module(
version = "0.10.3",
)

JAVA_VERSION = "20"

PYTHON_VERSION = "3.11"

NODE_VERSION = "20.5.0"

GRAALVM_VERSION = "20.0.2"

GRAALVM_DIST = "ce"

GRAALVM_SDK_VERSION = "23.0.1"

GRAALVM_COMPONENTS = [
"wasm",
"js",
]

##
## Dependencies: API
##
Expand All @@ -36,7 +23,7 @@ bazel_dep(
)
bazel_dep(
name = "rules_java",
version = "6.4.0",
version = "6.5.1",
)
bazel_dep(
name = "bazel_skylib",
Expand Down Expand Up @@ -141,6 +128,8 @@ bazel_dep(
# rules_jvm_external
################################################################################

GRAALVM_SDK_VERSION = "23.1.0"

MAVEN_ARTIFACTS = [
"org.graalvm.nativeimage:svm:%s" % GRAALVM_SDK_VERSION,
"org.graalvm.sdk:graal-sdk:%s" % GRAALVM_SDK_VERSION,
Expand Down Expand Up @@ -180,23 +169,26 @@ gvm = use_extension(
)
gvm.graalvm(
name = "graalvm",
components = GRAALVM_COMPONENTS,
distribution = GRAALVM_DIST,
java_version = JAVA_VERSION,
version = GRAALVM_VERSION,
distribution = "ce",
java_version = "21",
version = "23.1.0",
)
use_repo(
gvm,
"graalvm",
)
use_repo(
gvm,
"graalvm_toolchains",
)

register_toolchains(
"@graalvm//:jvm",
"@graalvm_toolchains//:toolchain",
dev_dependency = True,
)

register_toolchains(
"@graalvm//:sdk",
"@graalvm_toolchains//:toolchain_gvm",
dev_dependency = True,
)

Expand Down
961 changes: 476 additions & 485 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/integration_tests/graalvm-ce-20/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")

graalvm_repository(
name = "graalvm",
distribution = "oracle",
distribution = "ce",
java_version = "20",
version = "20.0.2",
)
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-ce-21/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing at this time.
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-ce-21/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-pre.20230816.3
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-ce-21/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
21 changes: 21 additions & 0 deletions example/integration_tests/graalvm-ce-21/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
workspace(name = "rules_graalvm_sample")

local_repository(
name = "rules_graalvm",
path = "../../..",
)

load("@rules_graalvm//graalvm:workspace.bzl", "register_graalvm_toolchains", "rules_graalvm_repositories")

rules_graalvm_repositories()

register_graalvm_toolchains()

load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")

graalvm_repository(
name = "graalvm",
distribution = "ce",
java_version = "21",
version = "23.1.0",
)
28 changes: 28 additions & 0 deletions example/integration_tests/graalvm-ce-21/sample/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load(
"@rules_graalvm//graalvm:defs.bzl",
"native_image",
)

java_library(
name = "java",
srcs = ["Main.java"],
)

java_binary(
name = "main",
main_class = "Main",
runtime_deps = [
":java",
],
)

native_image(
name = "main-native",
main_class = "Main",
deps = [":java"],
)

alias(
name = "sample",
actual = "main-native",
)
5 changes: 5 additions & 0 deletions example/integration_tests/graalvm-ce-21/sample/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Main {
public static void main(String args[]) {
System.out.println("Hello, GraalVM!");
}
}
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-oracle-21/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing at this time.
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-oracle-21/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-pre.20230816.3
1 change: 1 addition & 0 deletions example/integration_tests/graalvm-oracle-21/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
21 changes: 21 additions & 0 deletions example/integration_tests/graalvm-oracle-21/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
workspace(name = "rules_graalvm_sample")

local_repository(
name = "rules_graalvm",
path = "../../..",
)

load("@rules_graalvm//graalvm:workspace.bzl", "register_graalvm_toolchains", "rules_graalvm_repositories")

rules_graalvm_repositories()

register_graalvm_toolchains()

load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")

graalvm_repository(
name = "graalvm",
distribution = "oracle",
java_version = "21",
version = "23.1.0",
)
28 changes: 28 additions & 0 deletions example/integration_tests/graalvm-oracle-21/sample/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load(
"@rules_graalvm//graalvm:defs.bzl",
"native_image",
)

java_library(
name = "java",
srcs = ["Main.java"],
)

java_binary(
name = "main",
main_class = "Main",
runtime_deps = [
":java",
],
)

native_image(
name = "main-native",
main_class = "Main",
deps = [":java"],
)

alias(
name = "sample",
actual = "main-native",
)
5 changes: 5 additions & 0 deletions example/integration_tests/graalvm-oracle-21/sample/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Main {
public static void main(String args[]) {
System.out.println("Hello, GraalVM!");
}
}
11 changes: 3 additions & 8 deletions internal/config.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"Defines configuration and pinned versions for the GraalVM Rules project."

GRAALVM_VERSION = "20.0.2"
GRAALVM_VERSION = "21.0.0"

GRAALVM_SDK_VERSION = "23.0.1"
GRAALVM_SDK_VERSION = "23.1.0"

GRAALVM_DISTRIBUTION = "ce"

GRAALVM_JAVA_VERSION = "20"
GRAALVM_JAVA_VERSION = "21"

GRAALVM_SHA = None

Expand Down Expand Up @@ -49,11 +49,6 @@ MAVEN_REPOSITORIES = [
"https://repo1.maven.org/maven2",
]

GRAALVM_COMPONENTS = [
"wasm",
"js",
]

TARGET_JAVA_VERSIONS = [
"8",
"11",
Expand Down
37 changes: 33 additions & 4 deletions internal/graalvm_bindist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ def _get_bazel_version():
return versions.get() or "9999.0.0"

def _get_artifact_info(ctx, dist, platform, version, component = None, strict = True):
info = resolve_distribution_artifact(dist, platform, version, component, strict)
info = resolve_distribution_artifact(
dist,
platform,
version,
ctx.attr.java_version,
component,
strict,
)
if info == None:
return None
return struct(component = component, **info)
Expand Down Expand Up @@ -192,14 +199,20 @@ def _build_component_graph(components):
effective_components.append(component)
return effective_components

def _detect_older_gvm_version(version):
def _detect_older_gvm_version(ctx):
"""Checks if a version should be treated as an "older" GraalVM version, before release alignment."""
return version != None and _graal_version_configs.get(version) != None

version = ctx.attr.version
java_version = ctx.attr.java_version

if java_version != "21" and not int(java_version) > 20:
return version != None and _graal_version_configs.get(version) != None
return False # force newer resolution on java 21+

def _graal_bindist_repository_impl(ctx):
"""Implements the GraalVM repository rule (`graalvm_repository`)."""

if ctx.attr.distribution == None or _detect_older_gvm_version(ctx.attr.version):
if ctx.attr.distribution == None or _detect_older_gvm_version(ctx):
platform, os, archive = _get_platform(ctx, False)
version = ctx.attr.version
java_version = ctx.attr.java_version
Expand Down Expand Up @@ -294,6 +307,7 @@ def _graal_bindist_repository_impl(ctx):
dist_name,
platform,
version,
java_version,
strict = False,
)
if config == None:
Expand Down Expand Up @@ -731,6 +745,21 @@ def graalvm_repository(
**kwargs: Passed to the underlying bindist repository rule.
"""

if (version == "21.0.0" and (java_version != "21" and java_version != "21.0.0")):
print("""
Selected older GraalVM version at tag `21.0.0`; if you meant to select the newer Java 21 release,
please set the `java_version` to `21`, and the GraalVM `version` to `23.1.0`.
""")

if ((java_version == "21") or (version == "21.0.0" or version == "23.1.0" or version == "latest")):
if len(components) > 0:
fail("""
Components are no longer distributed via the GraalVM Updater (gu) tool at GraalVM 23.1.0+/Java 21+.
Please use Maven components instead.
To learn more about this transition, see: https://medium.com/graalvm/truffle-unchained-13887b77b62c
""")

toolchain_repo_name = toolchain_repo_name or (name + "_toolchains")

# if we're running on Bazel before 7, we need to omit the bootstrap toolchain, because
Expand Down
Loading

0 comments on commit 8c5edef

Please sign in to comment.