menuconfig: fix the MENUCONFIG_STYLE encoding issue and CLI env issue

1. Call cli with explicit argv

When using debugging tools like `pydbg.py --some_arg idf.py -G Ninga
build`, those tools usually call the python script with sys.argv
modified to correct value. But if the cli is called with argv blank, the
cli will get the argv again, and finally get the original command line,
which is incorrect for debugging.

2. Encode the style unicode string back to ascii in menuconfig cmd

On Windows MSYS python2.7, the unicode string set in os.environ will
cause the subprocess creating to fail. All os.environ values should be
strings.
This commit is contained in:
michael 2019-12-04 17:55:23 +08:00 committed by Michael (XIAO Xufeng)
parent d24fe09356
commit 3e55baea90
2 changed files with 4 additions and 2 deletions

View file

@ -677,7 +677,7 @@ def init_cli(verbose_output=None):
def main():
checks_output = check_environment()
cli = init_cli(verbose_output=checks_output)
cli(prog_name=PROG)
cli(sys.argv[1:], prog_name=PROG)
def _valid_unicode_config():

View file

@ -35,7 +35,9 @@ def action_extensions(base_actions, project_path):
Menuconfig target is build_target extended with the style argument for setting the value for the environment
variable.
"""
os.environ['MENUCONFIG_STYLE'] = style
# The subprocess lib cannot accept environment variables as "unicode" . This is a problem
# only in Python 2.
os.environ['MENUCONFIG_STYLE'] = style.encode(sys.getfilesystemencoding() or 'utf-8')
build_target(target_name, ctx, args)
def fallback_target(target_name, ctx, args):