Skip to content

Commit fc20812

Browse files
authored
Initial bzlmod support (bazel-contrib#36)
1 parent da21c8f commit fc20812

File tree

10 files changed

+52
-2
lines changed

10 files changed

+52
-2
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ build:clang --//cuda:compiler=clang
1313

1414
# https://github.com/cloudhan/rules_cuda/issues/1
1515
build --ui_event_filters=-INFO
16+
17+
common:bzlmod --enable_bzlmod

.github/workflows/build-tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ jobs:
6767
- run: bazelisk build @rules_cuda_examples//if_cuda:main
6868
- run: bazelisk build @rules_cuda_examples//if_cuda:main --enable_cuda=False
6969

70+
- run: bazelisk build @rules_cuda_examples//basic:main --config=bzlmod
71+
- run: bazelisk build @rules_cuda_examples//rdc:main --config=bzlmod
72+
- run: bazelisk build @rules_cuda_examples//if_cuda:main --config=bzlmod
73+
- run: bazelisk build @rules_cuda_examples//if_cuda:main --enable_cuda=False --config=bzlmod
74+
7075
- run: bazelisk shutdown

MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module(
2+
name = "rules_cuda",
3+
compatibility_level = 1,
4+
version = "0.1.1",
5+
)
6+
7+
bazel_dep(name = "bazel_skylib", version = "1.2.1")
8+
bazel_dep(name = "platforms", version = "0.0.4")
9+
10+
toolchain = use_extension("@rules_cuda//cuda:extensions.bzl", "local_toolchain")
11+
use_repo(toolchain, "local_cuda")
12+
13+
register_toolchains(
14+
"@local_cuda//toolchain:nvcc-local-toolchain",
15+
"@local_cuda//toolchain/clang:clang-local-toolchain",
16+
)
17+
File renamed without changes.

WORKSPACE.bzlmod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
local_repository(
2+
name = "rules_cuda_examples",
3+
path = "examples",
4+
)

cuda/extensions.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Entry point for extensions used by bzlmod."""
2+
3+
load("//cuda/private:repositories.bzl", "local_cuda")
4+
5+
def _init(module_ctx):
6+
local_cuda(name = "local_cuda")
7+
8+
local_toolchain = module_extension(implementation = _init)

cuda/private/repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _local_cuda_impl(repository_ctx):
182182
clang_path = detect_clang(repository_ctx)
183183
config_clang(repository_ctx, cuda, clang_path)
184184

185-
_local_cuda = repository_rule(
185+
local_cuda = repository_rule(
186186
implementation = _local_cuda_impl,
187187
configure = True,
188188
local = True,
@@ -212,4 +212,4 @@ def rules_cuda_dependencies():
212212
],
213213
)
214214

215-
_local_cuda(name = "local_cuda")
215+
local_cuda(name = "local_cuda")

examples/.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ build:clang --//cuda:compiler=clang
1313

1414
# https://github.com/cloudhan/rules_cuda/issues/1
1515
build --ui_event_filters=-INFO
16+
17+
common:bzlmod --enable_bzlmod

examples/MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module(
2+
name = "rules_cuda_examples",
3+
compatibility_level = 1,
4+
version = "0.0.0",
5+
)
6+
7+
bazel_dep(name = "rules_cuda", version = "0.1.1")
8+
9+
cuda_toolchain = use_extension("@rules_cuda//cuda:extensions.bzl", "local_toolchain")
10+
use_repo(cuda_toolchain, "local_cuda")
11+
12+
local_path_override(module_name = "rules_cuda", path = "..")

examples/WORKSPACE.bzlmod

Whitespace-only changes.

0 commit comments

Comments
 (0)