From 50eff9d4738b933f36d2d0664e3742fa29dfadb0 Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Wed, 20 May 2020 15:39:29 +0000 Subject: [PATCH] Bug 1636574 - Allow setting `PYTHON3` in mozconfig r=glandium Configuration values defined above `mozconfig_options` in `init.configure` are those that can't be configured in `mozconfig`. As far as I can tell there is nothing wrong *in principle* with setting `PYTHON3` in `mozconfig`, so here we just bump `mozconfig_options` above `PYTHON3` configuration. Side note, diagnosing this failure took a *long* time. The error message that this produced ("unknown option `PYTHON3`") is useless and the underlying algos being extremely mutable, I ended up having to spend a lot of time in the debugger and monitor all the underlying changes to a bunch of mutable data structures to determine where `PYTHON3` was getting lost. A better error message would be good here but I don't know how I would begin adding it. Differential Revision: https://phabricator.services.mozilla.com/D75635 --- build/moz.configure/init.configure | 111 ++++++++++++----------------- 1 file changed, 46 insertions(+), 65 deletions(-) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index 20b1693907ae..f4599b00abbe 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -233,6 +233,52 @@ def help_shell(help, shell): shell = help_shell | shell +# Inject mozconfig options +# ============================================================== + + +@depends(mozconfig, 'MOZ_AUTOMATION', '--help') +# This gives access to the sandbox. Don't copy this blindly. +@imports('__sandbox__') +@imports('os') +@imports('six') +def mozconfig_options(mozconfig, automation, help): + if mozconfig['path']: + if 'MOZ_AUTOMATION_MOZCONFIG' in mozconfig['env']['added']: + if not automation: + log.error('%s directly or indirectly includes an in-tree ' + 'mozconfig.', mozconfig['path']) + log.error('In-tree mozconfigs make strong assumptions about ' + 'and are only meant to be used by Mozilla ' + 'automation.') + die("Please don't use them.") + 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): + if key.isupper(): + arg = '%s=%s' % (key, value) + log.info(' %s' % arg) + helper.add(arg, origin='mozconfig', args=helper._args) + + for key, value in six.iteritems(mozconfig['env']['added']): + add(key, value) + os.environ[key] = value + for key, (_, value) in six.iteritems(mozconfig['env']['modified']): + add(key, value) + os.environ[key] = value + for key, value in six.iteritems(mozconfig['vars']['added']): + add(key, value) + for key, (_, value) in six.iteritems(mozconfig['vars']['modified']): + add(key, value) + + # Python 3 # ======== @@ -397,71 +443,6 @@ set_config('PYTHON3', virtualenv_python3.path) set_config('PYTHON3_VERSION', virtualenv_python3.str_version) -# Inject mozconfig options -# ============================================================== -# All options defined above this point can't be injected in mozconfig_options -# below, so collect them. - - -@template -def early_options(): - @dependable - @imports('__sandbox__') - @imports(_from='six', _import='itervalues') - def early_options(): - return set( - option.env - for option in itervalues(__sandbox__._options) - if option.env - ) - return early_options - - -early_options = early_options() - - -@depends(mozconfig, 'MOZ_AUTOMATION', '--help') -# This gives access to the sandbox. Don't copy this blindly. -@imports('__sandbox__') -@imports('os') -@imports('six') -def mozconfig_options(mozconfig, automation, help): - if mozconfig['path']: - if 'MOZ_AUTOMATION_MOZCONFIG' in mozconfig['env']['added']: - if not automation: - log.error('%s directly or indirectly includes an in-tree ' - 'mozconfig.', mozconfig['path']) - log.error('In-tree mozconfigs make strong assumptions about ' - 'and are only meant to be used by Mozilla ' - 'automation.') - die("Please don't use them.") - 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): - if key.isupper(): - arg = '%s=%s' % (key, value) - log.info(' %s' % arg) - helper.add(arg, origin='mozconfig', args=helper._args) - - for key, value in six.iteritems(mozconfig['env']['added']): - add(key, value) - os.environ[key] = value - for key, (_, value) in six.iteritems(mozconfig['env']['modified']): - add(key, value) - os.environ[key] = value - for key, value in six.iteritems(mozconfig['vars']['added']): - add(key, value) - for key, (_, value) in six.iteritems(mozconfig['vars']['modified']): - add(key, value) - - # Source checkout and version control integration. # ================================================