scripts: generate_rust_analyzer: Handle sub-modules with no Makefile
authorAsahi Lina <lina@asahilina.net>
Thu, 6 Apr 2023 22:25:22 +0000 (00:25 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 6 Apr 2023 22:53:34 +0000 (00:53 +0200)
More complex drivers might want to use modules to organize their Rust
code, but those module folders do not need a Makefile.
generate_rust_analyzer.py currently crashes on those. Fix it so that a
missing Makefile is silently ignored.

Link: https://github.com/Rust-for-Linux/linux/pull/883
Signed-off-by: Asahi Lina <lina@asahilina.net>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
scripts/generate_rust_analyzer.py

index ecc7ea9a4dcfc6f1c89f289f8866bad9ed1e430b..946e250c1b2a6f9b243d8836ea47ad067970530b 100755 (executable)
@@ -104,7 +104,10 @@ def generate_crates(srctree, objtree, sysroot_src):
             name = path.name.replace(".rs", "")
 
             # Skip those that are not crate roots.
-            if f"{name}.o" not in open(path.parent / "Makefile").read():
+            try:
+                if f"{name}.o" not in open(path.parent / "Makefile").read():
+                    continue
+            except FileNotFoundError:
                 continue
 
             logging.info("Adding %s", name)