Bug 1264527 - Remove wanted_mozconfig_variables. r?nalexander
While forgetting about it was warned about, having to add every new
environment option to wanted_mozconfig_variables is cumbersome. It turns
out there is a hackish way to make things work without that list, which,
all things considered, is not worse than the hacks around the
wanted_mozconfig_variables function, and are certainly an improvement as
it doesn't require an ever growing list of environment options.
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -249,98 +249,44 @@ def early_options():
option.env
for option in __sandbox__._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.
-@depends('--help')
-def wanted_mozconfig_variables(help):
- return set([
- 'AUTOCONF',
- 'AWK',
- 'CC',
- 'CCACHE',
- 'CXX',
- 'COMPILER_WRAPPER',
- 'DISABLE_EXPORT_JS',
- 'DISABLE_SHARED_JS',
- 'DOXYGEN',
- 'DSYMUTIL',
- 'EXTERNAL_SOURCE_DIR',
- 'GENISOIMAGE',
- 'GRADLE',
- 'GRADLE_FLAGS',
- 'GRADLE_MAVEN_REPOSITORY',
- 'HOST_CC',
- 'HOST_CXX',
- 'JS_STANDALONE',
- 'L10NBASEDIR',
- 'MOZILLABUILD',
- 'MOZ_ARTIFACT_BUILDS',
- 'MOZ_BUILD_APP',
- 'MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE',
- 'MOZ_CALLGRIND',
- 'MOZ_DMD',
- 'MOZ_FMP4',
- 'MOZ_INSTRUMENT_EVENT_LOOP',
- 'MOZ_INSTRUMENTS',
- 'MOZ_JPROF',
- 'MOZ_PROFILING',
- 'MOZ_USE_SYSTRACE',
- 'MOZ_VTUNE',
- 'MOZTTDIR',
- 'PERL',
- 'RPMBUILD',
- 'TAR',
- 'TOOLCHAIN_PREFIX',
- 'UNZIP',
- 'USE_FC_FREETYPE',
- 'WITHOUT_X',
- 'XARGS',
- 'YASM',
- 'ZIP',
- ])
-
-
-@depends(mozconfig, wanted_mozconfig_variables, '--help')
+@depends(mozconfig, '--help')
# This gives access to the sandbox. Don't copy this blindly.
@imports('__sandbox__')
-def mozconfig_options(mozconfig, wanted_mozconfig_variables, help):
+def mozconfig_options(mozconfig, help):
if mozconfig['path']:
helper = __sandbox__._helper
log.info('Adding configure options from %s' % mozconfig['path'])
for arg in mozconfig['configure_args']:
log.info(' %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)
def add(key, value):
- # See comment above wanted_mozconfig_variables
- if key in wanted_mozconfig_variables:
+ if key.isupper():
arg = '%s=%s' % (key, value)
log.info(' %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)
+ # mozconfig_loader adds _IS_SET variables that are irrelevant
+ if not key.endswith('_IS_SET'):
+ add(key, value)
for key, (_, value) in mozconfig['vars']['modified'].iteritems():
add(key, value)
# 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
@@ -53,36 +53,16 @@ def autoconf(mozconfig, autoconf):
if not os.path.exists(autoconf):
die('Could not find autoconf 2.13 at %s', autoconf)
return autoconf
set_config('AUTOCONF', autoconf)
-# See comment in mozconfig_options() from build/moz.configure/init.configure
-@template
-# This gives access to the sandbox. Don't copy this blindly.
-@imports('__sandbox__')
-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 = __sandbox__._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):
- die('You need to add `%s` to the `wanted_mozconfig_variables` '
- 'list in build/moz.configure/init.configure.', option.env)
-
-check_mozconfig_variables()
-
-
@depends('OLD_CONFIGURE', mozconfig, autoconf, check_build_environment, shell,
old_configure_assignments, build_project)
@imports(_from='__builtin__', _import='open')
@imports(_from='__builtin__', _import='print')
@imports('glob')
@imports('itertools')
@imports('subprocess')
# Import getmtime without overwriting the sandbox os.path.
@@ -462,8 +442,29 @@ def post_old_configure(raw_config):
set_old_configure_config(
k[1:-1], v[1:-1] if isinstance(v, types.StringTypes) else v)
for k, v in dict(raw_config['defines']).iteritems():
set_old_configure_define(k[1:-1], v[1:-1])
set_old_configure_config('non_global_defines',
raw_config['non_global_defines'])
+
+
+# Assuming no other option is declared after this function, handle the
+# env options that were injected by mozconfig_options by creating dummy
+# Option instances and having the sandbox's CommandLineHelper handle
+# them. We only do so for options that haven't been declared so far,
+# which should be a proxy for the options that old-configure handles
+# and that we don't know anything about.
+@depends('--help')
+@imports('__sandbox__')
+@imports(_from='mozbuild.configure.options', _import='Option')
+def remaining_mozconfig_options(_):
+ helper = __sandbox__._helper
+ for arg in helper:
+ if helper._origins[arg] == 'mozconfig':
+ name = arg.split('=', 1)[0]
+ if name.isupper() and name not in __sandbox__._options:
+ option = Option(env=name, nargs='*', help=name)
+ helper.handle(option)
+
+# Please do not add anything after remaining_mozconfig_options()
--- a/moz.configure
+++ b/moz.configure
@@ -161,8 +161,9 @@ check_prog('DSYMUTIL', delayed_getattr(e
check_prog('GENISOIMAGE', delayed_getattr(extra_programs, 'GENISOIMAGE'),
allow_missing=True)
check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
allow_missing=True)
# Fallthrough to autoconf-based configure
include('build/moz.configure/old.configure')
+# Please do not add anything after the include of old.configure.