Skip to content

feat(cargo): Set rustc-check-cfg for all config options #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ball-hayden
Copy link

This squashes lint warnings for config options which are not currently enabled.

See https://doc.rust-lang.org/cargo/reference/build-scripts.html\#rustc-check-cfg

@ball-hayden
Copy link
Author

@d3zd3z thanks for your work so far on this.

May I request a review on this, please?

Copy link
Collaborator

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this only squashes some warnings from this lint, specifically settings that are possible in the current configuration, but are disabled. But configurations that don't apply will not be seen by this and will still generate warnings.

Aside from generating a list of all possible configs from all Kconfig files (including modules that aren't present), I don't really see a way to make this work, which is why my examples have just been suppressing the lint.

@ball-hayden
Copy link
Author

This is true.
It does feel like a step in the right direction, though?

@ball-hayden
Copy link
Author

I wonder if we could do something with kconfiglib similar to how the Doxygen extension works, so we could list all possible options.

I'll try to find some time to have a look into this.

@ball-hayden ball-hayden force-pushed the check-cfg branch 3 times, most recently from 227220c to 8ba2555 Compare April 20, 2025 16:00
@ball-hayden
Copy link
Author

@d3zd3z how do you feel about this as an approach?

This seems to work for my project - I'd be interested to know how CI fares.

I'm not entirely happy about having an intermediate JSON file, but struggling to think of other options that would produce the complete list we need.

This squashes lint warnings for config options which are not
currently enabled.

See https://doc.rust-lang.org/cargo/reference/build-scripts.html\#rustc-check-cfg

Signed-off-by: Hayden Ball <[email protected]>
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