Re: [PATCH v5 13/13] scripts: generate_rust_analyzer.py: use `cfg_groups`
From: Tamir Duberstein
Date: Thu Apr 17 2025 - 09:17:24 EST
On Thu, Apr 17, 2025 at 3:29 AM Trevor Gross <tmgross@xxxxxxxxx> wrote:
>
> On Tue, Mar 25, 2025 at 3:07 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
> >
> > Declare common `cfg`s just once to reduce the size of rust-analyzer.json
> > from 30619 to 2624 lines.
> >
> > Link: https://github.com/rust-lang/rust-analyzer/commit/2607c09fddef36da0d6f0a84625db5e20a5ebde3
> > Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> > Tested-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> > Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
> > ---
> > scripts/generate_rust_analyzer.py | 19 ++++++++++---------
> > 1 file changed, 10 insertions(+), 9 deletions(-)
>
> > @@ -76,6 +70,7 @@ def generate_crates(
> > "root_module": str(root_module),
> > "is_workspace_member": is_workspace_member,
> > "deps": deps,
> > + "cfg_groups": cfg_groups if is_workspace_member else [],
>
> Does r-a just expect cfg_groups for workspace members or is there
> logic here? Maybe worth a comment.
r-a doesn't have opinions, but our configs apply only to our crates as
opposed to sysroot crates. That's not entirely true for core, but the
configs we apply there are narrow, whereas our workspace crates get
all of KConfig, which is huge.
I'll add a comment.
> Reviewed-by: Trevor Gross <tmgross@xxxxxxxxx>
Thanks for the reviews! I need to rebase on rust-fixes which picked up
the ffi crate anyway, so I picked up your suggestions:
- generators instead of `map`.
- `Pathlib.path.stem`.
- `Pathlib.path.read_text`.
- Add a comment about cfg_groups.
Cheers.
Tamir