Bug 1694784 - Add a flag allowing to pick a sysroot manually. r=firefox-build-system-reviewers,sheehan,mhentges

Spidermonkey package builds don't have MOZ_AUTOMATION set (for good
reasons), which means they don't automatically get the sysroot through
MOZ_FETCHES_DIR. We need a way for that particular build to set its
sysroot.

Because the setup for sysroot is more elaborated than adding --sysroot
to C{,XX}FLAGS, it's more convenient to have an option for this.

And while at it, we might as well make that a full-fledged option,
although, we only make it available when targetting Linux (although it
could be useful for other OSes, but there's overlap with other options
on Android, and Mac, so for now, Linux-only will do).

This also allows to pass --without-sysroot along with
--enable-bootstrap, where the bootstrapped sysroot is not used.

Differential Revision: https://phabricator.services.mozilla.com/D106352
This commit is contained in:
Mike Hommey 2021-03-02 02:06:36 +00:00
parent cb744d4a9d
commit 28c8a64a50

View File

@ -917,16 +917,34 @@ def provided_program(env_var, when=None):
return provided
option(
"--with-sysroot",
env="SYSROOT",
nargs=1,
when=target_is_linux,
help="Build using the given sysroot directory",
)
sysroot_input = depends("--with-sysroot", when=target_is_linux)(lambda x: x)
bootstrap_sysroot = depends(target_is_linux, sysroot_input)(
lambda linux, input: linux and not input and input.origin == "default"
)
# We'll re-evaluate later, but for now, don't use the sysroot automatically
# even if it exists, unless --enable-bootstrap was passed, or when building
# on automation.
@depends(
bootstrap_path("sysroot", context=target, when=target_is_linux),
sysroot_input,
bootstrap_path("sysroot", context=target, when=bootstrap_sysroot),
"--enable-bootstrap",
"MOZ_AUTOMATION",
)
def sysroot_path(path, bootstrap, automation):
if bootstrap or automation:
def sysroot_path(sysroot_input, path, bootstrap, automation):
if sysroot_input:
path = sysroot_input[0]
elif sysroot_input is not None and sysroot_input.origin != "default":
return
if sysroot_input or bootstrap or automation:
if path:
log.info("Using sysroot in %s", path)
return path