Bug 1256568 - Inject some variables set in mozconfig into moz.configure. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 15 Mar 2016 14:17:23 +0900
changeset 326620 8b2a1bed177abbcc55a06e70e8fbcc2c67c943e3
parent 326619 e035b6133eeff11cacede43832e12b3ccaa64df7
child 326621 c71929474f668a7d47191287d820639ba833926f
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [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 1256568 - Inject some variables set in mozconfig into moz.configure. r=gps Because some of the existing mozconfigs may be setting some variables, we need to inject those that are handled by moz.configure now. It likely doesn't matter for the variables currently in moz.configure, but it will soon become important when more things are moved to moz.configure. In fact, it is necessary for GENISOIMAGE and DSYMUTIL that we're going to move in this bug, set in automation mozconfigs. The implementation is cumbersome and quite horrible. We could do better by changing the execution model in mozbuild.configure, which is probably necessary for other reasons as well, but that requires more work and testing.
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -217,33 +217,79 @@ def virtualenv_python(env_python, build_
 def command_line_helper():
     # This escapes the sandbox. Don't copy this. This is only here because
     # it is a one off and because the required functionality doesn't need
     # to be exposed for other usecases.
     return depends.__self__._helper
-def mozconfig_options(mozconfig):
+# All options defined above this point can't be injected in mozconfig_options
+# below, so collect them.
+def early_options():
+    @depends('--help')
+    def early_options(help):
+        return set(
+            option.env
+            for option in depends.__self__._options.itervalues()
+            if option.env
+        )
+    return early_options
+early_options = early_options()
+# At the moment, moz.configure doesn't have complete knowledge of all the
+# supported options in mozconfig because of all that is still in old.configure.
+# But we don't know all the options that moz.configure knows about until all
+# moz.configure files are executed, so we keep a manual list here, that is
+# checked in old.configure (we'll assume it's the last moz.configure file
+# processed). This is tedious but necessary for now.
+def wanted_mozconfig_variables(help):
+     return set([
+         'AUTOCONF',
+         'DISABLE_EXPORT_JS',
+         'DISABLE_SHARED_JS',
+         'MOZILLABUILD',
+         'MOZ_BUILD_APP',
+     ])
+@depends(mozconfig, wanted_mozconfig_variables)
+def mozconfig_options(mozconfig, wanted_mozconfig_variables):
     if mozconfig['path']:
         helper = command_line_helper()
         warn('Adding configure options from %s' % mozconfig['path'])
         for arg in mozconfig['configure_args']:
             warn('  %s' % arg)
             # We could be using imply_option() here, but it has other
             # contraints that don't really apply to the command-line
             # emulation that mozconfig provides.
             helper.add(arg, origin='mozconfig', args=helper._args)
-        # Ideally we'd handle mozconfig['env'] and mozconfig['vars'] here,
-        # but at the moment, moz.configure has no knowledge of the options
-        # that may appear there. We'll opt-in when we move things from
-        # old-configure.in, which will be tedious but necessary until we
-        # can discriminate what old-configure.in supports.
+        def add(key, value):
+            # See comment above wanted_mozconfig_variables
+            if key in wanted_mozconfig_variables:
+                arg = '%s=%s' % (key, value)
+                warn('  %s' % arg)
+                helper.add(arg, origin='mozconfig', args=helper._args)
+        for key, value in mozconfig['env']['added'].iteritems():
+            add(key, value)
+        for key, (_, value) in mozconfig['env']['modified'].iteritems():
+            add(key, value)
+        for key, value in mozconfig['vars']['added'].iteritems():
+            add(key, value)
+        for key, (_, value) in mozconfig['vars']['modified'].iteritems():
+            add(key, value)
 del command_line_helper
 # Mozilla-Build
 # ==============================================================
 option(env='MOZILLABUILD', nargs=1,
        help='Path to Mozilla Build (Windows-only)')
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -55,16 +55,36 @@ def autoconf(mozconfig, autoconf):
     if not os.path.exists(autoconf):
         error('Could not find autoconf 2.13 at %s' % (autoconf,))
     set_config('AUTOCONF', autoconf)
     return autoconf
+# See comment in mozconfig_options() from build/moz.configure/init.configure
+def check_mozconfig_variables():
+    # This escapes the sandbox. Don't copy this. This is only here because it
+    # is a one off until old-configure is gone.
+    all_options = depends.__self__._options.itervalues()
+    @depends(early_options, wanted_mozconfig_variables)
+    def check_mozconfig_variables(early_options, wanted_mozconfig_variables):
+        for option in all_options:
+            if (option.env and option.env not in early_options and
+                    option.env not in wanted_mozconfig_variables):
+                error(
+                    'You need to add `%s` to the `wanted_mozconfig_variables` '
+                    'list in build/moz.configure/init.configure.' % option.env)
 @depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
 def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
     import glob
     import itertools
     import subprocess