Skip to content

Commit

Permalink
feat: add extra_rustc_flags_triples (#2999)
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-ball authored Nov 14, 2024
1 parent d383a1a commit 6a66388
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 6a66388

Please sign in to comment.