aquery function confusion (deps vs all_actions)
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
I wanted to do something that I thought was pretty simple. Get all the actions for a particular target. I tried `all_actions()`, and for a while I thought that was doing the right thing.
Later I came to find out that this would include actions that, I guess, aren't normally run when you build the target. I came to this conclusion after noticing that when I run `buck2 aquery all_actions()` I will occasionally see both PIC and non-PIC entries in the output for the exact same file. I know this isn't correct, because when I just build the target `buck2 build `, no actions execute which build the PIC version.
So I started playing around with other query functions. I tried `buck2 aquery deps(, 1)` and found that this more closely matches the real set of actions that run when you build the target. But that returns a bunch of dependent targets that I didn't want. Like toolchain targets, and other actions for targets that aren't that exact same target literal.
Then I found that I can use `filter(, deps(, 1))` to get the exact set that I wanted.
But that didn't work either because that was actually missing some targets that *were* needed. For example, it didn't include the action for writing the `.cpp.argsfile` for an exe target, whereas `all_actions()` did.
So now I'm back to being stuck again.
Ultimately, what I'm really interested in the following: For a given target literal, I want
1. All c_compile and cxx_compile actions.
2. All write actions that output argsfiles referenced by any action from 1.
Is this possible?
Separately, what is the reason for `all_actions()` seemingly including actions that don't execute when you `buck2 build` the same target? And why is `all_actions(T)` a superset of `filter(T, deps(T, 1))` instead of being identical?
Contributor guide
Assessment
This issue has not been assessed yet.