2019-01-17 02:12:20 +03:00
|
|
|
# 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 http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2020-05-02 00:21:55 +03:00
|
|
|
@depends(host_for_sub_configure, target_for_sub_configure, check_build_environment,
|
|
|
|
js_configure_args, prepare_mozconfig, old_configure,
|
|
|
|
old_configure_assignments, '--cache-file')
|
2019-01-17 02:29:19 +03:00
|
|
|
@imports('errno')
|
2019-01-17 00:44:54 +03:00
|
|
|
@imports('logging')
|
2019-01-17 02:12:20 +03:00
|
|
|
@imports('os')
|
2019-01-17 02:29:19 +03:00
|
|
|
@imports('pickle')
|
2019-01-17 02:12:20 +03:00
|
|
|
@imports('sys')
|
2019-01-17 02:42:12 +03:00
|
|
|
@imports(_from='__main__', _import='config_status')
|
2019-01-17 02:29:19 +03:00
|
|
|
@imports(_from='__builtin__', _import='OSError')
|
2019-01-17 02:18:29 +03:00
|
|
|
@imports(_from='__builtin__', _import='open')
|
2019-01-17 00:44:54 +03:00
|
|
|
@imports(_from='__builtin__', _import='object')
|
2019-01-17 02:42:12 +03:00
|
|
|
@imports(_from='mozbuild.configure', _import='ConfigureSandbox')
|
2019-01-17 00:44:54 +03:00
|
|
|
@imports(_from='mozbuild.configure.util', _import='ConfigureOutputHandler')
|
2020-05-02 00:21:55 +03:00
|
|
|
def js_subconfigure(host, target, build_env, js_configure_args, mozconfig,
|
2019-01-17 02:12:20 +03:00
|
|
|
old_configure, old_configure_assignments, cache_file):
|
2019-01-17 00:44:54 +03:00
|
|
|
|
|
|
|
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(self._prefix)
|
|
|
|
self._fh.write(('\n' + self._prefix).join(content.splitlines()))
|
|
|
|
self._begin_line = content.endswith('\n')
|
|
|
|
if self._begin_line:
|
|
|
|
self._fh.write('\n')
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
self._fh.flush()
|
|
|
|
|
|
|
|
logger = logging.getLogger('moz.configure')
|
2019-01-17 02:42:12 +03:00
|
|
|
formatter = logging.Formatter('js/src> %(levelname)s: %(message)s')
|
2019-01-17 00:44:54 +03:00
|
|
|
for handler in logger.handlers:
|
2019-01-17 02:42:12 +03:00
|
|
|
handler.setFormatter(formatter)
|
2019-01-17 00:44:54 +03:00
|
|
|
if isinstance(handler, ConfigureOutputHandler):
|
|
|
|
handler._stdout = PrefixOutput('js/src> ', handler._stdout)
|
|
|
|
|
2019-01-17 02:12:20 +03:00
|
|
|
substs = dict(old_configure['substs'])
|
|
|
|
assignments = dict(old_configure_assignments)
|
|
|
|
environ = dict(os.environ)
|
|
|
|
|
2020-05-29 20:11:27 +03:00
|
|
|
options = [host, target] + js_configure_args
|
2019-01-17 02:12:20 +03:00
|
|
|
|
|
|
|
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(
|
|
|
|
('CC', 'CXX', 'CPPFLAGS', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'HOST_CC',
|
|
|
|
'HOST_CXXFLAGS', 'HOST_LDFLAGS'))
|
|
|
|
|
|
|
|
# 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`.
|
2020-05-02 00:21:55 +03:00
|
|
|
for var in (
|
2019-01-17 02:12:20 +03:00
|
|
|
'MOZ_SYSTEM_ZLIB', 'MOZ_ZLIB_CFLAGS', 'MOZ_ZLIB_LIBS',
|
|
|
|
'MOZ_APP_NAME', 'MOZ_APP_REMOTINGNAME', 'MOZ_DEV_EDITION',
|
|
|
|
'STLPORT_LIBS', 'DIST', 'MOZ_LINKER', 'ZLIB_IN_MOZGLUE', 'RANLIB',
|
|
|
|
'AR', 'CPP', 'CC', 'CXX', 'CPPFLAGS', 'CFLAGS', 'CXXFLAGS',
|
|
|
|
'LDFLAGS', 'HOST_CC', 'HOST_CXX', 'HOST_CPPFLAGS',
|
|
|
|
'HOST_CXXFLAGS', 'HOST_LDFLAGS'
|
2020-05-02 00:21:55 +03:00
|
|
|
):
|
2019-01-17 02:12:20 +03:00
|
|
|
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]
|
|
|
|
else:
|
|
|
|
continue
|
|
|
|
if isinstance(value, list):
|
|
|
|
value = ' '.join(value)
|
|
|
|
environ[var] = value
|
|
|
|
|
2019-01-17 02:29:19 +03:00
|
|
|
options.append('JS_STANDALONE=')
|
|
|
|
|
2019-01-16 18:21:27 +03:00
|
|
|
srcdir = os.path.join(build_env.topsrcdir, 'js', 'src')
|
|
|
|
objdir = os.path.join(build_env.topobjdir, 'js', 'src')
|
2019-01-17 02:12:20 +03:00
|
|
|
|
2019-01-17 02:29:19 +03:00
|
|
|
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)
|
|
|
|
|
2020-05-08 04:45:56 +03:00
|
|
|
cache_file = cache_file[0] if cache_file else './config.cache'
|
2019-01-17 02:29:19 +03:00
|
|
|
cache_file = os.path.join(build_env.topobjdir, cache_file)
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.makedirs(objdir)
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
|
|
|
|
|
|
|
with open(data_file, 'wb') as f:
|
|
|
|
pickle.dump(options, f)
|
2019-01-17 02:18:29 +03:00
|
|
|
|
|
|
|
# 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
|
|
|
|
else:
|
|
|
|
config_status_deps = os.path.join(objdir, 'config_status_deps.in')
|
|
|
|
if not os.path.exists(config_status_deps):
|
|
|
|
skip_configure = False
|
|
|
|
else:
|
|
|
|
with open(config_status_deps, 'r') as fh:
|
|
|
|
dep_files = fh.read().splitlines() + [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
|
2019-01-17 02:29:19 +03:00
|
|
|
((previous_args or options) != options)):
|
2019-01-17 02:18:29 +03:00
|
|
|
skip_configure = False
|
|
|
|
|
2019-01-17 02:42:12 +03:00
|
|
|
ret = 0
|
2019-01-17 02:18:29 +03:00
|
|
|
if not skip_configure:
|
2019-01-17 02:42:12 +03:00
|
|
|
oldpwd = os.getcwd()
|
|
|
|
os.chdir(objdir)
|
2019-01-17 02:18:29 +03:00
|
|
|
command = [
|
|
|
|
os.path.join(build_env.topsrcdir, 'configure.py'),
|
|
|
|
'--enable-project=js',
|
|
|
|
]
|
|
|
|
environ['OLD_CONFIGURE'] = os.path.join(
|
|
|
|
os.path.dirname(configure), 'old-configure')
|
2019-01-17 02:29:19 +03:00
|
|
|
command += options
|
2019-01-17 02:18:29 +03:00
|
|
|
command += ['--cache-file=%s' % cache_file]
|
|
|
|
|
2019-01-17 00:44:54 +03:00
|
|
|
log.info('configuring')
|
|
|
|
log.info('running %s' % ' '.join(command[:-1]))
|
2019-01-17 02:42:12 +03:00
|
|
|
config = {}
|
|
|
|
sandbox = ConfigureSandbox(config, environ, command, logger=logger)
|
|
|
|
sandbox.run(os.path.join(build_env.topsrcdir, 'moz.configure'))
|
|
|
|
ret = config_status(config)
|
|
|
|
os.chdir(oldpwd)
|
|
|
|
|
|
|
|
# Restore unprefixed logging.
|
|
|
|
formatter = logging.Formatter('%(levelname)s: %(message)s')
|
|
|
|
for handler in logger.handlers:
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
if isinstance(handler, ConfigureOutputHandler):
|
|
|
|
handler._stdout.flush()
|
|
|
|
handler._stdout = handler._stdout._fh
|
|
|
|
|
|
|
|
return ret
|