Skip to content

Commit

Permalink
Allow bzl_library to depend on non-bzl_library targets
Browse files Browse the repository at this point in the history
Notably, `filegroup`. `bzl_library` doesn't actually read anything from the `StarlarkLibraryInfo` provider, and requiring all deps to be other `bzl_library` targets is really painful for anyone loading .bzls from `@bazel_tools` or `@platforms` because those core modules/repos don't want a dependency on Skylib just for access to `bzl_library`.

The medium-term plan will be to move `bzl_library` into `@bazel_tools`; but before then, this can serve as a stop-gap.
  • Loading branch information
Wyverald committed Apr 23, 2024
1 parent 054ebf5 commit 11fd29b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
5 changes: 1 addition & 4 deletions bzl_library.bzl
Expand Up @@ -54,10 +54,7 @@ bzl_library = rule(
),
"deps": attr.label_list(
allow_files = [".bzl", ".scl"],
providers = [
[StarlarkLibraryInfo],
],
doc = """List of other `bzl_library` targets that are required by the
doc = """List of other `bzl_library` or `filegroup` targets that are required by the
Starlark files listed in `srcs`.""",
),
},
Expand Down
32 changes: 32 additions & 0 deletions tests/bzl_library/BUILD
@@ -0,0 +1,32 @@
load("//:bzl_library.bzl", "bzl_library")
load("//rules:build_test.bzl", "build_test")

bzl_library(
name = "a_bl",
srcs = ["a.bzl"],
)

bzl_library(
name = "b_bl",
srcs = ["b.bzl"],
deps = [":a_bl"],
)

filegroup(
name = "a_fg",
srcs = ["a.bzl"],
)

bzl_library(
name = "b_fg",
srcs = ["b.bzl"],
deps = [":a_fg"],
)

build_test(
name = "test_bzl_library",
targets = [
":b_bl",
":b_fg",
],
)
1 change: 1 addition & 0 deletions tests/bzl_library/a.bzl
@@ -0,0 +1 @@
A = 30
2 changes: 2 additions & 0 deletions tests/bzl_library/b.bzl
@@ -0,0 +1,2 @@
load(":a.bzl", "A")
B = A + 70

0 comments on commit 11fd29b

Please sign in to comment.