diff --git a/example/MODULE.bazel b/example/MODULE.bazel index a34785f..7e759ce 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -1,3 +1,5 @@ +module(name = "rules_runfiles_group_example") + bazel_dep(name = "rules_runfiles_group") bazel_dep(name = "rules_go", version = "0.60.0") bazel_dep(name = "hermetic_launcher", version = "0.0.5") @@ -10,21 +12,21 @@ local_path_override( path = "../", ) -local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") +local_starlark_repository = use_repo_rule("//producer/repository_rules:local_starlark_repository.bzl", "local_starlark_repository") -local_repository( +local_starlark_repository( name = "std", - path = "producer/stdlib_repo", + repo_file = "//producer:stdlib_repo/REPO.bazel", ) -local_repository( +local_starlark_repository( name = "fizzbuzz", - path = "third_party/fizzbuzz", + repo_file = "//:third_party/fizzbuzz/REPO.bazel", ) -local_repository( +local_starlark_repository( name = "stringutil", - path = "third_party/stringutil", + repo_file = "//:third_party/stringutil/REPO.bazel", ) http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") diff --git a/example/producer/BUILD.bazel b/example/producer/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/example/producer/repository_rules/BUILD.bazel b/example/producer/repository_rules/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/example/producer/repository_rules/local_starlark_repository.bzl b/example/producer/repository_rules/local_starlark_repository.bzl new file mode 100644 index 0000000..7c563a3 --- /dev/null +++ b/example/producer/repository_rules/local_starlark_repository.bzl @@ -0,0 +1,14 @@ +def _local_starlark_repository_impl(rctx): + rctx.watch(rctx.attr.repo_file) + repo_root = rctx.path(rctx.attr.repo_file).dirname + rctx.watch(repo_root) + rctx.symlink(repo_root, ".") + + +local_starlark_repository = repository_rule( + implementation = _local_starlark_repository_impl, + attrs = {"repo_file": attr.label( + mandatory = True, + doc = "REPO.bazel of the local starlark repository", + )}, +) diff --git a/example/producer/stdlib_repo/BUILD.bazel b/example/producer/stdlib_repo/BUILD.bazel index 1d2a04a..13a4458 100644 --- a/example/producer/stdlib_repo/BUILD.bazel +++ b/example/producer/stdlib_repo/BUILD.bazel @@ -1,5 +1,4 @@ -# buildifier: disable=canonical-repository -load("@@//producer/rules:starlark_library.bzl", "starlark_library") +load("@rules_runfiles_group_example//producer/rules:starlark_library.bzl", "starlark_library") starlark_library( name = "std", diff --git a/example/producer/stdlib_repo/sha256/BUILD.bazel b/example/producer/stdlib_repo/sha256/BUILD.bazel index 360e9c4..1ec8f05 100644 --- a/example/producer/stdlib_repo/sha256/BUILD.bazel +++ b/example/producer/stdlib_repo/sha256/BUILD.bazel @@ -1,6 +1,5 @@ -# buildifier: disable=canonical-repository -load("@@//producer/rules:starlark_library.bzl", "starlark_library") load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@rules_runfiles_group_example//producer/rules:starlark_library.bzl", "starlark_library") copy_file( name = "implementation_src", diff --git a/example/third_party/fizzbuzz/BUILD.bazel b/example/third_party/fizzbuzz/BUILD.bazel index 4ad64c2..db01e76 100644 --- a/example/third_party/fizzbuzz/BUILD.bazel +++ b/example/third_party/fizzbuzz/BUILD.bazel @@ -1,5 +1,4 @@ -# buildifier: disable=canonical-repository -load("@@//producer/rules:starlark_library.bzl", "starlark_library") +load("@rules_runfiles_group_example//producer/rules:starlark_library.bzl", "starlark_library") starlark_library( name = "fizzbuzz", diff --git a/example/third_party/stringutil/BUILD.bazel b/example/third_party/stringutil/BUILD.bazel index 55112e0..fa7a6b3 100644 --- a/example/third_party/stringutil/BUILD.bazel +++ b/example/third_party/stringutil/BUILD.bazel @@ -1,5 +1,4 @@ -# buildifier: disable=canonical-repository -load("@@//producer/rules:starlark_library.bzl", "starlark_library") +load("@rules_runfiles_group_example//producer/rules:starlark_library.bzl", "starlark_library") starlark_library( name = "stringutil",