From 28c8a64a50ca3185a123a157d71423752f538325 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 2 Mar 2021 02:06:36 +0000 Subject: [PATCH] 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 --- build/moz.configure/toolchain.configure | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 6b340e2237f4..1b4e01388c77 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -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