Skip to content

Commit 806775f

Browse files
committed
change: use esp_kconfiglib instead of kconfiglib in Python imports
1 parent 8448452 commit 806775f

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tools/cmake/kconfig.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,20 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
267267
idf_build_set_property(SDKCONFIG_JSON_MENUS ${sdkconfig_json_menus})
268268
idf_build_set_property(CONFIG_DIR ${config_dir})
269269

270-
set(MENUCONFIG_CMD ${python} -m menuconfig)
270+
# newer versions of esp-idf-kconfig renamed menuconfig to esp_menuconfig
271+
# Order matters here, we want to use esp_menuconfig if it is available
272+
execute_process(
273+
COMMAND ${python} -c "import esp_menuconfig"
274+
RESULT_VARIABLE ESP_MENUCONFIG_AVAILABLE
275+
OUTPUT_QUIET ERROR_QUIET
276+
)
277+
if(ESP_MENUCONFIG_AVAILABLE EQUAL 0)
278+
set(MENUCONFIG_CMD ${python} -m esp_menuconfig)
279+
else()
280+
set(MENUCONFIG_CMD ${python} -m menuconfig)
281+
endif()
282+
283+
271284
set(TERM_CHECK_CMD ${python} ${idf_path}/tools/check_term.py)
272285

273286
if(NOT ${ARG_CREATE_MENUCONFIG_TARGET})

tools/ldgen/ldgen/sdkconfig.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
#
2-
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6-
import kconfiglib
6+
# In newer esp-idf-kconfig versions, kconfiglib module is renamed to esp_kconfiglib
7+
# Order is important here, as we want to use esp_kconfiglib if available
8+
try:
9+
import esp_kconfiglib as kconfiglib
10+
except ImportError:
11+
import kconfiglib
712

813

914
class SDKConfig:
1015
"""
1116
Evaluates conditional expressions based on the build's sdkconfig and Kconfig files.
1217
"""
18+
1319
def __init__(self, kconfig_file, sdkconfig_file):
1420
self.config = kconfiglib.Kconfig(kconfig_file)
1521
self.config.load_config(sdkconfig_file)

0 commit comments

Comments
 (0)