Bug 1416490 - Ensure environment variables that are configure options are passed from configure to old-configure. draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 13 Nov 2017 23:33:35 -0800
changeset 697784 c64943406acc4cafdd75c6f04b4d1ccbb5f8d661
parent 697783 1c8294de969c1ed67f7ac43c2701ac057f3f7f82
child 697785 f052355d72c5a41dd84bb83ea43a98c02a57a20f
push id89090
push usercmanchester@mozilla.com
push dateTue, 14 Nov 2017 17:10:26 +0000
bugs1416490
milestone59.0a1
Bug 1416490 - Ensure environment variables that are configure options are passed from configure to old-configure. MozReview-Commit-ID: GFP8bahu1bb
build/moz.configure/old.configure
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -301,46 +301,46 @@ def old_configure_options(*options):
 @imports(_from='__builtin__', _import='compile')
 @imports(_from='__builtin__', _import='open')
 @imports('logging')
 @imports('os')
 @imports('subprocess')
 @imports('sys')
 @imports(_from='mozbuild.shellutil', _import='quote')
 @imports(_from='mozbuild.shellutil', _import='split')
+@imports(_from='mozbuild.util', _import='encode')
 def old_configure(prepare_configure, extra_old_configure_args, all_options,
                   *options):
     cmd = prepare_configure
 
     # old-configure only supports the options listed in @old_configure_options
     # so we don't need to pass it every single option we've been passed. Only
     # the ones that are not supported by python configure need to.
     cmd += [
         value.format(name)
         for name, value in zip(all_options, options)
         if value.origin != 'default'
     ]
 
-    env = os.environ
+    env = dict(os.environ)
     extra_env = {}
 
     # We also pass it the options from js/moz.configure so that it can pass
     # them down to js/src/configure. Note this list is empty when running
     # js/src/configure, in which case we don't need to pass those options
     # to old-configure since old-configure doesn't handle them anyways.
     if extra_old_configure_args:
         for arg in extra_old_configure_args:
             if arg.startswith('-'):
                 cmd.append(arg)
             else:
                 k, v = arg.split('=', 1)
                 extra_env[k] = v
 
     if extra_env:
-        env = dict(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()))
 
@@ -351,17 +351,17 @@ def old_configure(prepare_configure, ext
     logger = logging.getLogger('moz.configure')
     for handler in logger.handlers:
         if isinstance(handler, logging.FileHandler):
             handler.close()
             logger.removeHandler(handler)
 
     log_size = os.path.getsize('config.log')
 
-    ret = subprocess.call(cmd)
+    ret = subprocess.call(cmd, env=encode(env))
     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())
             log.error('old-configure failed')
         sys.exit(ret)