1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
9 from pathlib
import Path
11 from mozbuild
.configure
import ConfigureSandbox
14 def _raw_sandbox(extra_args
=[]):
15 # Here, we don't want an existing mozconfig to interfere with what we
16 # do, neither do we want the default for --enable-bootstrap (which is not
17 # always on) to prevent this from doing something.
19 logger
= logging
.getLogger("moz.configure")
20 handler
= logging
.StreamHandler(out
)
21 logger
.addHandler(handler
)
22 logger
.propagate
= False
23 sandbox
= ConfigureSandbox(
26 + ["--enable-bootstrap", f
"MOZCONFIG={os.devnull}"]
33 @functools.lru_cache(maxsize
=None)
34 def _bootstrap_sandbox():
35 sandbox
= _raw_sandbox()
37 Path(__file__
).parent
.parent
.parent
.parent
/ "build" / "moz.configure"
39 sandbox
.include_file(str(moz_configure
/ "init.configure"))
40 sandbox
.include_file(str(moz_configure
/ "bootstrap.configure"))
44 def bootstrap_toolchain(toolchain_job
):
45 # Expand the `bootstrap_path` template for the given toolchain_job, and execute the
46 # expanded function via `_value_for`, which will trigger autobootstrap.
47 # Returns the path to the toolchain.
48 sandbox
= _bootstrap_sandbox()
49 return sandbox
._value
_for
(sandbox
["bootstrap_path"](toolchain_job
))
52 def bootstrap_all_toolchains_for(configure_args
=[]):
53 sandbox
= _raw_sandbox(configure_args
)
54 moz_configure
= Path(__file__
).parent
.parent
.parent
.parent
/ "moz.configure"
55 sandbox
.include_file(str(moz_configure
))
56 for depend
in sandbox
._depends
.values():
57 if depend
.name
== "bootstrap_path":