How can I use aquery in bxl to get all actions for all targets?
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to iterate over all configured targets, then enumerate each of their actions. aquery requires a target literal, so I can't seem to just do `aquery(...)`. So I tried to enumerate all `configured_targets`, and then pass each one to aquery. First I ran into the problem that `aquery` seems to want an unconfigured target label.
```
for target in ctx.configured_targets('...'):
aquery_result = ctx.aquery(target.label)
> error: Type of parameter `target_platform` doesn't match, expected `None | str | target_label`, actual `configured_target_label`
```
So I changed that to `target.label.raw_target()`.
That worked and gave me something that I could call the function `all_actions()` on, but it seems that function requires me to pass in another target. Which I'm confused about, since I had to pass in a target to `ctx.aquery` in the first place. Example:
```
for target in ctx.configured_targets('...'):
aquery_result = ctx.aquery(target.label.raw_target())
all_actions = aquery_result.all_actions()
> error: Missing parameter `targets` for call to all_actions
```
Not entirely sure what I'm supposed to do at this point, so I tried to pass in the configured target label again, but then it always returns an empty list of actions, even when it's clear the target does have actions on it.
I tried to follow this documentation here (https://buck2.build/docs/rfcs/bxl/#actions) which has the following example:
```
targets = deps(“foo:rule”)
for t in targets:
action_ctx = ctx.analysis(t).actions
for action in action_ctx.iter():
if “foo/path” in action.output:
ctx.build(action)
```
by modifying it to the following, which gives me a different error
```
for t in ctx.configured_targets("..."):
action_ctx = ctx.analysis(t).actions
> error: Object of type `analysis_result` has no attribute `actions`
```
Any advice about how to proceed?
Contributor guide
Assessment
This issue has not been assessed yet.