Skip to content

Commit

Permalink
[antlir sendstream][anon targets] Migrate to new API (attempt 2)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wendy728 authored and facebook-github-bot committed Oct 5, 2023
1 parent 6bf71a9 commit f3724b3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions antlir/antlir2/bzl/package/sendstream.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ 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")),
"build_appliance": attrs.option(attrs.dep(providers = [LayerInfo]), default = None),
"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)
Expand All @@ -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")
Expand Down

0 comments on commit f3724b3

Please sign in to comment.