def _impl(ctx):
args= ctx.actions.args()
args.add(ctx.attr.device_type)
........
ctx.actions.run(
inputs = [ctx.file.srcs],
arguments = [args],
outputs = [ctx.outputs.text],
executable = ctx.executable.runner)
flash_tool = rule(
implementation = _impl,
attrs = {
"runner": attr.label(
executable = True,
cfg = "host",
default=Label("//tools/flash")),
"device_type":attr.string(mandatory = True),
"srcs":attr.label(mandatory = True, allow_single_file = True,),
},
outputs = {
"text": "%{name}.txt"},
)