-
Notifications
You must be signed in to change notification settings - Fork 511
Open
Description
@kolloch's bazel_env example is great. I tried to use it to use the Bazel-managed rust toolchain for non-Bazel-aware tools that invoke rustc, including a tool that directly invokes rustup
and one that runs cargo
. It would a big project to port those outside tools to Bazel, but it would still be a nice little win to consolidate on one Rust toolchain, which would avoid issues of syncing rustup
and rust-toolchain.toml
with the rules_rust
configuration.
My wishlist feature request is to somehow support cross-compilation from @rules_rust//tools/upstream_wrapper:rustc
, with theextra_target_triples
in rust.toolchain
taking the place of rustup target add
.
In other words:
# MODULE.bazel
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
extra_target_triples = [
"aarch64-unknown-linux-gnu",
"wasm32-unknown-unknown",
"x86_64-unknown-linux-gnu",
],
)
# .../BUILD.bazel
bazel_env(
name = "bazel_env",
# TODO: Upgrade when on Bazel 9+
# toolchains = {
# "rust": "@rules_rust//rust/toolchain:current_rust_toolchain",
# },
tools = {
# TODO: Uncomment when on Bazel 9+
# "cargo": "$(CARGO)",
# "rustfmt": "$(RUSTFMT)",
# "rustc": "$(RUSTC)",
# "rustdoc": "$(RUSTDOC)",
"cargo": "@rules_rust//tools/upstream_wrapper:cargo",
"cargo-clippy": "@rules_rust//tools/upstream_wrapper:cargo_clippy",
"rustc": "@rules_rust//tools/upstream_wrapper:rustc",
"rustfmt": "@rules_rust//tools/upstream_wrapper:rustfmt",
},
...
Then:
wasm-pack build ...
Metadata
Metadata
Assignees
Labels
No labels