scripts: generate_rust_analyzer.py: define scripts
Subsystems (3)
Tamir Duberstein
maintainerPATCH 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
@@ -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]>
Quoted 5 lines · Tamir Duberstein
Generate rust-project.json entries for scripts written in Rust.
Use
Pathlib.path.stemfor consistency.
Quoted 7 lines
Fixes 9a8ff24ce584 ("scripts: add `generate_rust_target.rs`")Reviewed-by Daniel Almeida <[email protected]>Tested-by Daniel Almeida <[email protected]>Reviewed-by Fiona Behrens <[email protected]>Reviewed-by Trevor Gross <[email protected]>Signed-off-by Tamir Duberstein <[email protected]>
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
Tamir Duberstein
maintainerQuoted 15 lines · Miguel Ojeda
Quoted 5 lines · Tamir Duberstein
Generate rust-project.json entries for scripts written in Rust.
Use
Pathlib.path.stemfor consistency.Quoted 7 lines
Fixes 9a8ff24ce584 ("scripts: add `generate_rust_target.rs`")Reviewed-by Daniel Almeida <[email protected]>Tested-by Daniel Almeida <[email protected]>Reviewed-by Fiona Behrens <[email protected]>Reviewed-by Trevor Gross <[email protected]>Signed-off-by Tamir Duberstein <[email protected]>
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
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
Tamir Duberstein
maintainerQuoted 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
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!
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
Tamir Duberstein
maintainerQuoted 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.
Tamir Duberstein
maintainerQuoted 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!