-
Notifications
You must be signed in to change notification settings - Fork 214
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
How do I call a rule impl explicitly? #714
Comments
For anyone also interested in this, getting the providers from another rule can be done with something like: my_wrapper_rule = rule(
impl = lambda ctx: ctx.attrs.dep.providers,
attrs = {
"dep": attrs.dep(),
},
) It's not quite the same as it requires 2 targets to be defined. It can be abstracted away behind a macro, which is less than ideal, but better than nothing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've heard in multiple contexts that calling a rule's implementation from another rule could make sense.
I have previously wanted to do that to get the providers from
cxx_library
and add my own on top, and I now want to do it to create a wrapper aroundcxx_library
that has a transition applied to it (I wish I could just use target transitions from a macro, but they don't exist yet!). In those cases, a macro just doesn't cut it.So my question is: how? Rule implementations take a single
AnalysisContext
parameter, which I cannot mutate at will, nor create myself. If I need to amend the attrs passed to the underlying impl, I am stuck; but even without that, I don't think that forwarding the context as is would be correct: for examplectx.label
would likely be incorrect.Is there something I'm missing here?
The text was updated successfully, but these errors were encountered: