我无法加载@bazel_tool
I am unable to load @bazel_tool
我正在尝试使用 bazel 编译一些损坏的、依赖于平台的 C# 代码,但我在定义平台时遇到了很多问题。
我定义了两个平台:
platform (
name = "darwin",
constraint_values = [
"@bazel_tools//platform:osx",
],
)
platform (
name = "windows",
constraint_values = [
"@bazel_tools//platform:windows",
],
)
然后我在 BUILD
文件的其他地方的 genrule
中的 select 中使用它:
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
是内置的,所以这对我来说是一个惊喜——对我来说 "builtin",意味着 "you don't have to do anything for this to be available to you"。我也找不到任何可以解决问题的方法。
我相信目录是 platforms":
@bazel_tools//platforms:osx"
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"
]
)
我正在尝试使用 bazel 编译一些损坏的、依赖于平台的 C# 代码,但我在定义平台时遇到了很多问题。
我定义了两个平台:
platform (
name = "darwin",
constraint_values = [
"@bazel_tools//platform:osx",
],
)
platform (
name = "windows",
constraint_values = [
"@bazel_tools//platform:windows",
],
)
然后我在 BUILD
文件的其他地方的 genrule
中的 select 中使用它:
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
是内置的,所以这对我来说是一个惊喜——对我来说 "builtin",意味着 "you don't have to do anything for this to be available to you"。我也找不到任何可以解决问题的方法。
我相信目录是 platforms":
@bazel_tools//platforms:osx"
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"
]
)