Bug 1520377 - Inline subconfigure.prepare and simplify. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 16 Jan 2019 23:29:19 +0000
changeset 514173 939c78a89e7d29fda19d764e110bacca71f48e60
parent 514172 e0fd6ca971ae522dd9398d49f564fe3f7263112b
child 514174 e96f2ef974594bd4302b3d2d4cc00822ca2cca3e
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)
reviewersnalexander
bugs1520377
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 1520377 - Inline subconfigure.prepare and simplify. r=nalexander Depends on D16644 Differential Revision: https://phabricator.services.mozilla.com/D16645
build/subconfigure.py
js/sub.configure
deleted file mode 100644
--- a/build/subconfigure.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This script is used to capture the content of config.status-generated
-# files and subsequently restore their timestamp if they haven't changed.
-
-import argparse
-import errno
-import os
-import subprocess
-import sys
-import pickle
-
-import mozpack.path as mozpath
-
-
-CONFIGURE_DATA = 'configure.pkl'
-
-
-def prepare(srcdir, objdir, args):
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--cache-file', type=str)
-
-    data_file = os.path.join(objdir, CONFIGURE_DATA)
-    previous_args = None
-    if os.path.exists(data_file):
-        with open(data_file, 'rb') as f:
-            data = pickle.load(f)
-            previous_args = data['args']
-
-    args, others = parser.parse_known_args(args)
-
-    data = {
-        'args': others,
-        'srcdir': srcdir,
-        'objdir': objdir,
-        'env': os.environ,
-    }
-
-    if args.cache_file:
-        data['cache-file'] = mozpath.normpath(mozpath.join(os.getcwd(),
-                                                           args.cache_file))
-    else:
-        data['cache-file'] = mozpath.join(objdir, 'config.cache')
-
-    if previous_args is not None:
-        data['previous-args'] = previous_args
-
-    try:
-        os.makedirs(objdir)
-    except OSError as e:
-        if e.errno != errno.EEXIST:
-            raise
-
-    with open(data_file, 'wb') as f:
-        pickle.dump(data, f)
-
-    return data
--- a/js/sub.configure
+++ b/js/sub.configure
@@ -1,20 +1,22 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 @depends(check_build_environment, prepare_configure_options, prepare_mozconfig,
          old_configure, old_configure_assignments, '--cache-file')
+@imports('errno')
 @imports('itertools')
 @imports('logging')
 @imports('os')
-@imports('subconfigure')
+@imports('pickle')
 @imports('subprocess')
 @imports('sys')
+@imports(_from='__builtin__', _import='OSError')
 @imports(_from='__builtin__', _import='open')
 @imports(_from='__builtin__', _import='object')
 @imports(_from='mozbuild.configure.util', _import='ConfigureOutputHandler')
 @imports(_from='mozbuild.util', _import='encode')
 def js_subconfigure(build_env, prepare_configure_options, mozconfig,
                     old_configure, old_configure_assignments, cache_file):
 
     class PrefixOutput(object):
@@ -101,26 +103,38 @@ def js_subconfigure(build_env, prepare_c
                 not mozconfig[var][1].startswith('removed'):
             value = mozconfig[var][0]
         else:
             continue
         if isinstance(value, list):
             value = ' '.join(value)
         environ[var] = value
 
-    options += [
-        'JS_STANDALONE=',
-        '--cache-file=%s' % (cache_file or './config.cache'),
-    ]
+    options.append('JS_STANDALONE=')
+
     srcdir = os.path.join(build_env.topsrcdir, 'js', 'src')
     objdir = os.path.join(build_env.topobjdir, 'js', 'src')
-    data = subconfigure.prepare(srcdir, objdir, options)
+
+    data_file = os.path.join(objdir, 'configure.pkl')
+    previous_args = None
+    if os.path.exists(data_file):
+        with open(data_file, 'rb') as f:
+            previous_args = pickle.load(f)
 
-    # subconfigure.prepare does some normalization so use the value it returned.
-    cache_file = data['cache-file']
+    cache_file = cache_file or './config.cache'
+    cache_file = os.path.join(build_env.topobjdir, cache_file)
+
+    try:
+        os.makedirs(objdir)
+    except OSError as e:
+        if e.errno != errno.EEXIST:
+            raise
+
+    with open(data_file, 'wb') as f:
+        pickle.dump(options, f)
 
     # Only run configure if one of the following is true:
     # - config.status doesn't exist
     # - config.status is older than an input to configure
     # - the configure arguments changed
     configure = os.path.join(srcdir, 'old-configure')
     config_status_path = os.path.join(objdir, 'config.status')
     skip_configure = True
@@ -131,17 +145,17 @@ def js_subconfigure(build_env, prepare_c
         if not os.path.exists(config_status_deps):
             skip_configure = False
         else:
             with open(config_status_deps, 'r') as fh:
                 dep_files = fh.read().splitlines() + [configure]
             if (any(not os.path.exists(f) or
                     (os.path.getmtime(config_status_path) < os.path.getmtime(f))
                     for f in dep_files) or
-                data.get('previous-args', data['args']) != data['args']):
+                ((previous_args or options) != options)):
                 skip_configure = False
 
     if not skip_configure:
         # Because configure is a shell script calling a python script
         # calling a shell script, on Windows, with msys screwing the
         # environment, we lose the benefits from our own efforts in this
         # script to get past the msys problems. So manually call the python
         # script instead, so that we don't do a native->msys transition
@@ -149,17 +163,17 @@ def js_subconfigure(build_env, prepare_c
         # environment when calling the shell configure.
         command = [
             sys.executable,
             os.path.join(build_env.topsrcdir, 'configure.py'),
             '--enable-project=js',
         ]
         environ['OLD_CONFIGURE'] = os.path.join(
             os.path.dirname(configure), 'old-configure')
-        command += data['args']
+        command += options
         command += ['--cache-file=%s' % cache_file]
 
         log.info('configuring')
         log.info('running %s' % ' '.join(command[:-1]))
         proc = subprocess.Popen(
             command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
             cwd=objdir, env=encode(environ))
         while True: