Skip to content

Commit 36c619f

Browse files
committed
scripts: generate_rust_analyzer.py: define scripts
Add IDE support for host-side scripts written in Rust. This support has been missing since these scripts were initially added in commit 9a8ff24 ("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: 9a8ff24 ("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>
1 parent 75c0fb2 commit 36c619f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

scripts/generate_rust_analyzer.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,18 @@ def append_crate_with_generated(
299299
"kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi]
300300
)
301301

302+
scripts = srctree / "scripts"
303+
makefile = (scripts / "Makefile").read_text()
304+
for path in scripts.glob("*.rs"):
305+
name = path.stem
306+
if f"{name}-rust" not in makefile:
307+
continue
308+
append_crate(
309+
name,
310+
path,
311+
[std],
312+
)
313+
302314
def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
303315
try:
304316
return f"{target}.o" in open(build_file).read()
@@ -316,7 +328,7 @@ def is_root_crate(build_file: pathlib.Path, target: str) -> bool:
316328
for folder in extra_dirs:
317329
for path in folder.rglob("*.rs"):
318330
logging.info("Checking %s", path)
319-
name = path.name.replace(".rs", "")
331+
name = path.stem
320332

321333
# Skip those that are not crate roots.
322334
if not is_root_crate(path.parent / "Makefile", name) and \

0 commit comments

Comments
 (0)