Skip to content

Commit

Permalink
fix!: add alias indirection for gvm toolchain
Browse files Browse the repository at this point in the history
- fix: add `gvm` toolchain to toolchain config repo
- fix: add aliases from `graalvm` → toolchain targets
- fix: adjust instructions for registering toolchains
- fix: adjust workspace toolchain registration logic

Breaking change:
When registering toolchains in a Bzlmod installation of these rules,
the target `@graalvm//:all` must be changed to two toolchain
registrations, based on the desired functionality:

  Register the Java toolchain:
  register_toolchains("@graalvm//:jvm")

  Register the GVM toolchain:
  register_toolchains("@graalvm//:sdk")

Fixes and closes #66.

Relates-To: #66
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Sep 2, 2023
1 parent f3ad698 commit d3451fa
Show file tree
Hide file tree
Showing 23 changed files with 1,140 additions and 58 deletions.
64 changes: 40 additions & 24 deletions .github/workflows/module.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,46 @@ jobs:
labs: false
skip: false

# Test: Bazel 4
- label: Bazel 4
target: sample
action: build
directory: "./example/integration_tests/bazel4"
labs: false
skip: ${{ contains(inputs.runner, 'windows') }}

# Test: Bazel 5
- label: Bazel 5
target: sample
action: build
directory: "./example/integration_tests/bazel5"
labs: false
skip: ${{ contains(inputs.runner, 'windows') }}

# Test: Bazel 6
- label: Bazel 6
target: sample
action: build
directory: "./example/integration_tests/bazel6"
labs: false
skip: false

# Test: Inert
- label: Inert
target: sample
action: build
directory: "./example/integration_tests/inert"
labs: false
skip: false

# Test: Inert Workspace
- label: Inert Workspace
target: sample
action: build
directory: "./example/integration_tests/inert-workspace"
labs: false
skip: false

# Test: Legacy Rules
- label: Legacy Rules
target: sample
Expand Down Expand Up @@ -243,30 +283,6 @@ jobs:
labs: false
skip: false

# Test: Bazel 4
- label: Bazel 4
target: sample
action: build
directory: "./example/integration_tests/bazel4"
labs: false
skip: ${{ contains(inputs.runner, 'windows') }}

# Test: Bazel 5
- label: Bazel 5
target: sample
action: build
directory: "./example/integration_tests/bazel5"
labs: false
skip: ${{ contains(inputs.runner, 'windows') }}

# Test: Bazel 6
- label: Bazel 6
target: sample
action: build
directory: "./example/integration_tests/bazel6"
labs: false
skip: false

steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
Expand Down
6 changes: 5 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ use_repo(
)

register_toolchains(
"@graalvm//:all",
"@graalvm//:jvm",
dev_dependency = True,
)
register_toolchains(
"@graalvm//:sdk",
dev_dependency = True,
)

Expand Down
25 changes: 13 additions & 12 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ gvm.graalvm(
],
)
use_repo(gvm, "graalvm")
register_toolchains("@graalvm//:all")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
```

## Usage: Java Toolchains
Expand All @@ -121,7 +122,8 @@ register_graalvm_toolchains()
**Via Bzlmod:**

```starlark
register_toolchains("@graalvm//:all")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
```

**To _use_ the toolchain, add this to your `.bazelrc`:**
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ gvm.graalvm(
],
)
use_repo(gvm, "graalvm")
register_toolchains("@graalvm//:all")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
```

## Usage
Expand Down
3 changes: 2 additions & 1 deletion docs/modern-bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")

# graalvm_repository(name = "graalvm" ...)

register_toolchains("@graalvm//:all")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
```

### Installation in `WORKSPACE.bazel`
Expand Down
3 changes: 2 additions & 1 deletion example/integration_tests/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ use_repo(
"graalvm",
)

register_toolchains("@graalvm//:all")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
3 changes: 2 additions & 1 deletion example/integration_tests/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/integration_tests/inert-workspace/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing at thie time.
1 change: 1 addition & 0 deletions example/integration_tests/inert-workspace/.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/inert-workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
19 changes: 19 additions & 0 deletions example/integration_tests/inert-workspace/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
workspace(name = "rules_graalvm_sample")

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

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

rules_graalvm_repositories()

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

graalvm_repository(
name = "graalvm",
distribution = "ce",
java_version = "20",
version = "20.0.2",
)
17 changes: 17 additions & 0 deletions example/integration_tests/inert-workspace/sample/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
java_library(
name = "java",
srcs = ["Main.java"],
)

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

alias(
name = "sample",
actual = "main",
)
5 changes: 5 additions & 0 deletions example/integration_tests/inert-workspace/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/inert/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --enable_bzlmod
1 change: 1 addition & 0 deletions example/integration_tests/inert/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-pre.20230816.3
27 changes: 27 additions & 0 deletions example/integration_tests/inert/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"Sample bzlmod-style project which uses the GraalVM Rules for Bazel."

module(
name = "rules_graalvm_bzlmod_sample",
version = "0.0.1",
)

bazel_dep(
name = "rules_java",
version = "6.5.0",
)
bazel_dep(
name = "rules_graalvm",
version = "0.0.0",
)
local_path_override(
module_name = "rules_graalvm",
path = "../../..",
)

gvm = use_extension("@rules_graalvm//:extensions.bzl", "graalvm")
gvm.graalvm(
name = "graalvm",
distribution = "ce",
java_version = "20",
version = "20.0.2",
)
Loading

0 comments on commit d3451fa

Please sign in to comment.