cmake: kconfig cmake file environment cleanup

This commit is a cleanup of the cmake/kconfig.cmake file.
It removes `set(ENV{<name>} <value>)` and instead creates a shared list
that can be used for execute_process() and add_custom_target() when
running Kconfig during CMake configure time or menuconfig and related
build targets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2020-08-25 11:02:45 +02:00 committed by Carles Cufí
parent eca8842b67
commit c8295b19aa

View file

@ -48,20 +48,23 @@ endif()
# separated list instead.
string(REPLACE ";" "?" DTS_ROOT_BINDINGS "${DTS_ROOT_BINDINGS}")
set(ENV{srctree} ${ZEPHYR_BASE})
set(ENV{KERNELVERSION} ${KERNELVERSION})
set(ENV{KCONFIG_CONFIG} ${DOTCONFIG})
set(ENV{PYTHON_EXECUTABLE} ${PYTHON_EXECUTABLE})
# Set environment variables so that Kconfig can prune Kconfig source
# files for other architectures
set(ENV{ARCH} ${ARCH})
set(ENV{BOARD_DIR} ${BOARD_DIR})
set(ENV{SHIELD_AS_LIST} "${SHIELD_AS_LIST}")
set(ENV{KCONFIG_BINARY_DIR} ${KCONFIG_BINARY_DIR})
set(ENV{ARCH_DIR} ${ARCH_DIR})
set(ENV{TOOLCHAIN_KCONFIG_DIR} "${TOOLCHAIN_KCONFIG_DIR}")
set(ENV{EDT_PICKLE} ${EDT_PICKLE})
# A list of common environment settings used when invoking Kconfig during CMake
# configure time or menuconfig and related build target.
set(COMMON_KCONFIG_ENV_SETTINGS
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
srctree=${ZEPHYR_BASE}
KERNELVERSION=${KERNELVERSION}
KCONFIG_CONFIG=${DOTCONFIG}
# Set environment variables so that Kconfig can prune Kconfig source
# files for other architectures
ARCH=${ARCH}
ARCH_DIR=${ARCH_DIR}
BOARD_DIR=${BOARD_DIR}
SHIELD_AS_LIST=${SHIELD_AS_LIST}
KCONFIG_BINARY_DIR=${KCONFIG_BINARY_DIR}
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
EDT_PICKLE=${EDT_PICKLE}
)
# Allow out-of-tree users to add their own Kconfig python frontend
# targets by appending targets to the CMake list
@ -93,27 +96,18 @@ foreach(kconfig_target
add_custom_target(
${kconfig_target}
${CMAKE_COMMAND} -E env
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
srctree=${ZEPHYR_BASE}
KERNELVERSION=${KERNELVERSION}
ZEPHYR_BASE=${ZEPHYR_BASE}
KCONFIG_CONFIG=${DOTCONFIG}
ARCH=$ENV{ARCH}
BOARD_DIR=$ENV{BOARD_DIR}
SHIELD_AS_LIST=$ENV{SHIELD_AS_LIST}
KCONFIG_BINARY_DIR=$ENV{KCONFIG_BINARY_DIR}
ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT}
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
ARCH_DIR=$ENV{ARCH_DIR}
${COMMON_KCONFIG_ENV_SETTINGS}
EXTRA_DTC_FLAGS=${EXTRA_DTC_FLAGS}
DTS_POST_CPP=${DTS_POST_CPP}
DTS_ROOT_BINDINGS=${DTS_ROOT_BINDINGS}
EDT_PICKLE=${EDT_PICKLE}
${PYTHON_EXECUTABLE}
${EXTRA_KCONFIG_TARGET_COMMAND_FOR_${kconfig_target}}
${KCONFIG_ROOT}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig
USES_TERMINAL
COMMAND_EXPAND_LISTS
)
endforeach()
@ -211,7 +205,8 @@ else()
endif()
execute_process(
COMMAND
COMMAND ${CMAKE_COMMAND} -E env
${COMMON_KCONFIG_ENV_SETTINGS}
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/kconfig/kconfig.py
--zephyr-base=${ZEPHYR_BASE}