Bug 1521284 - Don't hardcode config.log path in old-configure. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 21 Jan 2019 17:32:11 +0000
changeset 511879 39d0c50a2209e0f0c982b1d121765c9dc950e161
parent 511878 744ba6ab5e0cde764faaf12f79072b3dd2681a99
child 511880 ad20edb20e58f913e922dff27005fe088903e5e9
push id10563
push userarchaeopteryx@coole-files.de
push dateThu, 24 Jan 2019 17:31:37 +0000
treeherdermozilla-beta@c0b43d952f70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1521284
milestone66.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 1521284 - Don't hardcode config.log path in old-configure. r=nalexander Because old-configure is only refreshed when, essentially, old-configure.in changes, hardcoded (absolute) paths don't necessarily match the build environment of the current build. So instead, use an environment variable that we pass from python configure when invoking old-configure. Also do dummy changes to old-configure.in so that old-configure is refreshed at least once to get the environment-based value. Differential Revision: https://phabricator.services.mozilla.com/D17077
build/moz.configure/old.configure
js/src/old-configure.in
old-configure.in
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -71,39 +71,30 @@ 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
 
 
-@dependable
-@imports('logging')
-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, config_log)
+         shell, old_configure_assignments, build_project)
 @imports(_from='__builtin__', _import='open')
 @imports(_from='__builtin__', _import='print')
 @imports(_from='__builtin__', _import='sorted')
 @imports('glob')
 @imports('itertools')
 @imports('subprocess')
 # 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, config_log):
+                      old_configure_assignments, build_project):
     # 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'):
@@ -131,21 +122,17 @@ 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
-        if config_log:
-            path = config_log.baseFilename
-        else:
-            path = '/dev/null'
-        script = script.replace('>./config.log', '>>%s' % quote(normsep(path)))
+        script = script.replace('>./config.log', '>>${CONFIG_LOG=./config.log}')
 
         with open(old_configure, 'wb') as fh:
             fh.write(script)
 
     cmd = [shell, old_configure]
     with encoded_open('old-configure.vars', 'w') as out:
         log.debug('Injecting the following to old-configure:')
 
@@ -304,49 +291,53 @@ def prepare_configure_options(extra_old_
                 options.append(arg)
             else:
                 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, config_log)
+@depends(prepare_configure, prepare_configure_options)
 @imports(_from='__builtin__', _import='compile')
 @imports(_from='__builtin__', _import='open')
 @imports('logging')
 @imports('os')
 @imports('subprocess')
 @imports('sys')
 @imports('types')
 @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, config_log):
+def old_configure(prepare_configure, prepare_configure_options):
     cmd = prepare_configure + prepare_configure_options.options
     extra_env = prepare_configure_options.extra_env
 
     env = dict(os.environ)
     if extra_env:
         env.update(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')
-    if config_log:
-        config_log.close()
-        logger.removeHandler(config_log)
-
-        log_size = os.path.getsize(config_log.baseFilename)
+    config_log = None
+    for handler in logger.handlers:
+        if isinstance(handler, logging.FileHandler):
+            config_log = handler
+            config_log.close()
+            logger.removeHandler(config_log)
+            env['CONFIG_LOG'] = config_log.baseFilename
+            log_size = os.path.getsize(config_log.baseFilename)
+            break
 
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                             env=encode(env))
     while True:
         line = proc.stdout.readline()
         if not line:
             break
         log.info(line.rstrip())
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -8,17 +8,17 @@ dnl Process this file with autoconf to p
 dnl ========================================================
 AC_PREREQ(2.13)
 AC_INIT(js/src/jsapi.h)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
 
 dnl ========================================================
 dnl =
-dnl = Don't change the following lines.  Doing so breaks:
+dnl = Don't change the following lines. Doing so breaks:
 dnl =
 dnl = CFLAGS="-foo" ./configure
 dnl =
 dnl ========================================================
 CFLAGS="${CFLAGS=}"
 CPPFLAGS="${CPPFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"
--- a/old-configure.in
+++ b/old-configure.in
@@ -8,17 +8,17 @@ dnl Process this file with autoconf to p
 dnl ========================================================
 AC_PREREQ(2.13)
 AC_INIT(config/config.mk)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
 
 dnl ========================================================
 dnl =
-dnl = Don't change the following lines.  Doing so breaks:
+dnl = Don't change the following lines. Doing so breaks:
 dnl =
 dnl = CFLAGS="-foo" ./configure
 dnl =
 dnl ========================================================
 CFLAGS="${CFLAGS=}"
 CPPFLAGS="${CPPFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"