Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rust/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ def _rust_impl(module_ctx):
toolchains = root.tags.toolchain or rules_rust.tags.toolchain

for toolchain in toolchains:
if toolchain.extra_rustc_flags and toolchain.extra_rustc_flags_triples:
fail("Cannot define both extra_rustc_flags and extra_rustc_flags_triples")
if len(toolchain.versions) == 0:
# If the root module has asked for rules_rust to not register default
# toolchains, an empty repository named `rust_toolchains` is created
# so that the `register_toolchains()` in MODULES.bazel is still
# valid.
_empty_repository(name = "rust_toolchains")
else:
extra_rustc_flags = toolchain.extra_rustc_flags if toolchain.extra_rustc_flags else toolchain.extra_rustc_flags_triples

rust_register_toolchains(
dev_components = toolchain.dev_components,
edition = toolchain.edition,
extra_rustc_flags = toolchain.extra_rustc_flags,
extra_rustc_flags = extra_rustc_flags,
extra_exec_rustc_flags = toolchain.extra_exec_rustc_flags,
allocator_library = toolchain.allocator_library,
rustfmt_version = toolchain.rustfmt_version,
Expand Down Expand Up @@ -117,6 +121,9 @@ _RUST_TOOLCHAIN_TAG = tag_class(
extra_rustc_flags = attr.string_list(
doc = "Extra flags to pass to rustc in non-exec configuration",
),
extra_rustc_flags_triples = attr.string_list_dict(
doc = "Extra flags to pass to rustc in non-exec configuration. Key is the triple, value is the flag.",
),
rust_analyzer_version = attr.string(
doc = "The version of Rustc to pair with rust-analyzer.",
),
Expand Down