change: use esp_kconfiglib instead of kconfiglib in Python imports

This commit is contained in:
Jan Beran
2025-06-25 15:55:56 +02:00
parent 8448452e03
commit 806775f54e
2 changed files with 22 additions and 3 deletions

View File

@@ -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})

View File

@@ -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)