1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 @depends(check_build_environment)
10 @imports(_from="__builtin__", _import="object")
11 @imports(_from="mozbuild.configure.util", _import="ConfigureOutputHandler")
12 def old_js_configure(build_env):
13 class PrefixOutput(object):
14 def __init__(self, prefix, fh):
16 self._begin_line = True
19 def write(self, content):
21 self._fh.write(self._prefix)
22 self._fh.write(("\n" + self._prefix).join(content.splitlines()))
23 self._begin_line = content.endswith("\n")
30 logger = logging.getLogger("moz.configure")
31 formatter = logging.Formatter("js/src> %(levelname)s: %(message)s")
32 for handler in logger.handlers:
33 handler.setFormatter(formatter)
34 if isinstance(handler, ConfigureOutputHandler):
35 handler._stdout = PrefixOutput("js/src> ", handler._stdout)
36 return os.path.join(build_env.topsrcdir, "js", "src", "old-configure")
39 @depends(old_configure.substs, mozconfig)
40 def old_js_configure_env(substs, mozconfig):
42 # Here, we mimic what we used to do from old-configure, which makes this
45 # Variables that were explicitly exported from old-configure, and those
46 # explicitly set in the environment when invoking old-configure, were
47 # automatically inherited from subconfigure. We assume the relevant ones
48 # have a corresponding AC_SUBST in old-configure, making them available
64 and not mozconfig[var][1].startswith("removed")
66 value = mozconfig[var][0]
69 if isinstance(value, list):
70 value = " ".join(value)
71 extra_env[var] = value
76 old_js_configure = old_configure_for(old_js_configure, extra_env=old_js_configure_env)
77 set_config("OLD_JS_CONFIGURE_SUBSTS", old_js_configure.substs)
78 set_config("OLD_JS_CONFIGURE_DEFINES", old_js_configure.defines)
83 @imports(_from="mozbuild.configure.util", _import="ConfigureOutputHandler")
84 def post_old_js_configure():
85 # Restore unprefixed logging.
86 formatter = logging.Formatter("%(levelname)s: %(message)s")
87 logger = logging.getLogger("moz.configure")
88 for handler in logger.handlers:
89 handler.setFormatter(formatter)
90 if isinstance(handler, ConfigureOutputHandler):
91 handler._stdout.flush()
92 handler._stdout = handler._stdout._fh