是否有一种机制可以根据平台或环境变量选择默认配置?例如:
common --config=$DEFAULT_CONFIG
我正在做一个使用 bazelrc
的项目配置为不同的平台指定默认构建和测试标志。它看起来像这样:
build:macos --compiler=clang
...
build:linux --compiler=gcc
...
build:windows --compiler=msvc
...
这对于多平台 CI 设置非常有用,通常可以避免输入 bazel <command> --config=<some config> <target>
。每次。
相关问题:Default, platform specific, Bazel flags in bazel.rc
最佳答案
现在有!如果你添加
common --enable_platform_specific_config
到您的 .bazelrc,然后 --config=windows
将自动应用于 windows 主机,--config=macos
在 mac 上, --config=linux
在 linux 等上
然后您可以将行添加到您的 .bazelrc 中,例如:
build:windows --windows-flags
build:linux --linux-flags
不过,也有一个缺点。这基于主机而不是目标。所以如果你正在交叉编译,例如到移动设备,并希望那里有不同的标志,您可以将您在宏中使用的所有库规则包装起来,或者(可能更好)将转换添加到您的图形目标中。 ( See discussion here 和 here 。“无标志构建”仍在开发中,但同时有可用的 hack。)您还可以使用临时 platform_mappings API。
引用资料: Commit that added this functionality. Where it appears in the Bazel docs.
https://stackoverflow.com/questions/48927073/
相关文章:
spring - @Transactional(read-only = true) 的目的是什么
python-3.x - 在 XGBoost 中应用增量学习进行分类设置时出错(python)
json - 如何在 vuejs 中将 JSON 对象发布到 Web 服务器?
macos - 有没有办法防止 OSX 用数千个 .DS_Store 文件污染我的项目?
javascript - 如何从提供 NET::ERR_CERT_AUTHORITY_INVALID
google-chrome-extension - 将 Google Chrome 扩展程序限制为选