cmake: import_kconfig: Generalize 'import_kconfig' to support DT

Generalize 'import_kconfig' to support parsing symbols with other
prefixes than 'CONFIG_'. This will eventually allow us to also import
'DT_' symbols into the CMake namespace.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2018-12-12 15:33:07 +01:00 committed by Kumar Gala
commit c842fb88d7
3 changed files with 6 additions and 6 deletions

View file

@ -193,7 +193,7 @@ if(CONFIG_HAS_DTS)
message(FATAL_ERROR "command failed with return code: ${ret}")
endif()
import_kconfig(${GENERATED_DTS_BOARD_CONF})
import_kconfig(CONFIG_ ${GENERATED_DTS_BOARD_CONF})
else()
file(WRITE ${GENERATED_DTS_BOARD_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */")

View file

@ -745,15 +745,15 @@ endfunction()
# 2.2 Misc
#
# Parse a KConfig fragment (typically with extension .config) and
# introduce all the symbols that are prefixed with 'CONFIG_' into the
# introduce all the symbols that are prefixed with 'prefix' into the
# CMake namespace
function(import_kconfig kconfig_fragment)
# Parse the lines prefixed with 'CONFIG_' in ${kconfig_fragment}
function(import_kconfig prefix kconfig_fragment)
# Parse the lines prefixed with 'prefix' in ${kconfig_fragment}
file(
STRINGS
${kconfig_fragment}
DOT_CONFIG_LIST
REGEX "^CONFIG_"
REGEX "^${prefix}"
ENCODING "UTF-8"
)

View file

@ -177,7 +177,7 @@ foreach (name ${cache_variable_names})
endforeach()
# Parse the lines prefixed with CONFIG_ in the .config file from Kconfig
import_kconfig(${DOTCONFIG})
import_kconfig(CONFIG_ ${DOTCONFIG})
# Re-introduce the CLI Kconfig symbols that survived
foreach (name ${cache_variable_names})