Skip to contentSkip to conversation

scripts: generate_rust_analyzer.py: define scripts

PATCH In review Tamir Duberstein 2 participants 9 messages Jan 22 – Mar 2

Subsystems (3)
lore
Share & tools
lore

Tamir Duberstein

author maintainer
#0 lore raw

PATCH 1/1 scripts: generate_rust_analyzer.py: define scripts

Generate rust-project.json entries for scripts written in Rust.

Use Pathlib.path.stem for consistency.

---
 scripts/generate_rust_analyzer.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
scripts/generate_rust_analyzer.py +13 -1
index 3b645da90092..650535f2228d 100755
@@ -188,6 +188,18 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
     append_crate_with_generated("uapi", ["core", "ffi", "pin_init"])
     append_crate_with_generated("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,
+            deps=["std"],
+        )
+
     def is_root_crate(build_file, target):
         try:
             return f"{target}.o" in open(build_file).read()
@@ -203,7 +215,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
     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 \

---
base-commit: 2af6ad09fc7dfe9b3610100983cccf16998bf34d
change-id: 20260122-rust-analyzer-scripts-39e673a918ff

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
#1 lore raw
Quoted 5 lines · Tamir Duberstein

Generate rust-project.json entries for scripts written in Rust.

Use Pathlib.path.stem for consistency.

Quoted 7 lines

Hmm... This introduces support for scripts, right? i.e. it is a feature, or am I misunderstanding the Fixes:/Cc: stable tags?

Also, I don't see the Tested-by from Daniel -- he gave it on the last patch in v4, but not this one. Was it because it was assumed that testing the last patch meant testing all? Generally that shouldn't be assumed, e.g. he gave two Tested-by tags, so I guess he didn't mean to give it to all.

I would also suggest on apply to give it a bit more details.

Anyway, this seems best suited for rust-analyzer-next after the merge window when the above is sorted out.

Thanks for reviving these patches and splitting them!

Cheers,
Miguel

author maintainer
#2 lore raw
Quoted 15 lines · Miguel Ojeda
Quoted 5 lines · Tamir Duberstein

Generate rust-project.json entries for scripts written in Rust.

Use Pathlib.path.stem for consistency.

Quoted 7 lines
Quoted 2 lines

Hmm... This introduces support for scripts, right? i.e. it is a feature, or am I misunderstanding the Fixes:/Cc: stable tags?

It depends on your perspective - I framed it as a fix of the commit that added the first script because that script was added without RA support. What do you think?

Quoted 5 lines

Also, I don't see the Tested-by from Daniel -- he gave it on the last patch in v4, but not this one. Was it because it was assumed that testing the last patch meant testing all? Generally that shouldn't be assumed, e.g. he gave two Tested-by tags, so I guess he didn't mean to give it to all.

It was so long ago, I'm not sure. I'll remove the tag. Thanks for calling out!

Quoted 4 lines

I would also suggest on apply to give it a bit more details.

Anyway, this seems best suited for rust-analyzer-next after the merge window when the above is sorted out.

Will do.

Quoted 6 lines

Thanks for reviving these patches and splitting them!

Cheers,
Miguel

#3 lore raw
Quoted 4 lines · Tamir Duberstein

It depends on your perspective - I framed it as a fix of the commit that added the first script because that script was added without RA support. What do you think?

Yeah, I see.

So, on the implementation side, I don't think we expected scripts to work at all, which is why it sounds to me like a feature (neither the linked commit nor the one that added rust-analyzer overall support mentions it that I can see, though it doesn't say otherwise either).

But perhaps someone out there expected it to actually work and thus may think of it as a fix. I don't recall someone asking for it, but I haven't checked. Perhaps someone would, when we use more and more Rust scripts.

Now, for the backport part, according to the official rules, I think it wouldn't fit. But those rules are often relaxed and who knows what companies out there doing out-of-tree work on top of LTS kernels want... (Commits can be submitted there even if they are not fixes, by the way).

Cheers,
Miguel

author maintainer
#4 lore raw
Quoted 19 lines · Miguel Ojeda
Quoted 4 lines · Tamir Duberstein

It depends on your perspective - I framed it as a fix of the commit that added the first script because that script was added without RA support. What do you think?

Yeah, I see.

So, on the implementation side, I don't think we expected scripts to work at all, which is why it sounds to me like a feature (neither the linked commit nor the one that added rust-analyzer overall support mentions it that I can see, though it doesn't say otherwise either).

But perhaps someone out there expected it to actually work and thus may think of it as a fix. I don't recall someone asking for it, but I haven't checked. Perhaps someone would, when we use more and more Rust scripts.

Quoted 5 lines

Now, for the backport part, according to the official rules, I think it wouldn't fit. But those rules are often relaxed and who knows what companies out there doing out-of-tree work on top of LTS kernels want... (Commits can be submitted there even if they are not fixes, by the way).

Thanks for the context. In that case I'll keep it as a fix and take it through rust-analyzer-next with the backport tags since I expect it to apply cleanly.

Cheers,
Tamir

author maintainer Applied
#5 lore raw
Quoted 28 lines · Tamir Duberstein
Quoted 19 lines · Miguel Ojeda
Quoted 4 lines · Tamir Duberstein

It depends on your perspective - I framed it as a fix of the commit that added the first script because that script was added without RA support. What do you think?

Yeah, I see.

So, on the implementation side, I don't think we expected scripts to work at all, which is why it sounds to me like a feature (neither the linked commit nor the one that added rust-analyzer overall support mentions it that I can see, though it doesn't say otherwise either).

But perhaps someone out there expected it to actually work and thus may think of it as a fix. I don't recall someone asking for it, but I haven't checked. Perhaps someone would, when we use more and more Rust scripts.

Quoted 5 lines

Now, for the backport part, according to the official rules, I think it wouldn't fit. But those rules are often relaxed and who knows what companies out there doing out-of-tree work on top of LTS kernels want... (Commits can be submitted there even if they are not fixes, by the way).

Quoted 6 lines

Thanks for the context. In that case I'll keep it as a fix and take it through rust-analyzer-next with the backport tags since I expect it to apply cleanly.

Cheers,
Tamir

Applied to rust-analyzer-next. Thanks all!

#6 lore raw
Quoted 2 lines · Tamir Duberstein

Applied to rust-analyzer-next. Thanks all!

Please see the other thread (and please reset the branch to e.g. v6.19-rc7 for now -- we should avoid giving linux-next unneeded conflicts).

Cheers,
Miguel

author maintainer
#7 lore raw
Quoted 8 lines · Miguel Ojeda
Quoted 2 lines · Tamir Duberstein

Applied to rust-analyzer-next. Thanks all!

Please see the other thread (and please reset the branch to e.g. v6.19-rc7 for now -- we should avoid giving linux-next unneeded conflicts).

Ack, done.

author maintainer
#8 lore raw
Quoted 6 lines · Tamir Duberstein
Quoted 3 lines · Miguel Ojeda
Quoted 1 line · Tamir Duberstein
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Applied to rust-analyzer-next. Thanks all!

Please see the other thread (and please reset the branch to e.g. v6.19-rc7 for now -- we should avoid giving linux-next unneeded conflicts).

Ack, done.

This is now applied to rust-analyzer-next for real. Thanks all!