Created
April 3, 2017 13:50
-
-
Save kchodorow/9555479d416087e4e867440e0f4c582d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("//:fun-with-outputs.bzl", "my_rule") | |
my_rule( | |
name = "foo", | |
many_results = [ | |
"212", | |
"917", | |
"646", | |
], | |
one_result = "brooklyn", | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bazel build :foo | |
INFO: Found 1 target... | |
>>>>> # //:foo [action 'Generating 212'] | |
(cd home/kchodorow/.cache/bazel/_bazel_kchodorow/f454bcbe3fb58b7971b0951d116298e9/execroot/class-workspace && \ | |
exec env - \ | |
/bin/bash -c 'touch bazel-out/local-fastbuild/bin/212 bazel-out/local-fastbuild/bin/917 bazel-out/local-fastbuild/bin/646') | |
Target //:foo up-to-date: | |
bazel-bin/brooklyn | |
bazel-bin/212 | |
bazel-bin/917 | |
bazel-bin/646 | |
INFO: Elapsed time: 1.744s, Critical Path: 0.09s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _impl(ctx): | |
ctx.file_action( | |
output = ctx.outputs.one_result, | |
content = "I'm bespoke.", | |
) | |
ctx.action( | |
outputs = ctx.outputs.many_results, | |
command = "touch %s" % " ".join([p.path for p in ctx.outputs.many_results]), | |
) | |
my_rule = rule( | |
implementation = _impl, | |
attrs = { | |
'one_result' : attr.output(), | |
'many_results' : attr.output_list(), | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment