Closed zjturner closed 9 months ago
There are 2 problems here:
ctx.configured_targets()
is being passed with its configuration into eval()
, but it's not actually:query_string = "attrfilter(identifier, .cpp.argsfile, all_actions({}))".format(target.label.raw_target())
You're using raw_target()
, which means you're stripping the node of the configuration. This is not to say that you're able to pass in the configured version into query_string
, though. This brings me to my next point.
aquery.eval()
, you should either set the global target platform via --target-platform
on the buck2 command, or pass in the target platform into aquery()
instantiation directly (aquery = ctx.aquery(target_platform = "foo//bar:baz")
. eval()
is a special query which operates on strings rather than structured Starlark types, and strings do not support any kind of configuration. This tidbit probably should be explicitly said in the docs, so I will add this soon. deps()
works because it actually accepts structured Starlark types such as configured nodes, and will respect this configuration in computations.Thanks, the fact that I can pass a platform to aquery() is the piece I missed!
Assume the default platform is called P but there is another platform defined with the name Q.
If you run this as
buck2 bxl :foo.bxl:foo -- platform=Q
you will get the following output:I found that if I use a different queryfunction like deps(), then the target platform is respected.