diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 2018eb0e8f..e9413be9af 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -267,7 +267,20 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) idf_build_set_property(SDKCONFIG_JSON_MENUS ${sdkconfig_json_menus}) idf_build_set_property(CONFIG_DIR ${config_dir}) - set(MENUCONFIG_CMD ${python} -m menuconfig) + # newer versions of esp-idf-kconfig renamed menuconfig to esp_menuconfig + # Order matters here, we want to use esp_menuconfig if it is available + execute_process( + COMMAND ${python} -c "import esp_menuconfig" + RESULT_VARIABLE ESP_MENUCONFIG_AVAILABLE + OUTPUT_QUIET ERROR_QUIET + ) + if(ESP_MENUCONFIG_AVAILABLE EQUAL 0) + set(MENUCONFIG_CMD ${python} -m esp_menuconfig) + else() + set(MENUCONFIG_CMD ${python} -m menuconfig) + endif() + + set(TERM_CHECK_CMD ${python} ${idf_path}/tools/check_term.py) if(NOT ${ARG_CREATE_MENUCONFIG_TARGET}) diff --git a/tools/ldgen/ldgen/sdkconfig.py b/tools/ldgen/ldgen/sdkconfig.py index 7899ae5f91..560a1c136c 100644 --- a/tools/ldgen/ldgen/sdkconfig.py +++ b/tools/ldgen/ldgen/sdkconfig.py @@ -1,15 +1,21 @@ # -# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 # -import kconfiglib +# In newer esp-idf-kconfig versions, kconfiglib module is renamed to esp_kconfiglib +# Order is important here, as we want to use esp_kconfiglib if available +try: + import esp_kconfiglib as kconfiglib +except ImportError: + import kconfiglib class SDKConfig: """ Evaluates conditional expressions based on the build's sdkconfig and Kconfig files. """ + def __init__(self, kconfig_file, sdkconfig_file): self.config = kconfiglib.Kconfig(kconfig_file) self.config.load_config(sdkconfig_file)