@@ -12,9 +12,11 @@ use std::convert::Infallible;
1212use std:: sync:: Arc ;
1313
1414use allocative:: Allocative ;
15+ use buck2_artifact:: artifact:: artifact_type:: Artifact ;
1516use buck2_build_api:: actions:: RegisteredAction ;
1617use buck2_build_api:: actions:: query:: ActionQueryNode ;
1718use buck2_build_api:: actions:: query:: OwnedActionAttr ;
19+ use buck2_build_api:: interpreter:: rule_defs:: artifact:: starlark_artifact:: StarlarkArtifact ;
1820use buck2_core:: deferred:: base_deferred_key:: BaseDeferredKey ;
1921use buck2_error:: buck2_error;
2022use buck2_interpreter:: types:: target_label:: StarlarkConfiguredTargetLabel ;
@@ -49,7 +51,7 @@ pub(crate) struct StarlarkAction(pub(crate) Arc<RegisteredAction>);
4951
5052starlark_simple_value ! ( StarlarkAction ) ;
5153
52- #[ starlark_value( type = "action " ) ]
54+ #[ starlark_value( type = "bxl.Action " ) ]
5355impl < ' v > StarlarkValue < ' v > for StarlarkAction {
5456 fn get_methods ( ) -> Option < & ' static Methods > {
5557 static RES : MethodsStatic = MethodsStatic :: new ( ) ;
@@ -67,7 +69,7 @@ impl<'a> UnpackValue<'a> for StarlarkAction {
6769 }
6870}
6971
70- /// Methods for an action.
72+ /// Methods for an action obtained from [`bxl.AuditContext.output()`](../AuditContext#output) .
7173#[ starlark_module]
7274fn action_methods ( builder : & mut MethodsBuilder ) {
7375 /// Gets the owning configured target label for an action.
@@ -90,6 +92,17 @@ fn action_methods(builder: &mut MethodsBuilder) {
9092 . into ( ) ) ,
9193 }
9294 }
95+
96+ /// Gets the artifacts built by this action.
97+ fn outputs < ' v > ( this : StarlarkAction ) -> starlark:: Result < Vec < StarlarkArtifact > > {
98+ Ok ( this
99+ . 0
100+ . action ( )
101+ . outputs ( )
102+ . iter ( )
103+ . map ( |a| StarlarkArtifact :: new ( Artifact :: from ( a. clone ( ) ) ) )
104+ . collect ( ) )
105+ }
93106}
94107
95108#[ derive( Debug , Display , ProvidesStaticType , Allocative ) ]
0 commit comments