我有规则a
:
def _a_impl(ctx):
src = ctx.actions.declare_file("src.txt")
ctx.actions.write(src, "nothin")
dst = ctx.actions.declare_file("dst.txt")
ctx.actions.run_shell(
outputs = [dst],
inputs = [src],
command = "cp",
arguments = [src.path, dst.path]
)
return [DefaultInfo(files = depset([dst]))]
a = rule(
implementation = _a_impl,
)
出于某种原因,我收到以下错误:
ERROR: /home/erran/example/out_dir/BUILD:9:1: error executing shell command: '/bin/bash -c cp bazel-out/k8-fastbuild/bin/src.txt bazel-out/k8-fastbuild/bin/dst.txt' failed (Exit 1) bash failed: error executing command /bin/bash -c cp '' bazel-out/k8-fastbuild/bin/src.txt bazel-out/k8-fastbuild/bin/dst.txt
看起来 Bazel 没有正确解析参数。如您所见,实际的 bash 命令试图cp '' <src> <dst>
我也尝试过格式化复制命令本身,效果很好:
ctx.actions.run_shell(
outputs = [dst],
inputs = [src],
command = "cp {} {}".format(src.path, dst.path)
)
有谁知道问题是什么?