Bug 1720806 - Avoid multiple calls to toolchain_task_definitions during configure. r=firefox-build-system-reviewers,mhentges

Bug 1692137 added code that would end up calling
toolchain_task_definitions twice, once for each of host and target.
With the recent changes from bug 1719229, that is not useful anymore.
We also don't need the toolchain prefixes for toolchains on unsupported
hosts (which were useful before bug 1719229 for the target sysroots).

Differential Revision: https://phabricator.services.mozilla.com/D120044
This commit is contained in:
Mike Hommey 2021-07-16 20:59:35 +00:00
parent f162f75a6a
commit 5ac51ef77d
2 changed files with 20 additions and 37 deletions

View file

@ -953,7 +953,6 @@ def sysroot_path(host_or_target):
sysroot_input,
bootstrap_path(
depends(host_or_target)(lambda t: "sysroot-{}".format(t.toolchain)),
context=host_or_target,
when=bootstrap_sysroot,
),
"--enable-bootstrap",

View file

@ -247,47 +247,28 @@ def original_path():
return environ["PATH"].split(os.pathsep)
@template
def bootstrap_toolchain_tasks(host_or_target):
@depends(host_or_target, when="--enable-bootstrap")
@imports("os")
@imports(_from="mozbuild.toolchains", _import="toolchain_task_definitions")
@imports(_from="__builtin__", _import="Exception")
def bootstrap_toolchain_tasks(host_or_target):
prefix = {
("x86", "GNU", "Linux"): "linux32",
("x86_64", "GNU", "Linux"): "linux64",
("aarch64", "GNU", "Linux"): "linux64-aarch64",
("x86_64", "OSX", "Darwin"): "macosx64",
("aarch64", "OSX", "Darwin"): "macosx64-aarch64",
("x86_64", "WINNT", "WINNT"): "win64",
}.get((host_or_target.cpu, host_or_target.os, host_or_target.kernel))
if prefix:
try:
return namespace(prefix=prefix, tasks=toolchain_task_definitions())
except Exception:
return None
return bootstrap_toolchain_tasks
host_bootstrap_toolchain_tasks = bootstrap_toolchain_tasks(host)
target_bootstrap_toolchain_tasks = bootstrap_toolchain_tasks(target)
@depends(host, when="--enable-bootstrap")
@imports("os")
@imports(_from="mozbuild.toolchains", _import="toolchain_task_definitions")
@imports(_from="__builtin__", _import="Exception")
def bootstrap_toolchain_tasks(host):
prefix = {
("x86_64", "GNU", "Linux"): "linux64",
("x86_64", "OSX", "Darwin"): "macosx64",
("aarch64", "OSX", "Darwin"): "macosx64-aarch64",
("x86_64", "WINNT", "WINNT"): "win64",
}.get((host.cpu, host.os, host.kernel))
try:
return namespace(prefix=prefix, tasks=toolchain_task_definitions())
except Exception:
return None
@template
def bootstrap_path(path, **kwargs):
when = kwargs.pop("when", None)
context = kwargs.pop("context", host)
if kwargs:
configure_error(
"bootstrap_path only takes `when` or `context` as keyword arguments"
)
bootstrap_toolchain_tasks = {
host: host_bootstrap_toolchain_tasks,
target: target_bootstrap_toolchain_tasks,
}[context]
configure_error("bootstrap_path only takes `when` as a keyword argument")
@depends(
"--enable-bootstrap",
@ -309,7 +290,10 @@ def bootstrap_path(path, **kwargs):
def try_bootstrap(exists):
if not tasks:
return False
for prefix in ("{}-".format(tasks.prefix), ""):
prefixes = [""]
if tasks.prefix:
prefixes.insert(0, "{}-".format(tasks.prefix))
for prefix in prefixes:
label = "toolchain-{}{}".format(prefix, path_parts[0])
task = tasks.tasks.get(label)
if task: