Bazel:如果配置设置为真,如何排除某些目标
假设我在不同的文件夹中有 3 个库:
a_library(
name = "a",
)
b_library(
name = "b",
)
c_library(
name = "c",
)
我想使用 bazel build ... 来构建所有库,而 bazel build ... -c dbg 仅构建>a_library 和 b_library
。我想知道我应该改变什么?
我尝试过的:
我还尝试修改我的 .bazelrc
文件以将标签添加到 c_library
。例如: build --build_tag_filters="disable_for_dbg"
,但我不确定如何让它仅在我通过 -c dbg
时运行
感谢任何帮助,谢谢!
Let's say I have 3 libraries in different folders:
a_library(
name = "a",
)
b_library(
name = "b",
)
c_library(
name = "c",
)
I want to bazel build ...
to build all libraries, while bazel build ... -c dbg
only builds a_library
and b_library
. I'm wondering what I should change?
What i've tried:
I tried following https://bazel.build/docs/configurable-attributes, where I made a config setting for dbg
and selected tag=['default']
when you passed in -c dbg
, but apparently tags aren't configurable.
I've also tried modifying my .bazelrc
file to add a tag to c_library
. Eg: build --build_tag_filters="disable_for_dbg"
, but I'm not sure how to get this to only run when I pass -c dbg
Any help is appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不兼容的目标跳过是此类的功能。它将将库排除在通配符之外,任何(传统)取决于它们的任何东西。如果您在命令行(
bazel build -c dbg c
)上明确列出了其中一个,则会遇到一个错误。像这样:@platforms //:Inmbatible
不是任何平台的一部分,因此任何具有targe> target_compatible_with
包含在内的目标将始终跳过。target_compatible_with
是可配置的,因此您可以通过select有条件地添加该平台约束。
Incompatible target skipping is the feature for this. It'll exclude the libraries from wildcards, and anything which (transitively) depends on them. If you explicitly list one of them on the command line (
bazel build -c dbg c
), you'll get an error. Like this:@platforms//:incompatible
is not part of any platform, so any target withtarget_compatible_with
that includes it will always be skipped.target_compatible_with
is configurable, so you can add that platform constraint conditionally viaselect.