Thanks for the followup. I kept digging and did not find a solutions but came up with the following.
def _local_deploy_impl(ctx):
target = ctx.attr.target
shell_commands = ""
for s in ctx.files.srcs:
shell_commands += "sudo cp %s %s\n" % (s.short_path, target) # <2>
ctx.actions.write(
output = ctx.outputs.executable,
is_executable = True,
content = shell_commands,
)
runfiles = ctx.runfiles(files = ctx.files.srcs)
return DefaultInfo(
executable = ctx.outputs.executable,
runfiles = runfiles,
)
local_deploy = rule(
executable = True,
implementation = _local_deploy_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"target": attr.string(default = "/usr/local/bin", doc = "Deployment target directory"),
},
)
Including in a build file:
local_deploy(
name = "install",
srcs = [":binary"],
)
srcs references the binary outputs of another rule that will be installed locally.
Any suggestions to improve?