[bazel] add tarball as an optional output (#1383)

Usage would be something like:
```
filegroup(
    name = "hello-world-tarball",
    srcs = [":hello-world-wasm"],
    output_group = "_wasm_tar",
)
```
This commit is contained in:
walkingeyerobot
2024-05-15 17:20:54 -04:00
committed by GitHub
parent d52c465201
commit 399e5396df

View File

@@ -128,12 +128,15 @@ def _wasm_cc_binary_impl(ctx):
executable = ctx.executable._wasm_binary_extractor,
)
return DefaultInfo(
files = depset(ctx.outputs.outputs),
# This is needed since rules like web_test usually have a data
# dependency on this target.
data_runfiles = ctx.runfiles(transitive_files = depset(ctx.outputs.outputs)),
)
return [
DefaultInfo(
files = depset(ctx.outputs.outputs),
# This is needed since rules like web_test usually have a data
# dependency on this target.
data_runfiles = ctx.runfiles(transitive_files = depset(ctx.outputs.outputs)),
),
OutputGroupInfo(_wasm_tar = cc_target.files),
]
def _wasm_cc_binary_legacy_impl(ctx):
cc_target = ctx.attr.cc_target[0]
@@ -162,13 +165,16 @@ def _wasm_cc_binary_legacy_impl(ctx):
executable = ctx.executable._wasm_binary_extractor,
)
return DefaultInfo(
executable = ctx.outputs.wasm,
files = depset(outputs),
# This is needed since rules like web_test usually have a data
# dependency on this target.
data_runfiles = ctx.runfiles(transitive_files = depset(outputs)),
)
return [
DefaultInfo(
executable = ctx.outputs.wasm,
files = depset(outputs),
# This is needed since rules like web_test usually have a data
# dependency on this target.
data_runfiles = ctx.runfiles(transitive_files = depset(outputs)),
),
OutputGroupInfo(_wasm_tar = cc_target.files),
]
_wasm_cc_binary = rule(
implementation = _wasm_cc_binary_impl,