mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix: cleanup after dropping curses from menuconfig
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Checks for the content of environment variable TERM to use with the Python- and curses-based menuconfig. It is
|
||||
# not implemented in shell so calling this script could not use some other shell environment where TERM is set
|
||||
# differently. Implemented here so it could be checked at one place for make and cmake as well.
|
||||
if sys.platform == 'win32' and 'MSYSTEM' not in os.environ:
|
||||
# no TERM is used in Windows command line
|
||||
exit(0)
|
||||
|
||||
term = os.environ.get('TERM', None)
|
||||
|
||||
if term is None:
|
||||
print('WARNING: The TERM environment variable is not defined. The curses-based menuconfig '
|
||||
'will probably fail to run. Please consult the documentation of your terminal to set it up.')
|
||||
else:
|
||||
if term.endswith('256color') or term in ['alacritty']:
|
||||
print('TERM environment variable is set to "{}"'.format(term))
|
||||
else:
|
||||
print('WARNING: Menuconfig may fail because of the TERM environment variable is set '
|
||||
'to "{}". Please consult the documentation of your terminal to set it up. '
|
||||
'Some good, proved to been working setups include xterm-256color, screen-256color, '
|
||||
'rxvt-unicode-256color, alacritty.'.format(term))
|
||||
@@ -1,6 +1,5 @@
|
||||
tools/ble/**/*
|
||||
tools/bt/**/*
|
||||
tools/check_term.py
|
||||
tools/ci/*exclude*.txt
|
||||
tools/ci/astyle-rules.yml
|
||||
tools/ci/check_*.py
|
||||
|
||||
@@ -294,8 +294,6 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
||||
__check_python_package_min_version(
|
||||
${python} esp-idf-kconfig "${MENUCONFIG_INLINE_MIN_KCONFIG_VERSION}" MENUCONFIG_INLINE_SUPPORTED)
|
||||
|
||||
set(TERM_CHECK_CMD ${python} ${idf_path}/tools/check_term.py)
|
||||
|
||||
if(NOT ${ARG_CREATE_MENUCONFIG_TARGET})
|
||||
return()
|
||||
endif()
|
||||
@@ -313,7 +311,6 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
||||
# This is not necessary under normal circumstances, but if the files are manually removed,
|
||||
# it may be possible to regenerate them.
|
||||
COMMAND ${prepare_kconfig_files_command}
|
||||
COMMAND ${TERM_CHECK_CMD}
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
"COMPONENT_KCONFIGS_SOURCE_FILE=${kconfigs_path}"
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${kconfigs_projbuild_path}"
|
||||
@@ -344,8 +341,7 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
||||
--env "IDF_INIT_VERSION=${idf_init_version}"
|
||||
--env "KCONFIG_REPORT_VERBOSITY=quiet"
|
||||
--dont-write-deprecated
|
||||
--output config ${sdkconfig}
|
||||
COMMAND ${TERM_CHECK_CMD}
|
||||
--output config ${sdkconfig} # Do NOT regenerate the rest of the config files!
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
"COMPONENT_KCONFIGS_SOURCE_FILE=${kconfigs_path}"
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${kconfigs_projbuild_path}"
|
||||
@@ -357,6 +353,8 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
||||
"IDF_MINIMAL_BUILD=${idf_minimal_build}"
|
||||
${MENUCONFIG_CMD} ${root_kconfig}
|
||||
USES_TERMINAL
|
||||
# additional run of kconfgen ensures that the deprecated options will be inserted into config files
|
||||
# (for backward compatibility)
|
||||
COMMAND ${kconfgen_basecommand}
|
||||
--env "IDF_TARGET=${idf_target}"
|
||||
--env "IDF_TOOLCHAIN=${idf_toolchain}"
|
||||
|
||||
@@ -875,10 +875,12 @@ function(idf_create_menuconfig executable)
|
||||
|
||||
if(_menuconfig_inline_ok)
|
||||
add_custom_target("${ARG_TARGET}"
|
||||
# Ensure kconfig.in and kconfig_projbuild.in are present and up to date.
|
||||
# This is not necessary under normal circumstances, but if the files are manually removed,
|
||||
# it may be possible to regenerate them.
|
||||
COMMAND ${python} "${idf_path}/tools/kconfig_new/prepare_kconfig_files.py"
|
||||
--list-separator=semicolon
|
||||
--env-file "${config_env_dir}/config.env"
|
||||
COMMAND ${python} "${idf_path}/tools/check_term.py"
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
"COMPONENT_KCONFIGS_SOURCE_FILE=${config_env_dir}/kconfigs.in"
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${config_env_dir}/kconfigs_projbuild.in"
|
||||
@@ -906,6 +908,9 @@ function(idf_create_menuconfig executable)
|
||||
message(WARNING "esp-idf-kconfig >= ${MENUCONFIG_INLINE_MIN_KCONFIG_VERSION} is required "
|
||||
"for the optimised menuconfig target. Please update your Python packages by re-running the install script.")
|
||||
add_custom_target("${ARG_TARGET}"
|
||||
# Ensure kconfig.in and kconfig_projbuild.in are present and up to date.
|
||||
# This is not necessary under normal circumstances, but if the files are manually removed,
|
||||
# it may be possible to regenerate them.
|
||||
COMMAND ${python} "${idf_path}/tools/kconfig_new/prepare_kconfig_files.py"
|
||||
--list-separator=semicolon
|
||||
--env-file "${config_env_dir}/config.env"
|
||||
@@ -918,7 +923,6 @@ function(idf_create_menuconfig executable)
|
||||
--dont-write-deprecated
|
||||
--output config "${sdkconfig}"
|
||||
--env-file "${config_env_dir}/config.env"
|
||||
COMMAND ${python} "${idf_path}/tools/check_term.py"
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
"COMPONENT_KCONFIGS_SOURCE_FILE=${config_env_dir}/kconfigs.in"
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${config_env_dir}/kconfigs_projbuild.in"
|
||||
|
||||
@@ -145,25 +145,20 @@ def action_extensions(base_actions: dict, project_path: str) -> Any:
|
||||
build_target('help', ctx, args)
|
||||
|
||||
def menuconfig(target_name: str, ctx: Context, args: PropertyDict, style: str) -> None:
|
||||
"""
|
||||
Menuconfig target is build_target extended with the style argument for setting the value for the environment
|
||||
variable.
|
||||
"""
|
||||
if sys.platform != 'win32':
|
||||
try:
|
||||
import curses # noqa: F401
|
||||
except ImportError:
|
||||
raise FatalError(
|
||||
'\n'.join(
|
||||
[
|
||||
'',
|
||||
"menuconfig failed to import the standard Python 'curses' library.",
|
||||
'Please re-run the install script which might be able to fix the issue.',
|
||||
]
|
||||
)
|
||||
)
|
||||
os.environ['MENUCONFIG_STYLE'] = style
|
||||
"""Run the menuconfig configuration tool."""
|
||||
args.no_hints = True
|
||||
if style == 'dark':
|
||||
style = 'textual-dark'
|
||||
elif style == 'light':
|
||||
style = 'textual-light'
|
||||
|
||||
# Compatibility with legacy names
|
||||
if style in ['aquatic', 'monochrome', 'default']:
|
||||
print('NOTE: Legacy menuconfig styles are deprecated. Using dark style instead.')
|
||||
style = 'textual-dark'
|
||||
|
||||
if style:
|
||||
os.environ['MENUCONFIG_STYLE'] = style
|
||||
build_target(target_name, ctx, args)
|
||||
|
||||
def save_defconfig(target_name: str, ctx: Context, args: PropertyDict, add_menu_labels: bool) -> None:
|
||||
@@ -615,17 +610,15 @@ def action_extensions(base_actions: dict, project_path: str) -> Any:
|
||||
{
|
||||
'names': ['--style', '--color-scheme', 'style'],
|
||||
'help': (
|
||||
'Menuconfig style.\n'
|
||||
'Menuconfig color scheme.\n'
|
||||
'The built-in styles include:\n\n'
|
||||
'- default - a yellowish theme,\n\n'
|
||||
'- monochrome - a black and white theme, or\n\n'
|
||||
'- aquatic - a blue theme.\n\n'
|
||||
'It is possible to customize these themes further'
|
||||
' as it is described in the Color schemes section of the kconfiglib documentation.\n'
|
||||
'The default value is "aquatic".'
|
||||
'- dark (default)\n\n'
|
||||
'- light\n\n'
|
||||
'More styles can be found in menuconfig TUI under [p]alette - Themes.\n\n'
|
||||
'Legacy names are still accepted, but will map to default style.'
|
||||
),
|
||||
'envvar': 'MENUCONFIG_STYLE',
|
||||
'default': 'aquatic',
|
||||
'default': '',
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
@@ -2748,13 +2748,6 @@ def action_install_python_env(args): # type: ignore
|
||||
# Reinstallation of the virtual environment could help if pip was installed for the main Python
|
||||
reinstall = True
|
||||
|
||||
if sys.platform != 'win32':
|
||||
try:
|
||||
subprocess.check_call([virtualenv_python, '-c', 'import curses'], stdout=sys.stdout, stderr=sys.stderr)
|
||||
except subprocess.CalledProcessError:
|
||||
warn('curses can not be imported, new virtual environment will be created.')
|
||||
reinstall = True
|
||||
|
||||
if reinstall and os.path.exists(idf_python_env_path):
|
||||
warn(f'Removing the existing Python environment in {idf_python_env_path}')
|
||||
shutil.rmtree(idf_python_env_path)
|
||||
|
||||
Reference in New Issue
Block a user