Skip to content

Commit

Permalink
Initial bzlmod support (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsharpe authored Jan 3, 2023
1 parent da21c8f commit fc20812
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build:clang --//cuda:compiler=clang

# https://github.com/cloudhan/rules_cuda/issues/1
build --ui_event_filters=-INFO

common:bzlmod --enable_bzlmod
5 changes: 5 additions & 0 deletions .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ jobs:
- run: bazelisk build @rules_cuda_examples//if_cuda:main
- run: bazelisk build @rules_cuda_examples//if_cuda:main --enable_cuda=False

- run: bazelisk build @rules_cuda_examples//basic:main --config=bzlmod
- run: bazelisk build @rules_cuda_examples//rdc:main --config=bzlmod
- run: bazelisk build @rules_cuda_examples//if_cuda:main --config=bzlmod
- run: bazelisk build @rules_cuda_examples//if_cuda:main --enable_cuda=False --config=bzlmod

- run: bazelisk shutdown
17 changes: 17 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module(
name = "rules_cuda",
compatibility_level = 1,
version = "0.1.1",
)

bazel_dep(name = "bazel_skylib", version = "1.2.1")
bazel_dep(name = "platforms", version = "0.0.4")

toolchain = use_extension("@rules_cuda//cuda:extensions.bzl", "local_toolchain")
use_repo(toolchain, "local_cuda")

register_toolchains(
"@local_cuda//toolchain:nvcc-local-toolchain",
"@local_cuda//toolchain/clang:clang-local-toolchain",
)

File renamed without changes.
4 changes: 4 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local_repository(
name = "rules_cuda_examples",
path = "examples",
)
8 changes: 8 additions & 0 deletions cuda/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Entry point for extensions used by bzlmod."""

load("//cuda/private:repositories.bzl", "local_cuda")

def _init(module_ctx):
local_cuda(name = "local_cuda")

local_toolchain = module_extension(implementation = _init)
4 changes: 2 additions & 2 deletions cuda/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _local_cuda_impl(repository_ctx):
clang_path = detect_clang(repository_ctx)
config_clang(repository_ctx, cuda, clang_path)

_local_cuda = repository_rule(
local_cuda = repository_rule(
implementation = _local_cuda_impl,
configure = True,
local = True,
Expand Down Expand Up @@ -212,4 +212,4 @@ def rules_cuda_dependencies():
],
)

_local_cuda(name = "local_cuda")
local_cuda(name = "local_cuda")
2 changes: 2 additions & 0 deletions examples/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build:clang --//cuda:compiler=clang

# https://github.com/cloudhan/rules_cuda/issues/1
build --ui_event_filters=-INFO

common:bzlmod --enable_bzlmod
12 changes: 12 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module(
name = "rules_cuda_examples",
compatibility_level = 1,
version = "0.0.0",
)

bazel_dep(name = "rules_cuda", version = "0.1.1")

cuda_toolchain = use_extension("@rules_cuda//cuda:extensions.bzl", "local_toolchain")
use_repo(cuda_toolchain, "local_cuda")

local_path_override(module_name = "rules_cuda", path = "..")
Empty file added examples/WORKSPACE.bzlmod
Empty file.

0 comments on commit fc20812

Please sign in to comment.