-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels passed to module extensions don't survive until BUILD time #14580
Comments
The root problem is that labels carry capabilities, but they don't survive the "text" layer that repo rules have to go through to create BUILD files. In foo/MODULE.bazel: bazel_dep(name="bar", version="1.0")
ext = use_extension("@bar//:extensions.bzl", "ext")
ext.tag(label = "//my:label") This allows repo_rule = repository_rule(implementation=..., attrs={"label":attr.label()})
def _ext_impl(mctx):
repo_rule(name="my_repo",label=mctx.modules[0].tag[0].label) The problem arises when we'd like to read We need to think about how to solve this problem. |
bzlmod
extensions cannot reference main workspace
Would it be possible to make the stringification of a Label return a repository-absolute label string that uses canonical repository names, at least with In general, I find it very difficult to wrap my head around how repository mapped labels and repository rules interact. I am proposing this solution since being able to generate fully absolute label strings from labels that are not subject to repo mappings would perhaps not only solve the current issue, but also simplify the overall process of writing repository rules with bzlmod. |
Duping against #15593 |
Description of the problem / feature request:
I am attempting to modularise
apple_rules_lint
. Users will register linters using a call similar to this in theirMODULE.bazel
:Behind the scenes, this creates a new
@apple_linters
workspace that is only ever used byapple_rules_lint
(whichapple_rules_lint
declares it uses). This generated workspace contains a build file similar to:The repository rule used to create this workspace has expanded the
:default_config
to@//:default_config
, which when not usingbzlmod
correctly refers to main workspace of the project.When using
bzlmod
, the following error occurs:Feature requests: what underlying problem are you trying to solve with this feature?
I want to automatically add linters to a project, and there's no way of knowing beforehand which repos need to be visible. The main project can add
use_repo
definitions, but as a module there's no way to know which repos the user will want access to.What's the output of
bazel info release
?release 5.0.0rc4
The text was updated successfully, but these errors were encountered: