nixpkgs/pkgs/by-name/en/envoy/bazel_nix.BUILD.bazel
Luke Granger-Brown cb5946cd93 envoy: fix up Rust
Envoy 1.32 has added some more dependencies on rules_rust bits, so we
need to support that now.

In particular, for some reason, we always fail with a message about
needing repinning, so we repin during the IFD phase, but we need to
point rules_rust at the nixpkgs Rust toolchain, make it build the
cargo-bazel tool (because the one in nixpkgs is the wrong version), and
then clean up afterwards.
2024-10-19 22:48:12 +01:00

55 lines
1.3 KiB
Plaintext

load("@bazel_tools//tools/sh:sh_toolchain.bzl", "sh_toolchain")
load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
toolchains = {
"x86_64": "x86_64-unknown-linux-gnu",
"aarch64": "aarch64-unknown-linux-gnu",
}
exports_files(["cargo", "rustdoc", "ruststd", "rustc"])
[
rust_toolchain(
name = "rust_nix_" + k + "_impl",
binary_ext = "",
dylib_ext = ".so",
exec_triple = v,
cargo = ":cargo",
rust_doc = ":rustdoc",
rust_std = ":ruststd",
rustc = ":rustc",
stdlib_linkflags = ["-ldl", "-lpthread"],
staticlib_ext = ".a",
target_triple = v,
)
for k, v in toolchains.items()
]
[
toolchain(
name = "rust_nix_" + k,
exec_compatible_with = [
"@platforms//cpu:" + k,
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:" + k,
"@platforms//os:linux",
],
toolchain = ":rust_nix_" + k + "_impl",
toolchain_type = "@rules_rust//rust:toolchain_type",
)
for k in toolchains.keys()
]
sh_toolchain(
name = "local_sh_impl",
path = "@bash@",
)
toolchain(
name = "local_sh",
toolchain = ":local_sh_impl",
toolchain_type = "@bazel_tools//tools/sh:toolchain_type",
)