gecko-dev/js/sub.configure

86 строки
3.1 KiB
Python

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
@depends(check_build_environment)
@imports('logging')
@imports(_from='__builtin__', _import='object')
@imports(_from='mozbuild.configure.util', _import='ConfigureOutputHandler')
def old_js_configure(build_env):
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')
formatter = logging.Formatter('js/src> %(levelname)s: %(message)s')
for handler in logger.handlers:
handler.setFormatter(formatter)
if isinstance(handler, ConfigureOutputHandler):
handler._stdout = PrefixOutput('js/src> ', handler._stdout)
return os.path.join(build_env.topsrcdir, 'js', 'src', 'old-configure')
@depends(old_configure.substs, mozconfig)
def old_js_configure_env(substs, mozconfig):
substs = dict(substs)
# Here, we mimic what we used to do from old-configure, which makes this
# all awkward.
# 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`.
extra_env = {}
for var in (
'MOZ_DEV_EDITION', 'STLPORT_LIBS', 'MOZ_LINKER', 'ZLIB_IN_MOZGLUE',
'RANLIB',
):
if var in substs:
value = substs[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)
extra_env[var] = value
return extra_env
old_js_configure = old_configure_for(old_js_configure, extra_env=old_js_configure_env)
set_config('OLD_JS_CONFIGURE_SUBSTS', old_js_configure.substs)
set_config('OLD_JS_CONFIGURE_DEFINES', old_js_configure.defines)
@dependable
@imports('logging')
@imports(_from='mozbuild.configure.util', _import='ConfigureOutputHandler')
def post_old_js_configure():
# Restore unprefixed logging.
formatter = logging.Formatter('%(levelname)s: %(message)s')
logger = logging.getLogger('moz.configure')
for handler in logger.handlers:
handler.setFormatter(formatter)
if isinstance(handler, ConfigureOutputHandler):
handler._stdout.flush()
handler._stdout = handler._stdout._fh