mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 10:01:39 -05:00
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>
This commit is contained in:
@@ -60,8 +60,10 @@ rustdoc_test_quiet=--test-args -q
|
|||||||
rustdoc_test_kernel_quiet=>/dev/null
|
rustdoc_test_kernel_quiet=>/dev/null
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
cfgs-to-flags = $(patsubst %,--cfg='%',$1)
|
||||||
|
|
||||||
core-cfgs := \
|
core-cfgs := \
|
||||||
--cfg no_fp_fmt_parse
|
no_fp_fmt_parse
|
||||||
|
|
||||||
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
|
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ core-skip_flags := \
|
|||||||
|
|
||||||
core-flags := \
|
core-flags := \
|
||||||
--edition=$(core-edition) \
|
--edition=$(core-edition) \
|
||||||
$(core-cfgs)
|
$(call cfgs-to-flags,$(core-cfgs))
|
||||||
|
|
||||||
# `rustdoc` did not save the target modifiers, thus workaround for
|
# `rustdoc` did not save the target modifiers, thus workaround for
|
||||||
# the time being (https://github.com/rust-lang/rust/issues/144521).
|
# the time being (https://github.com/rust-lang/rust/issues/144521).
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def args_crates_cfgs(cfgs):
|
|||||||
crates_cfgs = {}
|
crates_cfgs = {}
|
||||||
for cfg in cfgs:
|
for cfg in cfgs:
|
||||||
crate, vals = cfg.split("=", 1)
|
crate, vals = cfg.split("=", 1)
|
||||||
crates_cfgs[crate] = vals.replace("--cfg", "").split()
|
crates_cfgs[crate] = vals.split()
|
||||||
|
|
||||||
return crates_cfgs
|
return crates_cfgs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user