'How do I `select` over execution target?
I have the following rule but it isn't working because the select is evaluating target platform instead of host platform or execution platform.
Does anyone know how to make it work?
cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
build_script_env = select({
"@bazel_tools//src/conditions:linux_aarch64": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_linux_aarch64//:protoc)",
"RUSTFMT": "$(execpath @rust_linux_aarch64//:rustfmt_bin)",
},
"@bazel_tools//src/conditions:linux_x86_64": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_linux_x86_64//:protoc)",
"RUSTFMT": "$(execpath @rust_linux_x86_64//:rustfmt_bin)",
},
"@bazel_tools//src/conditions:darwin_arm64": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_macos_aarch64//:protoc)",
"RUSTFMT": "$(execpath @rust_darwin_aarch64//:rustfmt_bin)",
},
"@bazel_tools//src/conditions:darwin_x86_64": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_macos_x86_64//:protoc)",
"RUSTFMT": "$(execpath @rust_darwin_x86_64//:rustfmt_bin)",
},
}),
crate_features = [
"transport",
],
data = [
"//api/protos:protos",
"@com_google_protobuf//:protoc",
"@com_google_protobuf//:well_known_protos",
] + select({
"@bazel_tools//src/conditions:linux_aarch64": [
"@rust_linux_aarch64//:rustfmt_bin",
"@com_google_protobuf_protoc_linux_aarch64//:protoc",
],
"@bazel_tools//src/conditions:linux_x86_64": [
"@rust_linux_x86_64//:rustfmt_bin",
"@com_google_protobuf_protoc_linux_x86_64//:protoc",
],
"@bazel_tools//src/conditions:darwin_arm64": [
"@rust_darwin_aarch64//:rustfmt_bin",
"@com_google_protobuf_protoc_macos_aarch64//:protoc",
],
"@bazel_tools//src/conditions:darwin_x86_64": [
"@rust_darwin_x86_64//:rustfmt_bin",
"@com_google_protobuf_protoc_macos_x86_64//:protoc",
],
}),
deps = [
"@raze__tonic_build__0_6_2//:tonic_build",
],
)
I know there is an exex_compatible_with option for each rule but this doesn't help. I would have to create one rule per execution platform but then select again each rule given the platform.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
