mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 1719229 - Allow the build system to use a sysroot for the host part of the build. r=firefox-build-system-reviewers,andi
Differential Revision: https://phabricator.services.mozilla.com/D119847
This commit is contained in:
parent
162f9b6800
commit
487119e349
@ -19,7 +19,7 @@ def pkg_config_version(pkg_config):
|
||||
return Version(check_cmd_output(pkg_config, "--version").rstrip())
|
||||
|
||||
|
||||
@depends(sysroot_path, multiarch_dir, when=pkg_config)
|
||||
@depends(target_sysroot_path, multiarch_dir, when=pkg_config)
|
||||
@imports(_from="os", _import="environ")
|
||||
def pkg_config_vars(sysroot_path, multiarch_dir):
|
||||
if sysroot_path:
|
||||
|
@ -917,48 +917,73 @@ def provided_program(env_var, when=None):
|
||||
return provided
|
||||
|
||||
|
||||
option(
|
||||
"--with-sysroot",
|
||||
env="SYSROOT",
|
||||
nargs=1,
|
||||
when=target_is_linux_or_wasi,
|
||||
help="Build using the given sysroot directory",
|
||||
)
|
||||
|
||||
sysroot_input = depends("--with-sysroot", when=target_is_linux_or_wasi)(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 explicitly, or when
|
||||
# building on automation.
|
||||
@depends(
|
||||
sysroot_input,
|
||||
bootstrap_path(
|
||||
depends(target)(lambda t: "sysroot-{}".format(t.toolchain)),
|
||||
context=target,
|
||||
when=bootstrap_sysroot,
|
||||
),
|
||||
"--enable-bootstrap",
|
||||
"MOZ_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 and bootstrap.origin != "default") or automation:
|
||||
if path:
|
||||
log.info("Using sysroot in %s", path)
|
||||
return path
|
||||
@template
|
||||
def sysroot_path(host_or_target):
|
||||
if host_or_target is host:
|
||||
host_or_target_str = "host"
|
||||
opt = "--with-host-sysroot"
|
||||
env = "HOST_SYSROOT"
|
||||
when = depends(host)(lambda h: h.kernel == "Linux")
|
||||
bootstrap_when = when
|
||||
else:
|
||||
assert host_or_target is target
|
||||
host_or_target_str = "target"
|
||||
opt = "--with-sysroot"
|
||||
env = "SYSROOT"
|
||||
when = target_is_linux_or_wasi
|
||||
bootstrap_when = target_is_linux
|
||||
|
||||
option(
|
||||
opt,
|
||||
env=env,
|
||||
nargs=1,
|
||||
when=when,
|
||||
help="Use the given sysroot directory for %s build" % host_or_target_str,
|
||||
)
|
||||
|
||||
sysroot_input = depends(opt, when=when)(lambda x: x)
|
||||
bootstrap_sysroot = depends(bootstrap_when, sysroot_input)(
|
||||
lambda bootstrap, input: bootstrap and not input and input.origin == "default"
|
||||
)
|
||||
|
||||
@depends(
|
||||
sysroot_input,
|
||||
bootstrap_path(
|
||||
depends(host_or_target)(lambda t: "sysroot-{}".format(t.toolchain)),
|
||||
context=host_or_target,
|
||||
when=bootstrap_sysroot,
|
||||
),
|
||||
"--enable-bootstrap",
|
||||
"MOZ_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 and bootstrap.origin != "default") or automation:
|
||||
if path:
|
||||
log.info("Using %s sysroot in %s", host_or_target_str, path)
|
||||
return path
|
||||
|
||||
return sysroot_path
|
||||
|
||||
|
||||
host_sysroot_path = sysroot_path(host)
|
||||
target_sysroot_path = sysroot_path(target)
|
||||
|
||||
|
||||
@template
|
||||
def sysroot_flags(host_or_target):
|
||||
@depends(
|
||||
host_or_target, macos_sdk, sysroot_path if host_or_target is target else never
|
||||
)
|
||||
sysroot_path = {
|
||||
host: host_sysroot_path,
|
||||
target: target_sysroot_path,
|
||||
}[host_or_target]
|
||||
|
||||
@depends(host_or_target, macos_sdk, sysroot_path)
|
||||
def sysroot_flags(host_or_target, macos_sdk, sysroot_path):
|
||||
if macos_sdk and host_or_target.os == "OSX":
|
||||
return ["-isysroot", macos_sdk]
|
||||
@ -973,7 +998,7 @@ host_sysroot_flags = sysroot_flags(host)
|
||||
target_sysroot_flags = sysroot_flags(target)
|
||||
|
||||
|
||||
@depends(target, when=sysroot_path)
|
||||
@depends(target, when=target_sysroot_path)
|
||||
def multiarch_dir(target):
|
||||
if target.cpu == "x86":
|
||||
# Turn e.g. i686-linux-gnu into i386-linux-gnu
|
||||
@ -2196,7 +2221,7 @@ def select_linker(
|
||||
set_config("LINKER_KIND", select_linker.KIND)
|
||||
|
||||
|
||||
@depends_if(select_linker, target, macos_sdk, sysroot_path, multiarch_dir)
|
||||
@depends_if(select_linker, target, macos_sdk, target_sysroot_path, multiarch_dir)
|
||||
@imports("os")
|
||||
def linker_ldflags(linker, target, macos_sdk, sysroot_path, multiarch_dir):
|
||||
flags = list((linker and linker.LINKER_FLAG) or [])
|
||||
@ -2719,7 +2744,7 @@ def path_remapping(value):
|
||||
@depends(
|
||||
target,
|
||||
check_build_environment,
|
||||
sysroot_path,
|
||||
target_sysroot_path,
|
||||
macos_sdk,
|
||||
windows_sdk_dir,
|
||||
vc_path,
|
||||
|
@ -749,7 +749,7 @@ and/or set $JAVA_HOME.
|
||||
compile_environment = depends(when='--enable-compile-environment')(lambda: True)
|
||||
toolchain_prefix = depends(when=True)(lambda: None)
|
||||
multiarch_dir = depends(when=True)(lambda: None)
|
||||
sysroot_path = depends(when=True)(lambda: None)
|
||||
target_sysroot_path = depends(when=True)(lambda: None)
|
||||
include('%(topsrcdir)s/build/moz.configure/util.configure')
|
||||
include('%(topsrcdir)s/build/moz.configure/checks.configure')
|
||||
include('%(topsrcdir)s/build/moz.configure/pkg.configure')
|
||||
|
Loading…
Reference in New Issue
Block a user