Bug 1520394 - Don't hard code log file name for old-configure. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 16 Jan 2019 20:29:15 +0000
changeset 514178 e1f95cea7f0cf24df86031ee1e8433ecf3d1667d
parent 514177 596f8d9346ece3e6815d1af5460e9557ca91aec3
child 514179 adc8ba2d499e62e33c50d3afacb1a14e1f2c4a38
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1520394 - Don't hard code log file name for old-configure. r=nalexander Instead, use the actual log file name as configured through python logging. This doesn't make a practical difference now, but will when subconfigure logs to the toplevel log. Depends on D16666 Differential Revision: https://phabricator.services.mozilla.com/D16667
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -71,30 +71,39 @@ def prepare_mozconfig(mozconfig):
         for key, (old, value) in mozconfig['vars']['modified'].items():
             items[key] = (value, 'modified')
         for t in ('env', 'vars'):
             for key in mozconfig[t]['removed'].keys():
                 items[key] = (None, 'removed ' + t)
         return items
+def config_log():
+    logger = logging.getLogger('moz.configure')
+    for handler in logger.handlers:
+        if isinstance(handler, logging.FileHandler):
+            return handler
 @depends('OLD_CONFIGURE', prepare_mozconfig, autoconf, check_build_environment,
-         shell, old_configure_assignments, build_project)
+         shell, old_configure_assignments, build_project, config_log)
 @imports(_from='__builtin__', _import='open')
 @imports(_from='__builtin__', _import='print')
 @imports(_from='__builtin__', _import='sorted')
 # Import getmtime without overwriting the sandbox os.path.
 @imports(_from='os.path', _import='getmtime')
 @imports(_from='os.path', _import='exists')
 @imports(_from='mozbuild.shellutil', _import='quote')
 def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
-                      old_configure_assignments, build_project):
+                      old_configure_assignments, build_project, config_log):
     # os.path.abspath in the sandbox will ensure forward slashes on Windows,
     # which is actually necessary because this path actually ends up literally
     # as $0, and backslashes there breaks autoconf's detection of the source
     # directory.
     old_configure = os.path.abspath(old_configure[0])
     if build_project == 'js':
         old_configure_dir = os.path.dirname(old_configure)
         if not old_configure_dir.endswith('/js/src'):
@@ -122,17 +131,21 @@ def prepare_configure(old_configure, moz
             shell, autoconf,
             '--localdir=%s' % os.path.dirname(old_configure),
             old_configure + '.in'])
         if not script:
             die('Generated old-configure is empty! Check that your autoconf 2.13 program works!')
         # Make old-configure append to config.log, where we put our own log.
         # This could be done with a m4 macro, but it's way easier this way
-        script = script.replace('>./config.log', '>>./config.log')
+        if config_log:
+            path = config_log.baseFilename
+        else:
+            path = '/dev/null'
+        script = script.replace('>./config.log', '>>%s' % path)
         with open(old_configure, 'wb') as fh:
     cmd = [shell, old_configure]
     with encoded_open('old-configure.vars', 'w') as out:
         log.debug('Injecting the following to old-configure:')
@@ -291,68 +304,66 @@ def prepare_configure_options(extra_old_
                 k, v = arg.split('=', 1)
                 extra_env[k] = v
     return namespace(options=options, extra_env=extra_env, all_options=all_options)
-@depends(prepare_configure, prepare_configure_options)
+@depends(prepare_configure, prepare_configure_options, config_log)
 @imports(_from='__builtin__', _import='compile')
 @imports(_from='__builtin__', _import='open')
 @imports(_from='mozbuild.shellutil', _import='quote')
 @imports(_from='mozbuild.shellutil', _import='split')
 @imports(_from='mozbuild.util', _import='encode')
-def old_configure(prepare_configure, prepare_configure_options):
+def old_configure(prepare_configure, prepare_configure_options, config_log):
     cmd = prepare_configure + prepare_configure_options.options
     extra_env = prepare_configure_options.extra_env
     env = dict(os.environ)
     if extra_env:
     # For debugging purpose, in case it's not what we'd expect.
     log.debug('Running %s', quote(*cmd))
     if extra_env:
         log.debug('with extra environment: %s',
                   ' '.join('%s=%s' % pair for pair in extra_env.iteritems()))
     # Our logging goes to config.log, the same file old.configure uses.
     # We can't share the handle on the file, so close it.
     logger = logging.getLogger('moz.configure')
-    config_log = None
-    for handler in logger.handlers:
-        if isinstance(handler, logging.FileHandler):
-            config_log = handler
-            handler.close()
-            logger.removeHandler(handler)
+    if config_log:
+        config_log.close()
+        logger.removeHandler(config_log)
-    log_size = os.path.getsize('config.log')
+        log_size = os.path.getsize(config_log.baseFilename)
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
     while True:
         line = proc.stdout.readline()
         if not line:
     ret = proc.wait()
     if ret:
         with log.queue_debug():
-            with encoded_open('config.log', 'r') as fh:
-                fh.seek(log_size)
-                for line in fh:
-                    log.debug(line.rstrip())
+            if config_log:
+                with encoded_open(config_log.baseFilename, 'r') as fh:
+                    fh.seek(log_size)
+                    for line in fh:
+                        log.debug(line.rstrip())
             log.error('old-configure failed')
     if config_log:
         # Create a new handler in append mode
         handler = logging.FileHandler(config_log.baseFilename, mode='a', delay=True)