Skip to content

Commit

Permalink
fix: always create GraalVM native toolchain
Browse files Browse the repository at this point in the history
If `graalvm_repository`'s `toolchain` argument is `False`, a toolchain
for use with `native_image` should still be generated.
  • Loading branch information
fmeum committed Sep 11, 2023
1 parent 62e6ee1 commit 79d8eca
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions internal/graalvm_bindist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ def graalvm_repository(
java_version: Java version to use/declare.
version: Version of the GraalVM release.
distribution: Which GVM distribution to download - `ce`, `community`, or `oracle`.
toolchain: Whether to create a Java toolchain from this GVM installation.
toolchain_prefix: Name prefix to use for the toolchain; defaults to `graalvm`.
toolchain: Whether to create a Java runtime toolchain from this GVM installation.
toolchain_prefix: Name prefix to use for the Java toolchain; defaults to `graalvm`.
target_compatible_with: Compatibility tags to apply.
components: Components to install in the target GVM installation.
setup_actions: GraalVM Updater commands that should be run; pass complete command strings that start with "gu".
Expand Down Expand Up @@ -750,10 +750,32 @@ toolchain(
toolchain = "@{repo}//:jdk".format(repo = name),
)

toolchain_config_build_file = """
alias(
name = "toolchain_gvm",
actual = "gvm",
visibility = ["//visibility:public"],
)
toolchain(
name = "gvm",
exec_compatible_with = [
{gvm_toolchain_tags_exec}
],
target_compatible_with = [
{gvm_toolchain_tags_target}
],
toolchain = "@{name}//:gvm",
toolchain_type = "@rules_graalvm//graalvm/toolchain",
visibility = ["//visibility:public"],
)
""".format(
name = name,
gvm_toolchain_tags_exec = "",
gvm_toolchain_tags_target = "",
)

if toolchain:
_toolchain_config(
name = toolchain_repo_name,
build_file = """
toolchain_config_build_file += """
config_setting(
name = "prefix_version_setting",
values = {{"java_runtime_version": "{prefix}_{version}"}},
Expand All @@ -772,23 +794,6 @@ alias(
}}),
visibility = ["//visibility:private"],
)
alias(
name = "toolchain_gvm",
actual = "gvm",
visibility = ["//visibility:public"],
)
toolchain(
name = "gvm",
exec_compatible_with = [
{gvm_toolchain_tags_exec}
],
target_compatible_with = [
{gvm_toolchain_tags_target}
],
toolchain = "@{name}//:gvm",
toolchain_type = "@rules_graalvm//graalvm/toolchain",
visibility = ["//visibility:public"],
)
toolchain(
name = "toolchain",
target_compatible_with = {target_compatible_with},
Expand All @@ -799,15 +804,14 @@ toolchain(
)
{bootstrap_runtime_toolchain}
""".format(
name = name,
prefix = toolchain_prefix or "graalvm",
version = java_version,
target_compatible_with = target_compatible_with,
toolchain = "@{repo}//:jdk".format(repo = name),
bootstrap_runtime_toolchain = bootstrap_runtime_toolchain,
gvm_toolchain_tags_exec = "",
gvm_toolchain_tags_target = "",
),
name = name,
prefix = toolchain_prefix or "graalvm",
version = java_version,
target_compatible_with = target_compatible_with,
toolchain = "@{repo}//:jdk".format(repo = name),
bootstrap_runtime_toolchain = bootstrap_runtime_toolchain,
gvm_toolchain_tags_exec = "",
gvm_toolchain_tags_target = "",
)

if not register_all:
Expand Down

0 comments on commit 79d8eca

Please sign in to comment.