找到Bazel输出文件?

发布于 2025-02-07 08:03:51 字数 435 浏览 3 评论 0原文

当我运行Bazel Build时,Bazel报告了目标的输出文件。我该如何编程查询?

在此示例中,我想获得bazel-out /...路径。

$ bazel build foo/bar:registration
INFO: Analyzed target //foo/bar:registration (546 packages loaded, 13485 targets configured).
INFO: Found 1 target...
Target //foo/bar:registration up-to-date:
  bazel-out/k8-fastbuild-ST-a82eca4c6b7c/bin/foo/bar/registration/registration_/registration

When I run bazel build, bazel reports the target's output file. How can I programmatically query this?

In this example, I want to get the bazel-out/... path.

$ bazel build foo/bar:registration
INFO: Analyzed target //foo/bar:registration (546 packages loaded, 13485 targets configured).
INFO: Found 1 target...
Target //foo/bar:registration up-to-date:
  bazel-out/k8-fastbuild-ST-a82eca4c6b7c/bin/foo/bar/registration/registration_/registration

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给不了的爱 2025-02-14 08:03:51

通过使用cquery命令的 starlark”> starlark输出模式。例如,要获得类似于构建发出的输出,请使用:

 $ bazel cquery --output starlark --starlark:expr '"\n".join([f.path for f in target.files.to_list()])' //foo/bar

将来cquery也可能有一个专用选项,可以处理简单的情况,而无需在命令行上涉及Starlark。

This can be accomplished with great flexibility by using the cquery command's Starlark output mode. For instance, to obtain output similar to that emitted by build, use:

 $ bazel cquery --output starlark --starlark:expr '"\n".join([f.path for f in target.files.to_list()])' //foo/bar

In the future, there may also be a dedicated option in cquery that handles the simple cases without the need to involve Starlark on the command line.

無處可尋 2025-02-14 08:03:51

更新:自Bazel 5.3以来,确实有一种较短的方法。

bazel cquery --output=files //your:target

Update: there's indeed a shorter way since Bazel 5.3.

bazel cquery --output=files //your:target
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文