Skip to content

Commit 6a66388

Browse files
authored
feat: add extra_rustc_flags_triples (#2999)
Currently, this attribute can be either a dict or a list: https://github.com/bazelbuild/rules_rust/blob/d383a1aef9865e59172af6c63f29c96fed19b04a/rust/repositories.bzl#L152 Resolved here: https://github.com/bazelbuild/rules_rust/blob/d383a1aef9865e59172af6c63f29c96fed19b04a/rust/repositories.bzl#L1047 This adds `bzlmod` parity to that feature.
1 parent d383a1a commit 6a66388

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rust/extensions.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,21 @@ def _rust_impl(module_ctx):
5151
toolchains = root.tags.toolchain or rules_rust.tags.toolchain
5252

5353
for toolchain in toolchains:
54+
if toolchain.extra_rustc_flags and toolchain.extra_rustc_flags_triples:
55+
fail("Cannot define both extra_rustc_flags and extra_rustc_flags_triples")
5456
if len(toolchain.versions) == 0:
5557
# If the root module has asked for rules_rust to not register default
5658
# toolchains, an empty repository named `rust_toolchains` is created
5759
# so that the `register_toolchains()` in MODULES.bazel is still
5860
# valid.
5961
_empty_repository(name = "rust_toolchains")
6062
else:
63+
extra_rustc_flags = toolchain.extra_rustc_flags if toolchain.extra_rustc_flags else toolchain.extra_rustc_flags_triples
64+
6165
rust_register_toolchains(
6266
dev_components = toolchain.dev_components,
6367
edition = toolchain.edition,
64-
extra_rustc_flags = toolchain.extra_rustc_flags,
68+
extra_rustc_flags = extra_rustc_flags,
6569
extra_exec_rustc_flags = toolchain.extra_exec_rustc_flags,
6670
allocator_library = toolchain.allocator_library,
6771
rustfmt_version = toolchain.rustfmt_version,
@@ -117,6 +121,9 @@ _RUST_TOOLCHAIN_TAG = tag_class(
117121
extra_rustc_flags = attr.string_list(
118122
doc = "Extra flags to pass to rustc in non-exec configuration",
119123
),
124+
extra_rustc_flags_triples = attr.string_list_dict(
125+
doc = "Extra flags to pass to rustc in non-exec configuration. Key is the triple, value is the flag.",
126+
),
120127
rust_analyzer_version = attr.string(
121128
doc = "The version of Rustc to pair with rust-analyzer.",
122129
),

0 commit comments

Comments
 (0)