99 */
1010
1111use allocative:: Allocative ;
12+ use buck2_artifact:: actions:: key:: ActionKey ;
1213use buck2_build_api:: actions:: query:: ActionQueryNode ;
1314use buck2_build_api:: query:: bxl:: BxlAqueryFunctions ;
1415use buck2_build_api:: query:: bxl:: NEW_BXL_AQUERY_FUNCTIONS ;
@@ -46,6 +47,7 @@ use starlark::values::type_repr::StarlarkTypeRepr;
4647
4748use crate :: bxl:: starlark_defs:: context:: BxlContext ;
4849use crate :: bxl:: starlark_defs:: context:: ErrorPrinter ;
50+ use crate :: bxl:: starlark_defs:: nodes:: action:: StarlarkAction ;
4951use crate :: bxl:: starlark_defs:: nodes:: action:: StarlarkActionQueryNode ;
5052use crate :: bxl:: starlark_defs:: providers_expr:: AnyProvidersExprArg ;
5153use crate :: bxl:: starlark_defs:: providers_expr:: ProvidersExpr ;
@@ -123,6 +125,7 @@ enum UnpackActionNodes<'v> {
123125 ActionQueryNodesSet ( & ' v StarlarkTargetSet < ActionQueryNode > ) ,
124126 ConfiguredProviders ( AnyProvidersExprArg < ' v > ) ,
125127 ConfiguredTargets ( ConfiguredTargetListExprArg < ' v > ) ,
128+ StarlarkActions ( UnpackList < StarlarkAction > ) ,
126129}
127130
128131// Aquery operates on `ActionQueryNode`s. Under the hood, the target set of action query nodes is obtained
@@ -141,6 +144,14 @@ async fn unpack_action_nodes<'v>(
141144 return Ok ( action_nodes. into_iter ( ) . map ( |v| v. 0 ) . collect ( ) ) ;
142145 }
143146 UnpackActionNodes :: ActionQueryNodesSet ( action_nodes) => return Ok ( action_nodes. 0 . clone ( ) ) ,
147+ UnpackActionNodes :: StarlarkActions ( actions) => {
148+ let action_keys: Vec < ActionKey > = actions
149+ . into_iter ( )
150+ . map ( |starlark_action| starlark_action. 0 . key ( ) . dupe ( ) )
151+ . collect ( ) ;
152+
153+ return aquery_env. get_action_nodes ( dice, action_keys) . await ;
154+ }
144155 UnpackActionNodes :: ConfiguredProviders ( arg) => {
145156 ProvidersExpr :: < ConfiguredProvidersLabel > :: unpack (
146157 arg,
@@ -183,6 +194,11 @@ async fn unpack_action_nodes<'v>(
183194///
184195/// Query results are `target_set`s of `action_query_node`s, which supports iteration,
185196/// indexing, `len()`, set addition/subtraction, and `equals()`.
197+ ///
198+ /// Actions can be specified as:
199+ /// - Target expressions (configured targets/providers)
200+ /// - Existing action query nodes or target sets
201+ /// - `bxl.Action` objects (obtained from `ctx.audit().output()`)
186202#[ starlark_module]
187203fn aquery_methods ( builder : & mut MethodsBuilder ) {
188204 /// The deps query for finding the transitive closure of dependencies.
0 commit comments