Source code

Revision control

Other Tools

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at
@depends(host_for_sub_configure, target_for_sub_configure, check_build_environment,
js_configure_args, prepare_mozconfig, old_configure,
old_configure_assignments, '--cache-file')
@imports(_from='__main__', _import='config_status')
@imports(_from='__builtin__', _import='OSError')
@imports(_from='__builtin__', _import='open')
@imports(_from='__builtin__', _import='object')
@imports(_from='mozbuild.configure', _import='ConfigureSandbox')
@imports(_from='mozbuild.configure.util', _import='ConfigureOutputHandler')
def js_subconfigure(host, target, build_env, js_configure_args, mozconfig,
old_configure, old_configure_assignments, cache_file):
class PrefixOutput(object):
def __init__(self, prefix, fh):
self._fh = fh
self._begin_line = True
self._prefix = prefix
def write(self, content):
if self._begin_line:
self._fh.write(('\n' + self._prefix).join(content.splitlines()))
self._begin_line = content.endswith('\n')
if self._begin_line:
def flush(self):
logger = logging.getLogger('moz.configure')
formatter = logging.Formatter('js/src> %(levelname)s: %(message)s')
for handler in logger.handlers:
if isinstance(handler, ConfigureOutputHandler):
handler._stdout = PrefixOutput('js/src> ', handler._stdout)
substs = dict(old_configure['substs'])
assignments = dict(old_configure_assignments)
environ = dict(os.environ)
options = [host, target] + js_configure_args
options.append('--prefix=%s/dist' % build_env.topobjdir)
if substs.get('ZLIB_IN_MOZGLUE'):
substs['MOZ_ZLIB_LIBS'] = ''
environ['MOZILLA_CENTRAL_PATH'] = build_env.topsrcdir
if 'MOZ_BUILD_APP' in environ:
del environ['MOZ_BUILD_APP']
# Here, we mimic what we used to do from old-configure, which makes this
# all awkward.
# The following variables were saved at the beginning of old-configure,
# and restored before invoking the subconfigure. Which means their value
# should be taken from the old_configure_assignments or mozconfig.
from_assignment = set(
# Variables that were explicitly exported from old-configure, and those
# explicitly set in the environment when invoking old-configure, were
# automatically inherited from subconfigure. We assume the relevant ones
# have a corresponding AC_SUBST in old-configure, making them available
# in `substs`.
for var in (
if var not in from_assignment and var in substs:
value = substs[var]
elif var in assignments:
value = assignments[var]
elif mozconfig and var in mozconfig and \
not mozconfig[var][1].startswith('removed'):
value = mozconfig[var][0]
if isinstance(value, list):
value = ' '.join(value)
environ[var] = value
srcdir = os.path.join(build_env.topsrcdir, 'js', 'src')
objdir = os.path.join(build_env.topobjdir, 'js', 'src')
data_file = os.path.join(objdir, 'configure.pkl')
previous_args = None
if os.path.exists(data_file):
with open(data_file, 'rb') as f:
previous_args = pickle.load(f)
cache_file = cache_file[0] if cache_file else './config.cache'
cache_file = os.path.join(build_env.topobjdir, cache_file)
except OSError as e:
if e.errno != errno.EEXIST:
with open(data_file, 'wb') as f:
pickle.dump(options, f)
# Only run configure if one of the following is true:
# - config.status doesn't exist
# - config.status is older than an input to configure
# - the configure arguments changed
configure = os.path.join(srcdir, 'old-configure')
config_status_path = os.path.join(objdir, 'config.status')
skip_configure = True
if not os.path.exists(config_status_path):
skip_configure = False
config_status_deps = os.path.join(objdir, '')
if not os.path.exists(config_status_deps):
skip_configure = False
with open(config_status_deps, 'r') as fh:
dep_files = + [configure]
if (any(not os.path.exists(f) or
(os.path.getmtime(config_status_path) < os.path.getmtime(f))
for f in dep_files) or
((previous_args or options) != options)):
skip_configure = False
ret = 0
if not skip_configure:
oldpwd = os.getcwd()
command = [
os.path.join(build_env.topsrcdir, ''),
environ['OLD_CONFIGURE'] = os.path.join(
os.path.dirname(configure), 'old-configure')
command += options
command += ['--cache-file=%s' % cache_file]'configuring')'running %s' % ' '.join(command[:-1]))
config = {}
sandbox = ConfigureSandbox(config, environ, command, logger=logger), 'moz.configure'))
ret = config_status(config)
# Restore unprefixed logging.
formatter = logging.Formatter('%(levelname)s: %(message)s')
for handler in logger.handlers:
if isinstance(handler, ConfigureOutputHandler):
handler._stdout = handler._stdout._fh
return ret