facebook / facebook/buck2

How do I call a rule impl explicitly?

Open
#714 1 comment 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

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 around `cxx_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 example `ctx.label` would likely be incorrect.

Is there something I'm missing here?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.