|
|
@@ -233,6 +233,12 @@ class RunTool:
|
|
|
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
|
return ansi_escape.sub('', text)
|
|
|
|
|
|
+ def prepare_for_print(out: str) -> str:
|
|
|
+ if not output_stream.isatty():
|
|
|
+ # delete escape sequence if we printing in environments where ANSI coloring is disabled
|
|
|
+ return delete_ansi_escape(out)
|
|
|
+ return out
|
|
|
+
|
|
|
def print_progression(output: str) -> None:
|
|
|
# Print a new line on top of the previous line
|
|
|
sys.stdout.write('\x1b[K')
|
|
|
@@ -269,15 +275,8 @@ class RunTool:
|
|
|
output = await read_stream()
|
|
|
if not output:
|
|
|
break
|
|
|
- output_noescape = delete_ansi_escape(output)
|
|
|
- # Always remove escape sequences when writing the build log.
|
|
|
- output_file.write(output_noescape)
|
|
|
- # If idf.py output is redirected and the output stream is not a TTY,
|
|
|
- # strip the escape sequences as well.
|
|
|
- # (There shouldn't be any, but just in case.)
|
|
|
- if not output_stream.isatty():
|
|
|
- output = output_noescape
|
|
|
-
|
|
|
+ output = prepare_for_print(output)
|
|
|
+ output_file.write(output)
|
|
|
if self.force_progression and output[0] == '[' and '-v' not in self.args and output_stream.isatty():
|
|
|
# print output in progression way but only the progression related (that started with '[') and if verbose flag is not set
|
|
|
print_progression(output)
|
|
|
@@ -301,17 +300,11 @@ 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)()
|
|
|
|