Users often get confused when they change Kconfig sources and then
rebuild only to discover that nothing happens. To fix this we add a
dependency between re-running cmake, and all Kconfig sources, similair
to how touching CMakeLists.txt files cause CMake to re-run.
This fixes#5634
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Update Kconfiglib (and menuconfig, just to sync) to upstream revision
094f4a9622046, to add the commit below.
Save existing configuration to .<filename>.old in write_config()
Add a default-True 'save_old' flag to write_config(). If 'save_old' is
True and an existing configuration file is being overwritten, a copy
of the old configuration file is saved to .<filename>.old (e.g.
.config.old) in the same directory.
Errors are ignored, as the old configuration would usually just be a
nice-to-have, and not essential.
The same functionality could be added for minimal configuration files
and headers, but it's probably most useful for configuration files.
Other changes:
- Parsing performance is improved a bit
- scripts/kconfig/kconfig.py now prints the path to the merged
configuration in zephyr/.config, to make it a bit easier to
discover.
Fixes: #2907
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Update Kconfiglib and menuconfig to upstream revision d3866958c7685, to
add various improvements:
- Support HOME and END in the jump-to dialog in the menuconfig. END can
be handy as choices, menus, and comments appear at the end.
- Add more fine-grained warning controls for multiple assignments to a
symbol in configuration files. Use it to simplify kconfig.py a bit.
Clean up kconfig.py a bit in other ways too, e.g. by removing unused
imports.
- Improve Kconfig parsing performance slightly
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Since the warnings generated by this script are so spammy, it can be
difficult to tell where they start and end. Put a blank line before each
one to make it clearer.
Also put blank lines around the non-whitelisted-warning error.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
- Use Kconfig.unique_{defined_syms,choices} to avoid redundant checks
for symbols/choices defined in multiple locations. These were
recently added to Kconfiglib.
- Remove the comment about the alldefconfig starting state. It probably
isn't useful here.
- Print the messages about loading configuration files just before they
are actually loaded. That looks less confusing if one of them fails
to load.
- Line-wrap the error message about non-whitelisted warnings.
- Misc. other minor code cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Commit b3d165f ("scripts: kconfig: Handle warnings generated
during evaluation") made it common for kconfig.py to fail after writing
zephyr/.config. This confuses the configuration fragment checksum logic
in cmake/kconfig.cmake, because it expects the saved checksum file to
exist if zephyr/.config exists.
The end result is a CMake error when rerunning the configuration after
non-whitelisted Kconfig warnings.
Fix it by only writing zephyr/.config (and zephyr/include/autoconf.h) in
kconfig.py if there are no warnings-turned-errors.
Also check if the saved checksum file exists in kconfig.cmake before
trying to open it. Normally this shouldn't happen though.
Move the writing of the checksum file to before writing zephyr/.config
as well. That way, zephyr/.config only gets written if the other
operations succeed.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Warnings generated during symbol evaluation were accidentally ignored,
due to checking for warnings before writing .config and autoconf.h
(which indirectly evaluates all symbols).
Move the warning checking code to after writing the configuration to
catch such warnings. kconfig.py still gets rerun if any
warnings-turned-errors show up.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Update Kconfiglib to upstream revision 547fced630611 to get a new
Kconfig preprocessor in, documented in
https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kconfig-macro-language.txt.
The preprocessor allows shell functions to be run directly from Kconfig.
Things like 'default "prefix-$(shell,some-cmd)' and
'depends on (success,some-cmd)' are supported.
The preprocessor might come in handy for Kconfig/DTS integration. I'm
thinking of extending it so that Python functions can be called as well.
There's also two new warnings:
- Trying to use an int/hex symbol like a bool symbol in an expression
(where it will always evaluate to n)
- Having a 'default' on an int/hex symbol that lies outside an active
'range'.
The parser is more strict now as well (due to dropping some hacks for 3+
year old kernel versions).
A related fix for scripts/kconfig.py is also included:
The comment above the whitelist lies. I accidentally changed the warning
text for the select-with-unsatisfied-dependencies warning while
generalizing it (for m-valued dependencies, which you'd never get in
Zephyr).
Update the whitelist to detect the new warning text.
Last-minute piggyback:
Include a change that improved the parse time for U-Boot from 4 seconds
to about 0.6 seconds, related to symbols defined in multiple locations.
It might be helpful for Zephyr as well, as it also uses a lot of symbols
defined in multiple locations.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Andy Ross wanted to override a choice selection from a board defconfig
file in a prj.conf, but this could trigger the
assigned-value-didn't-take warning, because the choice symbol set to y
in the board defconfig file ends up as n after another choice symbol is
selected.
(Note: Setting any choice symbol to y is enough to make it the choice
(user) selection. There's no need to set the other symbols to n.)
Fix the warning by checking choices at the choice level rather than at
the level of individual choice symbols. This also makes the warning a
bit more informative in general for choice symbols.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The warnings were fixed by commit c4123643b5 ("tests: fp_sharing:
Extract x86 configs to separate .conf").
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
- Tailor the warning when the symbol has no prompt, explaining how
promptless symbols get values. Add some anti-select propaganda too.
- Reference the 'Setting configuration values' in the Board Porting
Guide. It explains Kconfig.defconfig files.
Fixes: #8388
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Some prj.conf files seem to deliberately override settings from the
board configuration (e.g. samples/bluetooth/hci_usb/prj.conf, with
GPIO=y). Disable the warning about a symbol being assigned more than
once to avoid warnings for those cases.
A list similar to WARNING_WHITELIST could be added later if more
warnings need to be disabled.
Also refactor the warning checking code a bit to get rid of some not's.
Suggested by Sebastian Bøe.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
In particular, this will turn assignments to undefined Kconfig variables
into errors, which are very easy to miss otherwise (e.g. when Kconfig
symbols get renamed or removed).
Warnings generated by anything tested by CI (scripts/sanitycheck) will
be caught.
Have a whitelist of warnings that are not turned into errors. Some
warnings currently whitelisted should be turned into errors as well, but
would require a bit of work.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Symbols that are assigned values in .config files must have satisfied
dependencies, and must have a prompt. Otherwise, the assigned value is
ignored. A warning is printed if the symbol ends up with a different
value than the assigned value as a result.
It might be difficult to know how to fix the problem just from seeing
the current warning. Add some hints to it to help out:
- The symbol information dialog in menuconfig is good for figuring out
dependencies that need to be enabled. Mention menuconfig in the
warning.
- The page for the symbol in the autogenerated Kconfig docs can be
helpful too, so link it. There's a slight chance that it'll be
outdated, but it's usually correct when working on the master
branch.
Automatically enabling dependencies is much trickier than it might seem
at first, due to the generality of Kconfig. See
https://github.com/zephyrproject-rtos/zephyr/issues/8181 for some
discussion.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Kconfig.py is not following the de-facto (real?) coding standards of
Zephyr. This commit refactors kconfig.py with two changes:
Use __main__ and def main().
Use argparse instead of sys.argv.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The warning from Kconfiglib might be hard to spot, and the problem is
easily fixed right away (note that malformed .config lines are different
from assignments to undefined symbols).
Do not make malformed .config lines an error in Kconfiglib itself (just
a warning), as you end up with messy "half-loaded" configurations.
Suggested by Marti Bolivar.
Piggyback some minor cleanups in kconfig.py. Make the warning for
configuration settings that didn't match the final value go to stderr,
for consistency.
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Warnings from Kconfiglib itself always give symbol locations, but the
custom value mismatch warning in kconfig.py doesn't. Make it print the
symbol location(s) too. This is helpful when debugging.
Before:
warning: UART_QMSI_0_HW_FC was assigned the value "y" but got the
value "n" -- check dependencies
After:
warning: UART_QMSI_0_HW_FC (defined at
.../drivers/serial/Kconfig.qmsi:35,
.../arch/x86/soc/intel_quark/quark_se/Kconfig.defconfig.series:194)
was assigned the value "y" but got the value "n" -- check
dependencies
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Decode Kconfig sources as UTF-8 instead of decoding them according to
the system locale (which might be ascii-only).
This resolves an issue that can be reproduced like this:
$ export LANG=C
$ echo '# Sebastian Bøe' >> ~/zephyr/Kconfig
$ build_any_zephyr_app
See the Python comment for details.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
We have been using a fork of the Linux kernel's Kconfig system to
configure the Zephyr tree. The issue is that this is a native tool
written in C that is not easy to compile for Windows. This patch
replaces the use of the conf executable with kconfig.py, a script that
uses Kconfiglib to generate the .config and autoconf.h files required to
compile Zephyr.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>