diff --git a/tools/idf_py_actions/constants.py b/tools/idf_py_actions/constants.py index 18ebe3e7c2..19e9e99587 100644 --- a/tools/idf_py_actions/constants.py +++ b/tools/idf_py_actions/constants.py @@ -12,7 +12,6 @@ GENERATORS: Dict[str, Union[str, Dict, list]] = collections.OrderedDict([ # - dry_run: command to run in dry run mode # - verbose_flag: verbose flag # - force_progression: one liner status of the progress - # - envvar: environment variables ('Ninja', { 'command': ['ninja'], 'version': ['ninja', '--version'], @@ -20,7 +19,6 @@ GENERATORS: Dict[str, Union[str, Dict, list]] = collections.OrderedDict([ 'verbose_flag': '-v', # as opposed to printing the status updates each in a in new line 'force_progression': True, - 'envvar': {} }), ]) @@ -30,9 +28,7 @@ if os.name != 'nt': 'version': [MAKE_CMD, '--version'], 'dry_run': [MAKE_CMD, '-n'], 'verbose_flag': 'VERBOSE=1', - 'force_progression': False, - # CLICOLOR_FORCE if set forcing make to print ANSI escape sequence - 'envvar': {'CLICOLOR_FORCE': '1'}} + 'force_progression': False} URL_TO_DOC = 'https://docs.espressif.com/projects/esp-idf' diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 2eecd1d2b1..854ca48a10 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -300,11 +300,17 @@ def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None, env = {} generator_cmd = GENERATORS[args.generator]['command'] - env.update(GENERATORS[args.generator]['envvar']) if args.verbose: generator_cmd += [GENERATORS[args.generator]['verbose_flag']] + # By default, GNU Make and Ninja strip away color escape sequences when they see that their stdout is redirected. + # If idf.py's stdout is not redirected, the final output is a TTY, so we can tell Make/Ninja to disable stripping + # of color escape sequences. (Requires Ninja v1.9.0 or later.) + if sys.stdout.isatty(): + if 'CLICOLOR_FORCE' not in env: + env['CLICOLOR_FORCE'] = '1' + RunTool(generator_cmd[0], generator_cmd + [target_name], args.build_dir, env, custom_error_handler, hints=not args.no_hints, force_progression=force_progression, interactive=interactive)()