从 CMake (ExternalProject_Add) 调用时,Bazel 在构建后不会退出
我正在尝试构建一个外部项目,该项目使用 Bazel 作为 CMake 和 Ninja 的构建系统。我正在使用 ExternalProject_Add
执行此操作,
ExternalProject_Add(bazel_proj
SOURCE_DIR "${bazel_proj_DIR}"
CONFIGURE_COMMAND :
CONFIGURE_HANDLED_BY_BUILD ON
BUILD_COMMAND bazel build //:install
INSTALL_COMMAND bazel run //:install
BUILD_IN_SOURCE ON
BUILD_ALWAYS ON
USES_TERMINAL_BUILD ON
USES_TERMINAL_INSTALL ON
LOG_BUILD ON
LOG_INSTALL ON
LOG_OUTPUT_ON_FAILURE ON
LOG_MERGED_STDOUTERR ON
INACTIVITY_TIMEOUT 10
)
我尝试将 --worker_quit_after_build
添加到构建命令,但没有帮助。 Bazel 默认使用 linux-sandbox 生成策略。
解决此问题的唯一方法是使用 CTRL+C 停止构建并重新开始,以便下次进入安装步骤!
我也无法让 CMake 将 Bazel 的进度报告打印到终端。这可能是相关的。
I am trying to build an external project that uses Bazel as its build system from CMake with Ninja. I am doing this by using ExternalProject_Add
ExternalProject_Add(bazel_proj
SOURCE_DIR "${bazel_proj_DIR}"
CONFIGURE_COMMAND :
CONFIGURE_HANDLED_BY_BUILD ON
BUILD_COMMAND bazel build //:install
INSTALL_COMMAND bazel run //:install
BUILD_IN_SOURCE ON
BUILD_ALWAYS ON
USES_TERMINAL_BUILD ON
USES_TERMINAL_INSTALL ON
LOG_BUILD ON
LOG_INSTALL ON
LOG_OUTPUT_ON_FAILURE ON
LOG_MERGED_STDOUTERR ON
INACTIVITY_TIMEOUT 10
)
I tried to add --worker_quit_after_build
to the build command but it did not help. Bazel uses the linux-sandbox spawn strategy by default.
The only way to work around this is to stop the build with CTRL+C and start over so it goes to the install step the next time!
I also could not make CMake print the progress report of Bazel to the terminal. That might be related.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

Bazel 有一个客户端/服务器模型,其中服务器保留用于后续增量构建。所以这可能是由于服务器仍在运行。尝试使用
--batch
启动标志,它告诉 bazel 不要使用此客户端/服务器模型:bazel --batch build //:install
https://bazel.build/docs/user-manual#batch
请注意,
bazel run // :install
还将启动服务器。您也可以在那里添加--batch
,但它可能会有点慢,因为 Bazel 会重新分析构建。您可以直接运行install
程序,该程序类似于bazel-bin/install
(取决于//:install
目标实际构建)。Bazel has a client/server model, where the server stays around for subsequent incremental builds. So this might be due to the server staying around. Try using the
--batch
startup flag, which tells bazel not to use this client/server model:bazel --batch build //:install
https://bazel.build/docs/user-manual#batch
Note that
bazel run //:install
will also start the server. You could add--batch
there as well, but it will probably be a bit slow because Bazel will reanalyze the build. You could possibly instead run theinstall
program directly, which will be something likebazel-bin/install
(depends on what the//:install
target actually builds).