From 9f62947d40cf44ab826368bd3679a6e22f96e1ad Mon Sep 17 00:00:00 2001 From: Yanfeng Liu Date: Tue, 27 Feb 2024 18:30:01 +0800 Subject: [PATCH] build/cmake: fix empty BASE_DEFCONFIG string Currently CMake system has empty string for BASE_DEFCONFIG option. This patch fills value for it. Signed-off-by: Yanfeng Liu --- cmake/nuttx_mkconfig.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmake/nuttx_mkconfig.cmake b/cmake/nuttx_mkconfig.cmake index 54b2e1072f..fc040eb840 100644 --- a/cmake/nuttx_mkconfig.cmake +++ b/cmake/nuttx_mkconfig.cmake @@ -40,6 +40,14 @@ if(COMPARE_RESULT EQUAL 0 AND EXISTS ${CONFIG_H}) return() endif() +set(BASE_DEFCONFIG "${NUTTX_BOARD}/${NUTTX_CONFIG}") +execute_process( + COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_BINARY_DIR}/.config + ${CMAKE_BINARY_DIR}/.config.orig RESULT_VARIABLE COMPARE_RESULT) +if(COMPARE_RESULT) + string(APPEND BASE_DEFCONFIG "-dirty") +endif() + set(DEQUOTELIST # NuttX "CONFIG_DEBUG_OPTLEVEL" # Custom debug level @@ -81,11 +89,16 @@ file(APPEND ${CONFIG_H} "#define CONFIG_y 1\n") file(APPEND ${CONFIG_H} "#define CONFIG_m 2\n\n") file(APPEND ${CONFIG_H} "/* General Definitions ***********************************/\n") +file(APPEND ${CONFIG_H} "#define CONFIG_BASE_DEFCONFIG \"${BASE_DEFCONFIG}\"\n") file(STRINGS ${CMAKE_BINARY_DIR}/.config ConfigContents) foreach(NameAndValue ${ConfigContents}) string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue}) string(REGEX MATCH "^CONFIG[^=]+" NAME ${NameAndValue}) + # skip BASE_DEFCONFIG here as it is handled above + if("${NAME}" STREQUAL "CONFIG_BASE_DEFCONFIG") + continue() + endif() string(REPLACE "${NAME}=" "" VALUE ${NameAndValue}) if(NAME AND NOT "${VALUE}" STREQUAL "") if(${VALUE} STREQUAL "y")