From a3fcd561838558d2491d5d3c877c111bee8e0d81 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 4 Jan 2022 22:15:16 +0000 Subject: [PATCH] Bug 1748373 - Don't print out the contents of CMake{Output,Error}.log. r=firefox-build-system-reviewers,mhentges When cmake fails during the clang build, we currently print out the contents of CMakeOutput.log and CMakeError.log because they may contain something useful to debug what happened. Unfortunately, because the treeherder log parser doesn't see the actual error, it reports the normal error that are part of the logs as being the errors causing the failure, the first one of which is a check whether malloc/malloc.h is a thing, which it is not, and that's normal. So instead of printing them out, we provide the files as artifacts. Differential Revision: https://phabricator.services.mozilla.com/D134999 --- build/build-clang/build-clang.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py index 28e9c813f11b..0ca3000bf05b 100755 --- a/build/build-clang/build-clang.py +++ b/build/build-clang/build-clang.py @@ -49,7 +49,7 @@ def check_run(args): sys.stdout.write(line.decode()) sys.stdout.flush() r = p.wait() - if r != 0: + if r != 0 and os.environ.get("UPLOAD_DIR"): cmake_output_re = re.compile(b'See also "(.*/CMakeOutput.log)"') cmake_error_re = re.compile(b'See also "(.*/CMakeError.log)"') @@ -62,16 +62,13 @@ def check_run(args): output_match = find_first_match(cmake_output_re) error_match = find_first_match(cmake_error_re) - def dump_file(log): - with open(log, "r", errors="replace") as f: - print("\nContents of", log, "follow\n", file=sys.stderr) - for line in f: - print(line, file=sys.stderr) - + upload_dir = os.environ["UPLOAD_DIR"].encode("utf-8") + if output_match or error_match: + mkdir_p(upload_dir) if output_match: - dump_file(output_match.group(1)) + shutil.copy2(output_match.group(1), upload_dir) if error_match: - dump_file(error_match.group(1)) + shutil.copy2(error_match.group(1), upload_dir) else: r = subprocess.call(args) assert r == 0