我正在尝试使用bazel来编译一些破坏的,依赖于平台的C#代码,并且我在定义平台时遇到了很多问题。
我已经定义了两个平台:
platform (
name = "darwin",
constraint_values = [
"@bazel_tools//platform:osx",
],
)
platform (
name = "windows",
constraint_values = [
"@bazel_tools//platform:windows",
],
)
然后我在genrule
文件中的其他地方的BUILD
中选择使用
cmd = select ({
":darwin" : "a bash command",
":windows" : "a long and complex windows command because windows is stupid and makes everything much much more complex than it has to be"
})
但是,当我尝试构建某些内容时,我会遇到错误
no such package '@bazel_tools//platform': BUILD file not found on package path and referenced by //<package>:darwin
我认为这意味着@bazel_tools
不可用。
documentation声称@bazel_tools
已内置,所以这对我来说是一个惊喜 - 对我而言“内置”,意味着“你无需为此做任何事情给你”。我无法找到任何可以解决问题的方法。
答案 0 :(得分:3)
我相信目录是平台&#34;:
@bazel_tools//platforms:osx"
答案 1 :(得分:1)
platform
规则未定义可在select()中使用的配置设置。您应该使用config_setting
这对我有用:
config_setting(
name = "darwin",
constraint_values = [
"@bazel_tools//platforms:osx",
"@bazel_tools//platforms:x86_64"
]
)
config_setting(
name = "linux_x86",
constraint_values = [
"@bazel_tools//platforms:linux",
"@bazel_tools//platforms:x86_64"
]
)