1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# -*- 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(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",
):
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
|