默认,特定于平台的bazel.rc中的Bazel标志 [英] Default, platform specific, Bazel flags in bazel.rc

查看:236
本文介绍了默认,特定于平台的bazel.rc中的Bazel标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道特定于平台的默认Bazel构建标记是否可行.

I was wondering if its possible for platform-specific default Bazel build flags.

例如,我们要使用--workspace_status_command,但这必须是Linux上的shell脚本,并且必须指向Windows的批处理脚本.

For example, we want to use --workspace_status_command but this must be a shell script on Linux and must point towards a batch script for Windows.

有没有一种方法可以在tools/bazel.rc文件中写类似...

Is there a way we can write in the tools/bazel.rc file something like...

if platform=WINDOWS build: --workspace_status_command=status_command.bat
if platform=LINUX build: --workspace_status_command=status_command.sh

我们可以通过让用户在构建之前运行脚本来生成.bazelrc文件,但是如果不需要的话,它将更干净/更简洁.

We could generate a .bazelrc file by having the users run a script before building, but it would be cleaner/nicer if this was not neccessary.

推荐答案

是的.您可以指定特定于配置的bazelrc条目,可以通过传递--config=<configname>来选择这些条目.

Yes, kind of. You can specify config-specific bazelrc entries, which you can select by passing --config=<configname>.

例如,您的bazelrc可能如下所示:

For example your bazelrc could look like:

build:linux --cpu=k8
build:linux --workspace_status_command=/path/to/command.sh
build:windows --cpu=x64_windows
build:windows --workspace_status_command=c:/path/to/command.bat

您将像这样构建:

bazel build --config=linux //path/to:target

或:

bazel build --config=windows //path/to:target

您必须注意不要混淆语义上冲突的--config标志(Bazel不会阻止您这样做).尽管可以使用,但是当配置使用相同的标志进行修改时,结果可能无法预测.

You have to be careful not to mix semantically conflicting --config flags (Bazel doesn't prevent you from that). Though it will work, the results may be unpredictable when the configs tinker with the same flags.

这篇关于默认,特定于平台的bazel.rc中的Bazel标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆