]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scripts: generate_rust_analyzer.py: define scripts
authorTamir Duberstein <tamird@kernel.org>
Thu, 22 Jan 2026 16:53:28 +0000 (11:53 -0500)
committerTamir Duberstein <tamird@kernel.org>
Mon, 9 Mar 2026 17:20:08 +0000 (13:20 -0400)
Add IDE support for host-side scripts written in Rust. This support has
been missing since these scripts were initially added in commit
9a8ff24ce584 ("scripts: add `generate_rust_target.rs`"), thus add it.

Change the existing instance of extension stripping to
`pathlib.Path.stem` to maintain code consistency.

Fixes: 9a8ff24ce584 ("scripts: add `generate_rust_target.rs`")
Cc: stable@vger.kernel.org
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Link: https://patch.msgid.link/20260122-rust-analyzer-scripts-v1-1-ff6ba278170e@kernel.org
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
scripts/generate_rust_analyzer.py

index 7becc2698c146503163953596333234df423d951..38e834bd209e0081cbbde692c746b0429d889c65 100755 (executable)
@@ -299,6 +299,18 @@ def generate_crates(
         "kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi]
     )
 
+    scripts = srctree / "scripts"
+    makefile = (scripts / "Makefile").read_text()
+    for path in scripts.glob("*.rs"):
+        name = path.stem
+        if f"{name}-rust" not in makefile:
+            continue
+        append_crate(
+            name,
+            path,
+            [std],
+        )
+
     def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
         try:
             return f"{target}.o" in open(build_file).read()
@@ -316,7 +328,7 @@ def generate_crates(
     for folder in extra_dirs:
         for path in folder.rglob("*.rs"):
             logging.info("Checking %s", path)
-            name = path.name.replace(".rs", "")
+            name = path.stem
 
             # Skip those that are not crate roots.
             if not is_root_crate(path.parent / "Makefile", name) and \