Skip to content

libnvme: replace accessor generator with Python and add in-source ann…#3196

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:generator-annotations
Mar 18, 2026
Merged

libnvme: replace accessor generator with Python and add in-source ann…#3196
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:generator-annotations

Conversation

@martin-belanger
Copy link

…otations

The generate-accessors tool has been rewritten in Python (generate-accessors.py) and the mechanism for controlling which structs and members get accessors has moved from separate list files to in-source annotations in the header files themselves.

Struct inclusion is now opt-in via an annotation on the opening brace:

struct nvme_ctrl { /*!generate-accessors*/

Members can be excluded or made read-only via per-member annotations:

char *state;     //!accessors:none
char *firmware;  //!accessors:readonly

Both /* */ and // comment styles are accepted for all annotations.

This replaces the generate-accessors-include.list and generate-accessors-exclude.list files, which are no longer needed. The annotations are co-located with the struct definitions, making it immediately visible from the header which structs and members are covered and why.

The Python rewrite is significantly shorter (~350 lines vs ~2100) and handles the annotation-before-comment-stripping requirement naturally, whereas the C implementation would have required keeping a raw copy of each struct body in parallel with the comment-masked version.

private.h is updated with the equivalent annotations that were previously expressed through the now-deleted list files.

meson.build and update-accessors.sh are updated accordingly. The --incl and --excl CLI options are removed as they are superseded by annotations.

…otations

The generate-accessors tool has been rewritten in Python
(generate-accessors.py) and the mechanism for controlling which structs
and members get accessors has moved from separate list files to in-source
annotations in the header files themselves.

Struct inclusion is now opt-in via an annotation on the opening brace:

    struct nvme_ctrl { /*!generate-accessors*/

Members can be excluded or made read-only via per-member annotations:

    char *state;     //!accessors:none
    char *firmware;  //!accessors:readonly

Both /* */ and // comment styles are accepted for all annotations.

This replaces the generate-accessors-include.list and
generate-accessors-exclude.list files, which are no longer needed.
The annotations are co-located with the struct definitions, making it
immediately visible from the header which structs and members are
covered and why.

The Python rewrite is significantly shorter (~350 lines vs ~2100) and
handles the annotation-before-comment-stripping requirement naturally,
whereas the C implementation would have required keeping a raw copy of
each struct body in parallel with the comment-masked version.

private.h is updated with the equivalent annotations that were
previously expressed through the now-deleted list files.

meson.build and update-accessors.sh are updated accordingly.
The --incl and --excl CLI options are removed as they are superseded
by annotations.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@igaw igaw merged commit a19cf14 into linux-nvme:master Mar 18, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants