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(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
61 and not mozconfig[var][1].startswith("removed")
63 value = mozconfig[var][0]
66 if isinstance(value, list):
67 value = " ".join(value)
68 extra_env[var] = value
73 old_js_configure = old_configure_for(old_js_configure, extra_env=old_js_configure_env)
74 set_config("OLD_JS_CONFIGURE_SUBSTS", old_js_configure.substs)
75 set_config("OLD_JS_CONFIGURE_DEFINES", old_js_configure.defines)
80 @imports(_from="mozbuild.configure.util", _import="ConfigureOutputHandler")
81 def post_old_js_configure():
82 # Restore unprefixed logging.
83 formatter = logging.Formatter("%(levelname)s: %(message)s")
84 logger = logging.getLogger("moz.configure")
85 for handler in logger.handlers:
86 handler.setFormatter(formatter)
87 if isinstance(handler, ConfigureOutputHandler):
88 handler._stdout.flush()
89 handler._stdout = handler._stdout._fh