【发布时间】:2025-12-08 15:55:02
【问题描述】:
在 Bazel 中,是否有一种等效的方法来运行如下所述的二进制可执行文件,但在 repository_rule 实现函数中使用 repository_ctx?
# def _impl
ctx.actions.run(
...
executable = ctx.executable.foo_binary,
)
# Is doing the ff also possible for a repository_rule?
bar = rule(
implementation = _impl,
attrs = {
"foo_binary": attr.label(
default = Label("//actions_run:foo"),
executable = True,
cfg = "exec",
allow_files = True,
),
},
)
repository_ctx 的文档表明有一个 execute() 函数,但我不确定如何使用它运行另一个 bazel 构建的二进制文件。任何示例都会有所帮助。
PS:我是 Bazel 的新手。如果这不是 repository_ctx.execute 的用途,请重定向。
【问题讨论】:
标签: bazel bazel-rules