summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@kernel.org>2026-01-27 08:55:51 -0500
committerTamir Duberstein <tamird@kernel.org>2026-03-09 13:20:09 -0400
commit5c8d16ac49405c5b77c955684849528f7d4d6b81 (patch)
tree4a4072e290a6a92e913e8dfba467ed7ca6361a9c /scripts
parentdc6b431f18cfb1e8cc7da45c16ccf371bcd636d5 (diff)
downloadlwn-5c8d16ac49405c5b77c955684849528f7d4d6b81.tar.gz
lwn-5c8d16ac49405c5b77c955684849528f7d4d6b81.zip
scripts: generate_rust_analyzer.py: reduce cfg plumbing
Pass `pin_init{,_internal}-cfgs` from rust/Makefile to scripts/generate_rust_analyzer.py. Remove hardcoded `cfg`s in scripts/generate_rust_analyzer.py for `pin-init{,-internal}` now that these are passed from `rust/Makefile`. Centralize `cfg` lookup in scripts/generate_rust_analyzer.py in `append_crate` to avoid having to do so for each crate. Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com> Acked-by: Benno Lossin <lossin@kernel.org> Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://patch.msgid.link/20260127-rust-analyzer-pin-init-duplication-v3-2-118c48c35e88@kernel.org Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_rust_analyzer.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 2977dfff76b3..b4a55344688d 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -78,7 +78,7 @@ def generate_crates(
is_workspace_member: Optional[bool],
edition: Optional[str],
) -> Crate:
- cfg = cfg if cfg is not None else []
+ cfg = cfg if cfg is not None else crates_cfgs.get(display_name, [])
is_workspace_member = (
is_workspace_member if is_workspace_member is not None else True
)
@@ -203,7 +203,7 @@ def generate_crates(
# NB: sysroot crates reexport items from one another so setting up our transitive dependencies
# here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth
# for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`.
- core = append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []))
+ core = append_sysroot_crate("core", [])
alloc = append_sysroot_crate("alloc", [core])
std = append_sysroot_crate("std", [alloc, core])
proc_macro = append_sysroot_crate("proc_macro", [core, std])
@@ -218,14 +218,12 @@ def generate_crates(
"proc_macro2",
srctree / "rust" / "proc-macro2" / "lib.rs",
[core, alloc, std, proc_macro],
- cfg=crates_cfgs["proc_macro2"],
)
quote = append_crate(
"quote",
srctree / "rust" / "quote" / "lib.rs",
[core, alloc, std, proc_macro, proc_macro2],
- cfg=crates_cfgs["quote"],
edition="2018",
)
@@ -233,7 +231,6 @@ def generate_crates(
"syn",
srctree / "rust" / "syn" / "lib.rs",
[std, proc_macro, proc_macro2, quote],
- cfg=crates_cfgs["syn"],
)
macros = append_proc_macro_crate(
@@ -252,14 +249,12 @@ def generate_crates(
"pin_init_internal",
srctree / "rust" / "pin-init" / "internal" / "src" / "lib.rs",
[std, proc_macro, proc_macro2, quote, syn],
- cfg=["kernel"],
)
pin_init = append_crate(
"pin_init",
srctree / "rust" / "pin-init" / "src" / "lib.rs",
[core, compiler_builtins, pin_init_internal, macros],
- cfg=["kernel"],
)
ffi = append_crate(