-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Kconfig: Support macro expansion within symbol names #9797
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
Kconfig: Support macro expansion within symbol names #9797
Conversation
Update Kconfiglib to upstream revision 2be02fac78527 to add support for expanding macros within symbol names, extending the existing Kconfig preprocessor (https://github.com/torvalds/linux/blob/master/Documentation/kbuild/ kconfig-macro-language.txt). Some minor optimizations are included as well. This makes it possible to add Kconfig templates to avoid code repetition, e.g. like below: Kconfig.log_template: choice prompt "Max compiled-in log level for $(module-str)" config $(module)_LOG_LEVEL_OFF bool "Off" config $(module)_LOG_LEVEL_ERR bool "Error" config $(module)_LOG_LEVEL_WRN bool "Warning" config $(module)_LOG_LEVEL_INF bool "Info" config $(module)_LOG_LEVEL_DBG bool "Debug" endchoice config $(module)_LOG_LEVEL int default 0 if $(module)_LOG_LEVEL_OFF default 1 if $(module)_LOG_LEVEL_ERR default 2 if $(module)_LOG_LEVEL_WRN default 3 if $(module)_LOG_LEVEL_INF default 4 if $(module)_LOG_LEVEL_DBG Using the template: module = FOO module-str = foo source "Kconfig.log_template" ... module = BAR module-str = bar source "Kconfig.log_template" This feature might create harder-to-read Kconfig files if abused, so it should probably be used sparingly. Fixes: zephyrproject-rtos#9761 Signed-off-by: Ulf Magnusson <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #9797 +/- ##
==========================================
+ Coverage 52.23% 52.24% +<.01%
==========================================
Files 212 212
Lines 25951 25951
Branches 5593 5593
==========================================
+ Hits 13556 13557 +1
Misses 10159 10159
+ Partials 2236 2235 -1
Continue to review full report at Codecov.
|
I've tried it and works as expected. @nashif @carlescufi, could we get that in? |
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 am happy with this. This is a very powerful feature and we can make good use of it.
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.
Cool feature!
Update Kconfiglib to upstream revision 2be02fac78527 to add support for
expanding macros within symbol names, extending the existing Kconfig
preprocessor
(https://github.com/torvalds/linux/blob/master/Documentation/kbuild/
kconfig-macro-language.txt). Some minor optimizations are included as
well.
This makes it possible to add Kconfig templates to avoid code
repetition, e.g. like below:
Kconfig.log_template:
Using the template:
This feature might create harder-to-read Kconfig files if abused, so it
should probably be used sparingly.
Fixes: #9761