Skip to content

Commit 1181c97

Browse files
committed
rust: kbuild: simplify --cfg handling
We need to handle `cfg`s in both `rustc` and `rust-analyzer`, and in future commits some of those contain double quotes, which complicates things further. Thus, instead of removing the `--cfg ` part in the rust-analyzer generation script, have the `*-cfgs` variables contain just the actual `cfg`, and use that to generate the actual flags in `*-flags`. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Tested-by: Gary Guo <gary@garyguo.net> Tested-by: Jesung Yang <y.j3ms.n@gmail.com> Link: https://patch.msgid.link/20251124151837.2184382-3-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 46e58a9 commit 1181c97

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

rust/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ rustdoc_test_quiet=--test-args -q
6060
rustdoc_test_kernel_quiet=>/dev/null
6161
endif
6262

63+
cfgs-to-flags = $(patsubst %,--cfg='%',$1)
64+
6365
core-cfgs := \
64-
--cfg no_fp_fmt_parse
66+
no_fp_fmt_parse
6567

6668
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
6769

@@ -72,7 +74,7 @@ core-skip_flags := \
7274

7375
core-flags := \
7476
--edition=$(core-edition) \
75-
$(core-cfgs)
77+
$(call cfgs-to-flags,$(core-cfgs))
7678

7779
# `rustdoc` did not save the target modifiers, thus workaround for
7880
# the time being (https://github.com/rust-lang/rust/issues/144521).

scripts/generate_rust_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def args_crates_cfgs(cfgs):
1515
crates_cfgs = {}
1616
for cfg in cfgs:
1717
crate, vals = cfg.split("=", 1)
18-
crates_cfgs[crate] = vals.replace("--cfg", "").split()
18+
crates_cfgs[crate] = vals.split()
1919

2020
return crates_cfgs
2121

0 commit comments

Comments
 (0)