Skip to content

Instantly share code, notes, and snippets.

@kchodorow
Created March 31, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kchodorow/01b8b9eebb757a43e18e113461102499 to your computer and use it in GitHub Desktop.
Save kchodorow/01b8b9eebb757a43e18e113461102499 to your computer and use it in GitHub Desktop.
Skylark rule with output
load("//:output.bzl", "my_rule")
my_rule(name = "foo")
INFO: Found 1 target...
>>>>> # //:foo [action 'Generating b']
(cd /home/kchodorow/.cache/bazel/_bazel_kchodorow/f454bcbe3fb58b7971b0951d116298e9/execroot/class-workspace && \
exec env - \
/bin/bash -c 'touch a; touch bazel-out/local-fastbuild/bin/b')
Target //:foo up-to-date:
bazel-bin/b
INFO: Elapsed time: 9.406s, Critical Path: 9.16s
def _rule_impl(ctx):
ctx.action(
outputs = [ctx.outputs.b],
command = "touch a; touch %s" % ctx.outputs.b.path)
my_rule = rule(
implementation = _rule_impl,
outputs = {'b' : 'b'}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment