From f3724b377e128ecd8b278cffcadcc75710bb898e Mon Sep 17 00:00:00 2001 From: Wendy Yu Date: Thu, 5 Oct 2023 06:09:55 -0700 Subject: [PATCH] [antlir sendstream][anon targets] Migrate to new API (attempt 2) Summary: Missed `with_artifacts` the first time. Test Plan: ``` [wendyy@devvm11782]/data/users/wendyy/fbsource/fbcode/buck2% buck2 build fbcode//antlir/antlir2/test_images/package:btrfs-test-3.sendstream fbcode// antlir/antlir2/test_images/package:btrfs-test-3.sendstream.v2 fbcode//antlir/antlir2/test_images/package:btrfs-test-3.sendstream.zst Downloading buck2... [======================================================================] Watchman fresh instance: new mergebase, cleared graph state, cleared dep files Buck UI: https://www.internalfb.com/buck2/22e5b7b6-cc15-44a6-ac4d-c9ec9f4e946e Note: Using experimental modern dice Network: Up: 1.6MiB Down: 327MiB (reSessionID-87ed82ac-64ac-4763-91ad-4fc288f8f4e2) Jobs completed: 147526. Time elapsed: 30.4s. Cache hits: 98%. Commands: 695 (cached: 683, remote: 0, local: 12) BUILD SUCCEEDED ``` Reviewed By: vmagro Differential Revision: D49914076 fbshipit-source-id: 9bcbf9595cc3c28f14564dfd2bd3a1c1b117174d --- antlir/antlir2/bzl/package/sendstream.bzl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/antlir/antlir2/bzl/package/sendstream.bzl b/antlir/antlir2/bzl/package/sendstream.bzl index e76e8701ce..e6abb5ecb6 100644 --- a/antlir/antlir2/bzl/package/sendstream.bzl +++ b/antlir/antlir2/bzl/package/sendstream.bzl @@ -34,7 +34,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]: ) return [DefaultInfo(sendstream), SendstreamInfo(sendstream = sendstream)] -_sendstream = rule( +_sendstream = anon_rule( impl = _impl, attrs = { "antlir2_packager": attrs.default_only(attrs.exec_dep(default = "//antlir/antlir2/antlir2_packager:antlir2-packager")), @@ -42,6 +42,9 @@ _sendstream = rule( "layer": attrs.dep(providers = [LayerInfo]), "volume_name": attrs.string(default = "volume"), }, + artifact_promise_mappings = { + "anon_v1_sendstream": lambda x: x[SendstreamInfo].sendstream, + }, ) sendstream = rule_with_default_target_platform(_sendstream) @@ -53,16 +56,13 @@ def anon_v1_sendstream( volume_name: str = "volume", build_appliance: Dependency | None = None, antlir2_packager: Dependency | None = None) -> Artifact: - v1_anon_target = ctx.actions.anon_target(_sendstream, { + return ctx.actions.anon_target(_sendstream, { "antlir2_packager": antlir2_packager or ctx.attrs.antlir2_packager, "build_appliance": build_appliance or ctx.attrs.build_appliance, "layer": layer, "name": str(layer.label.raw_target()) + ".sendstream", "volume_name": volume_name, - }) - return ctx.actions.artifact_promise( - v1_anon_target.map(lambda x: x[SendstreamInfo].sendstream), - ) + }, with_artifacts = True).artifact("anon_v1_sendstream") def _zst_impl(ctx: AnalysisContext) -> list[Provider]: sendstream_zst = ctx.actions.declare_output("image.sendstream.zst")