cmake: kconfig: Preserve correct CLI assignments across re-runs
This tiny patch makes two improvements: 1. Preserve boolean (=n) assignments from command-line. This fixes an issue where, if a symbol with `default y` were turned off via command-line, e.g., `-DCONFIG_BOOT_BANNER=n`, a CMake re-run would revert that symbol back to its default value. To avoid this, the assignment should have been preserved in CMake cache as `CLI_CONFIG_BOOT_BANNER:INTERNAL=n`. However, `kconfig.cmake` clears unset variables from cache, and (=n) symbols become unset variables, so an exception had to be made for them. 2. Discard invalid assignments from command-line. Although `kconfig.cmake` takes care to discard assignments to symbols which get unset by Kconfig, it wasn't handling the case where Kconfig would keep the symbol but replace its value, making the CMake-cached assignment invalid. For example, this assignment: west build . -DCONFIG_PRINTK=n could be invalidated if PRINTK were selected by, e.g., BOOT_BANNER, producing this warning: PRINTK (...) was assigned the value 'n' but got the value 'y'. (...) Still, the old value of (=n) was being cached. One way in which this was evident was when setting an unrelated symbol in a separate invocation: west build . -DCONFIG_MAIN_STACK_SIZE=512 the same warning for PRINTK would show up again. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
9228c379cd
commit
cb46ed6a32
1 changed files with 19 additions and 2 deletions
|
@ -376,15 +376,32 @@ foreach (name ${cli_config_list})
|
|||
unset(${name} CACHE)
|
||||
endforeach()
|
||||
|
||||
# Before importing the symbol values from DOTCONFIG, process the CLI values by
|
||||
# re-importing them from EXTRA_KCONFIG_OPTIONS_FILE. Later, we want to compare
|
||||
# the values from both files, and 'import_kconfig' will make this easier.
|
||||
if(EXTRA_KCONFIG_OPTIONS_FILE)
|
||||
import_kconfig(${KCONFIG_NAMESPACE} ${EXTRA_KCONFIG_OPTIONS_FILE})
|
||||
foreach (name ${cache_variable_names})
|
||||
if(DEFINED ${name})
|
||||
set(temp_${name} "${${name}}")
|
||||
unset(${name})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Import the .config file and make all settings available in CMake processing.
|
||||
import_kconfig(${KCONFIG_NAMESPACE} ${DOTCONFIG})
|
||||
|
||||
# Cache the CLI Kconfig symbols that survived through Kconfig, prefixed with CLI_.
|
||||
# Remove those who might have changed compared to earlier runs, if they no longer appears.
|
||||
foreach (name ${cli_config_list})
|
||||
if(DEFINED ${name})
|
||||
foreach (name ${cache_variable_names})
|
||||
# Note: "${CLI_${name}}" is the verbatim value of ${name} from command-line,
|
||||
# while "${temp_${name}}" is the same value processed by 'import_kconfig'.
|
||||
if(((NOT DEFINED ${name}) AND (NOT DEFINED temp_${name})) OR
|
||||
((DEFINED ${name}) AND (DEFINED temp_${name}) AND (${name} STREQUAL temp_${name})))
|
||||
set(CLI_${name} ${CLI_${name}} CACHE INTERNAL "")
|
||||
else()
|
||||
unset(CLI_${name} CACHE)
|
||||
endif()
|
||||
unset(temp_${name})
|
||||
endforeach()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue