Bug 1255197 - Avoid cumulating dependencies in prepare_configure(). r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 10 Mar 2016 08:23:10 +0900
changeset 288190 57e084bd99c6c5417260658bb6502f850f14392e
parent 288189 a69518e297f1f5788fc03ea1c96f92ff2642aee9
child 288191 48286284fa92ecab0c87cc331300bb1566f32f9e
push id30075
push usercbook@mozilla.com
push dateFri, 11 Mar 2016 15:51:11 +0000
treeherdermozilla-central@f907faa919be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1255197
milestone48.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 1255197 - Avoid cumulating dependencies in prepare_configure(). r=chmanchester
build/moz.configure/init.configure
build/moz.configure/old.configure
js/moz.configure
moz.configure
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -83,16 +83,32 @@ def mozconfig(current_project, mozconfig
     current_project = current_project[0] if current_project else None
     mozconfig = mozconfig[0] if mozconfig else None
     mozconfig = loader.find_mozconfig(env={'MOZCONFIG': mozconfig})
     mozconfig = loader.read_mozconfig(mozconfig, moz_build_app=current_project)
 
     return mozconfig
 
 
+# Hacks related to old-configure
+# ==============================
+
+@depends('--help')
+def old_configure_assignments(help):
+    return []
+
+@template
+def add_old_configure_assignment(var, value):
+    @depends(old_configure_assignments)
+    @advanced
+    def add_assignment(assignments):
+        from mozbuild.shellutil import quote
+        assignments.append('%s=%s' % (var, quote(value)))
+
+
 option(env='PYTHON', nargs=1, help='Python interpreter')
 
 # Setup python virtualenv
 # ==============================================================
 @depends('PYTHON', check_build_environment, mozconfig)
 @advanced
 def virtualenv_python(env_python, build_env, mozconfig):
     import os
@@ -156,16 +172,17 @@ def virtualenv_python(env_python, build_
         sys.exit(subprocess.call([python] + sys.argv))
 
     # We are now in the virtualenv
     import distutils.sysconfig
     if not distutils.sysconfig.get_python_lib():
         error('Could not determine python site packages directory')
 
     set_config('PYTHON', python)
+    add_old_configure_assignment('PYTHON', python)
     return python
 
 
 # Inject mozconfig options
 # ==============================================================
 @template
 @advanced
 def command_line_helper():
@@ -225,27 +242,31 @@ option('--with-external-source-dir', env
          check_build_environment, '--help')
 def include_project_configure(project, external_source_dir, build_env, help):
     if not project:
         error('--enable-project is required.')
 
     base_dir = build_env['TOPSRCDIR']
     if external_source_dir:
         set_config('EXTERNAL_SOURCE_DIR', external_source_dir[0])
+        add_old_configure_assignment('EXTERNAL_SOURCE_DIR',
+                                     external_source_dir[0])
         base_dir = os.path.join(base_dir, external_source_dir[0])
 
     path = os.path.join(base_dir, project[0], 'moz.configure')
     if not os.path.exists(path):
         error('Cannot find project %s' % project[0])
     return path
 
 @depends(include_project_configure, check_build_environment, '--help')
 def build_project(include_project_configure, build_env, help):
-    return os.path.dirname(os.path.relpath(include_project_configure,
-                                           build_env['TOPSRCDIR']))
+    ret = os.path.dirname(os.path.relpath(include_project_configure,
+                                          build_env['TOPSRCDIR']))
+    add_old_configure_assignment('MOZ_BUILD_APP', ret)
+    return ret
 
 
 # This is temporary until js/src/configure and configure are merged.
 @depends(build_project)
 def extra_old_configure_args(build_project):
     if build_project != 'js':
         return []
     return False
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -57,22 +57,22 @@ def autoconf(mozconfig, autoconf):
     return autoconf
 
 
 option(env='OLD_CONFIGURE', nargs=1, help='Path to the old configure script')
 
 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
          virtualenv_python, compile_environment, build_project,
          extra_old_configure_args, '--with-external-source-dir',
-         '--enable-shared-js')
+         '--enable-shared-js', old_configure_assignments)
 @advanced
 def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
                       python, compile_env, build_project,
                       extra_old_configure_args, external_source_dir,
-                      shared_js):
+                      shared_js, old_configure_assignments):
     import glob
     import itertools
     import subprocess
     import sys
     # Import getmtime without overwriting the sandbox os.path.
     from os.path import getmtime
 
     from mozbuild.shellutil import quote
@@ -122,24 +122,18 @@ def prepare_configure(old_configure, moz
             for key, value in mozconfig['vars']['added'].items():
                 print("%s=%s" % (key, quote(value)), file=out)
             for key, (old, value) in mozconfig['vars']['modified'].items():
                 print("%s=%s" % (key, quote(value)), file=out)
             for t in ('env', 'vars'):
                 for key in mozconfig[t]['removed'].keys():
                     print("unset %s" % key, file=out)
 
-        print('PYTHON=%s' % quote(python), file=out)
-        if compile_env:
-            print('COMPILE_ENVIRONMENT=1', file=out)
-        print('MOZ_BUILD_APP=%s' % build_project, file=out)
-        if external_source_dir:
-            print(external_source_dir.format('EXTERNAL_SOURCE_DIR'), file=out)
-        if shared_js:
-            print('JS_SHARED_LIBRARY=1', file=out)
+        for assignment in old_configure_assignments:
+            print(assignment, file=out)
 
     if extra_old_configure_args:
         cmd += extra_old_configure_args
 
     return cmd
 
 
 @template
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -33,16 +33,17 @@ js_option('--disable-export-js', default
           help='Do not mark JS symbols as DLL exported/visible')
 
 @depends('--disable-shared-js', '--disable-export-js')
 def static_js(shared_js, export_js):
     if shared_js:
         if not export_js:
             error('Must export JS symbols when building a shared library.')
         set_config('JS_SHARED_LIBRARY', '1')
+        add_old_configure_assignment('JS_SHARED_LIBRARY', '1')
     else:
         if export_js:
             set_define('STATIC_EXPORTABLE_JS_API', '1')
         else:
             set_define('STATIC_JS_API', '1')
         set_define('MOZ_STATIC_JS', '1')
 
 
--- a/moz.configure
+++ b/moz.configure
@@ -27,16 +27,17 @@ def artifact_builds(value):
 
 option('--disable-compile-environment',
        help='Disable compiler/library checks')
 
 @depends('--disable-compile-environment')
 def compile_environment(value):
     if value:
         set_config('COMPILE_ENVIRONMENT', '1')
+        add_old_configure_assignment('COMPILE_ENVIRONMENT', '1')
     return bool(value)
 
 
 @depends('--help')
 @advanced
 def build_backends_choices(help):
     from mozbuild.backend import backends
     return tuple(backends)