[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",
)
```diff --git a/bazel/emscripten_toolchain/wasm_cc_binary.bzl b/bazel/emscripten_toolchain/wasm_cc_binary.bzl
index fe77e17..23749ed 100644
--- a/bazel/emscripten_toolchain/wasm_cc_binary.bzl
+++ b/bazel/emscripten_toolchain/wasm_cc_binary.bzl
@@ -128,12 +128,15 @@
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 @@
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,