Bug 1546136 - dump cmake logs on command failures; r=firefox-build-system-reviewers,chmanchester
authorNathan Froyd <froydnj@mozilla.com>
Tue, 23 Apr 2019 19:44:55 +0000
changeset 530206 1949dd602a233f6529f563b88d5edfe48b7c77d1
parent 530205 da741134005204d8c52add0f2c3f10068dde6cd8
child 530207 27527aa560046fe68ccacfc96e5580351b4b51e7
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, chmanchester
bugs1546136
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546136 - dump cmake logs on command failures; r=firefox-build-system-reviewers,chmanchester CMake errors can be pretty opaque, especially if CMake is being run inside the Ninja build process. Let's try to surface those errors to make problems easier to debug. Differential Revision: https://phabricator.services.mozilla.com/D28360
build/build-clang/build-clang.py
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -27,17 +27,37 @@ def symlink(source, link_name):
     else:
         if os.path.isdir(source):
             # Fall back to copying the directory :(
             copy_tree(source, link_name)
 
 
 def check_run(args):
     print >> sys.stderr, ' '.join(args)
-    r = subprocess.call(args)
+    p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    # CMake `message(STATUS)` messages, as appearing in failed source code
+    # compiles, appear on stdout, so we only capture that.
+    (out, _) = p.communicate()
+    r = p.returncode
+    if r != 0:
+        cmake_output_re = re.compile("See also \"(.*/CMakeOutput.log)\"")
+        cmake_error_re = re.compile("See also \"(.*/CMakeError.log)\"")
+        output_match = cmake_output_re.search(out)
+        error_match = cmake_error_re.search(out)
+
+        print >> sys.stderr, out
+
+        def dump_file(log):
+            with open(log, 'rb') as f:
+                print >> sys.stderr, "\nContents of", log, "follow\n"
+                print >> sys.stderr, f.read()
+        if output_match:
+            dump_file(output_match.group(1))
+        if error_match:
+            dump_file(error_match.group(1))
     assert r == 0
 
 
 def run_in(path, args):
     d = os.getcwd()
     print >> sys.stderr, 'cd "%s"' % path
     os.chdir(path)
     check_run(args)