20 lines
649 B
Python
20 lines
649 B
Python
def _echo_rule_impl(ctx):
|
|
# Attempt to read a file from the source tree without declaring it
|
|
# This will fail under the sandbox because undeclared inputs are not visible
|
|
input_path = ctx.attr.filename
|
|
out = ctx.actions.declare_file(ctx.label.name +".txt")
|
|
ctx.actions.run_shell(
|
|
inputs = [], # no inputs declared, this is the bug
|
|
outputs = [out],
|
|
command = "cat %s > %s" % (input_path, out.path),
|
|
progress_message = "illegally reading %s" % input_path,
|
|
)
|
|
|
|
return DefaultInfo(files = depset([out]))
|
|
|
|
echo_rule = rule(
|
|
implementation = _echo_rule_impl,
|
|
attrs = {
|
|
"filename": attr.string(mandatory = True),
|
|
},
|
|
)
|