Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / js / sub.configure
bloba331a9356bfc0c93c2ba6b9fa6639d85799d01b3
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)
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     ):
56         if var in substs:
57             value = substs[var]
58         elif (
59             mozconfig
60             and var in mozconfig
61             and not mozconfig[var][1].startswith("removed")
62         ):
63             value = mozconfig[var][0]
64         else:
65             continue
66         if isinstance(value, list):
67             value = " ".join(value)
68         extra_env[var] = value
70     return extra_env
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)
78 @dependable
79 @imports("logging")
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