【发布时间】:2021-11-30 15:00:25
【问题描述】:
编辑:下面的示例确实有效,我误解了编译器给我的输出。答案可能对某些人仍然有帮助。
是否有办法让规则中的操作生成一个文件,供同一规则中的后续操作使用?
例如:
def _example_rule_impl(ctx):
thefile = ctx.actions.declare_file("required_file.json")
ctx.actions.write(
output = thefile,
content = "CONTENT",
)
args = ctx.actions.args()
args.add("--config", thefile)
ctx.actions.run(
inputs = ctx.files.srcs + ctx.files.deps + [thefile],
outputs = outs,
arguments = [args],
progress_message = "Compiling...",
executable = ctx.executable._compiler,
)
这样做的主要问题似乎是,所有操作输出似乎都写入了 bazel-out,但运行操作需要将生成的文件写入 execroot 中的 srcs 和 deps 文件旁边才能正常工作.有没有办法将操作写入 execroot 或者这不是正确的方法?
【问题讨论】:
标签: bazel bazel-rules