Bug 1669633 - Don't recurse into js/src for the python-part of configure. r=firefox-build-system-reviewers,rstewart

Instead, we now run js/src/old-configure from the top-level configure
after having run old-configure and extracted a few variables to inherit
from it.

Because we're now running from the top-level, $_objdir is always the
top-level objdir, which simplifies some things. The topobjdir in
js/src/config.status, however, needs to stay in js/src because of the
build frontend expecting it there.

When running js/src/old-configure, we used to need some special
treatment for a large number of variables for historic reasons, where
we'd take values from the assigned values before running old-configure
for some, or from AC_SUBSTs after running old-configure.

Now that both old-configure and js/src/old-configure get the same
assignments from old-configure.vars, we don't need anything special for
the former. And only a few remaining variables still need manual work
for the latter.

One notable difference, though, is that the new code doesn't try to
avoid running js subconfigure, which added complexity, and was actually
error-prone.

Differential Revision: https://phabricator.services.mozilla.com/D92725
This commit is contained in:
Mike Hommey
2020-10-07 21:13:19 +00:00
parent e00e9c38b1
commit 29799d519a
7 changed files with 67 additions and 130 deletions

View File

@@ -5,6 +5,7 @@
from __future__ import absolute_import, print_function, unicode_literals
import codecs
import errno
import io
import itertools
import logging
@@ -55,6 +56,31 @@ def main(argv):
if sandbox._help:
return 0
logging.getLogger('moz.configure').info('Creating config.status')
old_js_configure_substs = config.pop('OLD_JS_CONFIGURE_SUBSTS', None)
old_js_configure_defines = config.pop('OLD_JS_CONFIGURE_DEFINES', None)
if old_js_configure_substs or old_js_configure_defines:
js_config = config.copy()
pwd = os.getcwd()
try:
try:
os.makedirs('js/src')
except OSError as e:
if e.errno != errno.EEXIST:
raise
os.chdir('js/src')
js_config['OLD_CONFIGURE_SUBSTS'] = old_js_configure_substs
js_config['OLD_CONFIGURE_DEFINES'] = old_js_configure_defines
# The build system frontend expects $objdir/js/src/config.status
# to have $objdir/js/src as topobjdir.
# We want forward slashes on all platforms.
js_config['TOPOBJDIR'] += '/js/src'
config_status(js_config, execute=False)
finally:
os.chdir(pwd)
return config_status(config)
@@ -79,7 +105,7 @@ def check_unicode(obj):
return True
def config_status(config):
def config_status(config, execute=True):
# Sanitize config data to feed config.status
# Ideally, all the backend and frontend code would handle the booleans, but
# there are so many things involved, that it's easier to keep config.status
@@ -139,7 +165,6 @@ def config_status(config):
# Create config.status. Eventually, we'll want to just do the work it does
# here, when we're able to skip configure tests/use cached results/not rely
# on autoconf.
logging.getLogger('moz.configure').info('Creating config.status')
with codecs.open('config.status', 'w', 'utf-8') as fh:
fh.write(textwrap.dedent('''\
#!%(python)s
@@ -152,7 +177,7 @@ def config_status(config):
fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', "
"'substs', 'mozconfig']")
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
if execute:
fh.write(textwrap.dedent('''
if __name__ == '__main__':
from mozbuild.util import patch_main
@@ -178,7 +203,7 @@ def config_status(config):
# Other things than us are going to run this file, so we need to give it
# executable permissions.
os.chmod('config.status', 0o755)
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
if execute:
from mozbuild.config_status import config_status
return config_status(args=[], **sanitized_config)
return 0