Re: [PATCH v5 12/13] scripts: generate_rust_analyzer.py: define scripts

Trevor Gross
2025-04-17T07:25:33Z

On Tue, Mar 25, 2025 at 3:07 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Generate rust-project.json entries for scripts written in Rust. This is
> possible now that we have a definition for `std` built for the host.
>
> Use `str::rstrip` for consistency.
>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
> Reviewed-by: Fiona Behrens <me@kloenk.dev>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> scripts/generate_rust_analyzer.py | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)

> + with open(scripts / "Makefile") as f:
> + makefile = f.read()

Since we are using pathlib, this can be `makefile = (scripts /
"Makefile").open().read()`

> + for path in scripts.glob("*.rs"):
> + name = path.name.rstrip(".rs")

`stem` should provide the file name without extension, so

name = path.stem

> @@ -267,7 +281,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.name.rstrip(".rs")

The above applies here too.

A couple of optional nits if you resend but nothing to block on:

Reviewed-by: Trevor Gross <tmgross@umich.edu>