Bug 1701957 [wpt PR 28298] - Incorrect reference for hsl() test, a=testonly
[gecko.git] / js / sub.configure
blob0d1443d07fa680e3cd70a456f7505a3c8da21662
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)
9 @imports("logging")
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):
15             self._fh = fh
16             self._begin_line = True
17             self._prefix = prefix
19         def write(self, content):
20             if self._begin_line:
21                 self._fh.write(self._prefix)
22             self._fh.write(("\n" + self._prefix).join(content.splitlines()))
23             self._begin_line = content.endswith("\n")
24             if self._begin_line:
25                 self._fh.write("\n")
27         def flush(self):
28             self._fh.flush()
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):
41     substs = dict(substs)
42     # Here, we mimic what we used to do from old-configure, which makes this
43     # all awkward.
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
49     # in `substs`.
50     extra_env = {}
52     for var in (
53         "MOZ_DEV_EDITION",
54         "STLPORT_LIBS",
55         "MOZ_LINKER",
56         "ZLIB_IN_MOZGLUE",
57         "RANLIB",
58     ):
59         if var in substs:
60             value = substs[var]
61         elif (
62             mozconfig
63             and var in mozconfig
64             and not mozconfig[var][1].startswith("removed")
65         ):
66             value = mozconfig[var][0]
67         else:
68             continue
69         if isinstance(value, list):
70             value = " ".join(value)
71         extra_env[var] = value
73     return extra_env
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)
81 @dependable
82 @imports("logging")
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