From e248b36676faaecc223c7c95467996be4af015d3 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Sat, 16 Aug 2025 13:23:50 +0200 Subject: [PATCH] feat(cmakev2/kconfig): use cmakev2 specific config_buildv2.env.in The current config.env.in template cannot be easily extended and shared between cmakev1 and cmakev2. Although the root Kconfig is shared and sources COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE and COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE, these environment variables cannot be set to empty strings. This issue arises unless we also adjust cmakev1 and esp-docs, which use prepare_kconfig_files.py, to properly set COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE and COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE. If an environment variable is set to an empty string and sourced in Kconfig, kconfgen will expand the variable with expandvars(), resulting in an empty value. This expanded variable is then appended to the root Kconfig or the currently processed Kconfig directory path, depending on whether osource or orsource is used, and passed to iglob. The iglog will return the directory as a result, and when Kconfig attempts to open the file, it will encounter an error because it is a directory. To resolve this issue and enable sharing of the root Kconfig file, a new config_buildv2.env.in template has been added, which includes environment variables for the excluded components. For cmakev1, kconfgen will encounter the osource command for COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE. Since this variable is not defined in config.env.in, expandvars() will return the environment variable name instead of expanding it, and iglob will not match anything. Because osource is used for excluded components, the non-existent file for osource will be skipped. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/kconfig.cmake | 2 +- tools/kconfig_new/config.env.in | 6 +----- tools/kconfig_new/config_buildv2.env.in | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 tools/kconfig_new/config_buildv2.env.in diff --git a/tools/cmakev2/kconfig.cmake b/tools/cmakev2/kconfig.cmake index f62f2977654..8f5d9a6b140 100644 --- a/tools/cmakev2/kconfig.cmake +++ b/tools/cmakev2/kconfig.cmake @@ -338,7 +338,7 @@ function(__create_config_env_file env_path) idf_build_set_property(__IDF_ENV_FPGA "${idf_env_fpga}") # Get the config.env.in template path - set(template_path "${idf_path}/tools/kconfig_new/config.env.in") + set(template_path "${idf_path}/tools/kconfig_new/config_buildv2.env.in") if(NOT EXISTS "${template_path}") idf_die("Kconfig environment template file not found at ${template_path}") endif() diff --git a/tools/kconfig_new/config.env.in b/tools/kconfig_new/config.env.in index 51245f6be95..962f02e4b86 100644 --- a/tools/kconfig_new/config.env.in +++ b/tools/kconfig_new/config.env.in @@ -2,15 +2,11 @@ "COMPONENT_KCONFIGS": "${kconfigs}", "COMPONENT_KCONFIGS_PROJBUILD": "${kconfig_projbuilds}", "COMPONENT_SDKCONFIG_RENAMES": "${sdkconfig_renames}", - "COMPONENT_KCONFIGS_EXCLUDED": "${kconfigs_excluded}", - "COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED": "${kconfigs_projbuild_excluded}", "IDF_TARGET": "${idf_target}", "IDF_TOOLCHAIN": "${idf_toolchain}", "IDF_VERSION": "$ENV{IDF_VERSION}", "IDF_ENV_FPGA": "${idf_env_fpga}", "IDF_PATH": "${idf_path}", "COMPONENT_KCONFIGS_SOURCE_FILE": "${kconfigs_path}", - "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE": "${kconfigs_projbuild_path}", - "COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE": "${kconfigs_excluded_path}", - "COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE": "${kconfigs_projbuild_excluded_path}" + "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE": "${kconfigs_projbuild_path}" } diff --git a/tools/kconfig_new/config_buildv2.env.in b/tools/kconfig_new/config_buildv2.env.in new file mode 100644 index 00000000000..51245f6be95 --- /dev/null +++ b/tools/kconfig_new/config_buildv2.env.in @@ -0,0 +1,16 @@ +{ + "COMPONENT_KCONFIGS": "${kconfigs}", + "COMPONENT_KCONFIGS_PROJBUILD": "${kconfig_projbuilds}", + "COMPONENT_SDKCONFIG_RENAMES": "${sdkconfig_renames}", + "COMPONENT_KCONFIGS_EXCLUDED": "${kconfigs_excluded}", + "COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED": "${kconfigs_projbuild_excluded}", + "IDF_TARGET": "${idf_target}", + "IDF_TOOLCHAIN": "${idf_toolchain}", + "IDF_VERSION": "$ENV{IDF_VERSION}", + "IDF_ENV_FPGA": "${idf_env_fpga}", + "IDF_PATH": "${idf_path}", + "COMPONENT_KCONFIGS_SOURCE_FILE": "${kconfigs_path}", + "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE": "${kconfigs_projbuild_path}", + "COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE": "${kconfigs_excluded_path}", + "COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE": "${kconfigs_projbuild_excluded_path}" +}