-
Notifications
You must be signed in to change notification settings - Fork 30
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
ball-hayden
wants to merge
1
commit into
zephyrproject-rtos:main
Choose a base branch
from
PlayerData:check-cfg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
import argparse | ||
import json | ||
|
||
from itertools import chain | ||
|
||
sys.path.insert(0, str(os.path.join(os.environ["ZEPHYR_BASE"], "scripts", "kconfig"))) | ||
from kconfiglib import Kconfig, _T_BOOL, _T_CHOICE | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
|
||
kconf = Kconfig(args.kconfig_file) | ||
kconf.load_config(args.dotconfig) | ||
|
||
options = {} | ||
|
||
for sym in chain(kconf.unique_defined_syms, kconf.unique_choices): | ||
if not sym.name: | ||
continue | ||
|
||
if "-" in sym.name: | ||
# Rust does not allow hyphens in cfg options. | ||
continue | ||
|
||
if sym.type in [_T_BOOL, _T_CHOICE]: | ||
options[f"CONFIG_{sym.name}"] = sym.str_value | ||
|
||
with open(args.outfile, "w") as f: | ||
json.dump(options, f, indent=2, sort_keys=True) | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(allow_abbrev=False) | ||
|
||
parser.add_argument("kconfig_file", help="Top-level Kconfig file") | ||
parser.add_argument("dotconfig", help="Path to dotconfig file") | ||
parser.add_argument("outfile", help="Path to output file") | ||
|
||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this code from Zephyr. Will this visit all kconfig files, or just the ones that make sense for the current build. Specifically, I think we should try this with a test case of conditional code that references a config that isn't present in the builds we make, but is in the tree. Ideally, we would make sure this works for modules as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this will pick up the applications "root" Kconfig file (i.e. the one in
<appdir>/Kconfig
, where it is defined), and follow anysource
/rsource
commands from there.So it's not loading everything that smells like a Kconfig file within the directory tree, but it will load all kconfig files that are
rsource
ed (the same as with Zephyr's normal build).I'm not sure I follow.
If it's loaded as part of the Kconfig tree, it is present? If it isn't part of the Kconfig tree, then it's not a valid option (and should be flagged as not available).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the CMake changes were based around https://github.com/zephyrproject-rtos/zephyr/blob/main/cmake/modules/kconfig.cmake