-
Notifications
You must be signed in to change notification settings - Fork 161
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
Implement autoconf.h generation #35
Conversation
kconfiglib.py
Outdated
item = node.item | ||
if isinstance(item, Symbol): | ||
if not item._written: | ||
if item._write_to_conf: |
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.
There's a subtlety here that causes this to break unless all the symbol values have already been calculated: _write_to_conf
is calculated when the symbol value is calculated.
If you do val = item.str_value
before checking _write_to_conf
and use that, it will work fine. .str_value
is actually a hidden function call (that uses Python @property
magic).
There's a related note in a comment in config_string
, but it might be hard to spot unless you already know that that's a hidden function call too. :)
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 did read that, but I wrongly assumed that one always calls write_config
before write_autoconf
kconfiglib.py
Outdated
elif item.orig_type == STRING: | ||
write('#define {}{} "{}"\n' | ||
.format(self.config_prefix, item.name, | ||
item.str_value)) |
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.
Could make this escape(item.str_value)
. Then string values containing "
and \
will be properly escaped.
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.
Fixed thanks!
kconfiglib.py
Outdated
elif item.orig_type in (INT, HEX): | ||
write("#define {}{} {}\n" | ||
.format(self.config_prefix, item.name, | ||
item.str_value)) |
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.
Could do this, just to match the C implementation:
if item.orig_type == HEX and not val.startswith(("0x", "0X")):
val = "0x" + val
Looks fine other than that!
I'm used to Gerrit. Think you might have to force push the branch or something to address review comments. 🤔
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.
Yeah, I do it all the time with GitHub :)
Addressed but I couldn't keep it within the 80-char width limit, Python was throwing me errors.
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.
No worries.
If you want to split something that's not enclosed in brackets over multiple lines in Python, you need to add a \ at the end of the line.
Implement the generation of the C header file that mirrors the .config files, commonly named autoconf.h. Signed-off-by: Carles Cufi <[email protected]>
Thanks! |
Going to bed soon (my sleep schedule's a bit wonky atm :)), but I'll push out a new release to PyPI later on today as well. |
Thank you, although there is no rush yet with PyPI since we will need to keep 2 patches (globbing and prefer later defaults) out of tree until I have fixed our Kconfig files. |
Implement the generation of the C header file that mirrors the .config
files, commonly named autoconf.h.
Signed-off-by: Carles Cufi [email protected]