Bug 1369658 - Print out subconfigure output while it runs. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 02 Jun 2017 17:13:06 +0900
changeset 410202 372bdca82f66d8dc63f66890248fc6935c19e4ce
parent 410201 a784646bf7be61e19fc345a5eb30fdc5c326ee62
child 410203 8fe7c30a22028584204bc88fe7c2bd277c0a43a2
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1369658
milestone55.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 1369658 - Print out subconfigure output while it runs. r=gps Now that subconfigure don't run in parallel, we don't need to care that their output can be interleaved, so print it out while the subconfigure executes.
build/subconfigure.py
--- a/build/subconfigure.py
+++ b/build/subconfigure.py
@@ -234,19 +234,32 @@ def prepare(srcdir, objdir, shell, args)
     with open(data_file, 'wb') as f:
         pickle.dump(data, f)
 
 
 def prefix_lines(text, prefix):
     return ''.join('%s> %s' % (prefix, line) for line in text.splitlines(True))
 
 
+def execute_and_prefix(*args, **kwargs):
+    prefix = kwargs['prefix']
+    del kwargs['prefix']
+    proc = subprocess.Popen(*args, stdout=subprocess.PIPE,
+                            stderr=subprocess.STDOUT, **kwargs)
+    while True:
+        line = proc.stdout.readline()
+        if not line:
+            break
+        print prefix_lines(line.rstrip(), prefix)
+        sys.stdout.flush()
+    return proc.wait()
+
+
 def run(objdir):
     ret = 0
-    output = ''
 
     with open(os.path.join(objdir, CONFIGURE_DATA), 'rb') as f:
         data = pickle.load(f)
 
     data['objdir'] = objdir
 
     cache_file = data['cache-file']
     cleared_cache = True
@@ -312,21 +325,20 @@ def run(objdir):
 
         # Pass --no-create to configure so that it doesn't run config.status.
         # We're going to run it ourselves.
         command += ['--no-create']
 
         print prefix_lines('configuring', relobjdir)
         print prefix_lines('running %s' % ' '.join(command[:-1]), relobjdir)
         sys.stdout.flush()
-        try:
-            output += subprocess.check_output(command,
-                stderr=subprocess.STDOUT, cwd=objdir, env=data['env'])
-        except subprocess.CalledProcessError as e:
-            return relobjdir, e.returncode, e.output
+        returncode = execute_and_prefix(command, cwd=objdir, env=data['env'],
+                                        prefix=relobjdir)
+        if returncode:
+            return returncode
 
         # Leave config.status with a new timestamp if configure is newer than
         # its original mtime.
         if config_status and os.path.getmtime(configure) <= config_status.mtime:
             config_status.update_time()
 
     # Only run config.status if one of the following is true:
     # - config.status changed or did not exist
@@ -346,28 +358,23 @@ def run(objdir):
             if not os.path.exists(t) or \
                     os.path.getmtime(f) < os.path.getmtime(t):
                 skip_config_status = False
 
     if not skip_config_status:
         if skip_configure:
             print prefix_lines('running config.status', relobjdir)
             sys.stdout.flush()
-        try:
-            output += subprocess.check_output([data['shell'], '-c',
-                './config.status'], stderr=subprocess.STDOUT, cwd=objdir,
-                env=data['env'])
-        except subprocess.CalledProcessError as e:
-            ret = e.returncode
-            output += e.output
+        ret = execute_and_prefix([data['shell'], '-c', './config.status'],
+                                 cwd=objdir, env=data['env'], prefix=relobjdir)
 
         for f in contents:
             f.update_time()
 
-    return relobjdir, ret, output
+    return ret
 
 
 def subconfigure(args):
     parser = argparse.ArgumentParser()
     parser.add_argument('--list', type=str,
         help='File containing a list of subconfigures to run')
     parser.add_argument('--skip', type=str,
         help='File containing a list of Subconfigures to skip')
@@ -381,19 +388,17 @@ def subconfigure(args):
         skips = set(open(args.skip, 'rb').read().splitlines())
         subconfigures = [s for s in subconfigures if s not in skips]
 
     if not subconfigures:
         return 0
 
     ret = 0
     for subconfigure in subconfigures:
-        relobjdir, returncode, output = run(subconfigure)
-        print prefix_lines(output, relobjdir)
-        sys.stdout.flush()
+        returncode = run(subconfigure)
         ret = max(returncode, ret)
         if ret:
             break
     return ret
 
 
 def main(args):
     if args[0] != '--prepare':