mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1693723 - Avoid bootstrapping when an explicit path is given for tools. r=firefox-build-system-reviewers,mhentges
This changes things such that setting e.g. NASM=/usr/bin/nasm will avoid bootstrapping nasm even when bootstrapping is enabled. This is not applied to CC/CXX/HOST_CC/HOST_CXX because things are more complicated. This also simplifies how check_prog is called for a bootstrapped tool, and avoids the repetition of when. CBINDGEN handling needs the pattern being applied manually because it currently doesn't use check_prog. Once --enable-bootstrap=install becomes the default on developer builds, it will be possible to simplify this. Differential Revision: https://phabricator.services.mozilla.com/D105718
This commit is contained in:
parent
dfb8c396a6
commit
34ada26a0e
@ -47,9 +47,16 @@ def check_cbindgen_version(cbindgen, fatal=False):
|
||||
)
|
||||
|
||||
|
||||
# Similar behavior to what check_prog does.
|
||||
has_cbindgen_input = depends("CBINDGEN", when=cbindgen_is_needed)(lambda x: x)
|
||||
bootstrap_cbindgen = depends(cbindgen_is_needed, has_cbindgen_input)(
|
||||
lambda n, i: n and not i
|
||||
)
|
||||
|
||||
|
||||
@depends_if(
|
||||
"CBINDGEN",
|
||||
bootstrap_search_path("cbindgen"),
|
||||
bootstrap_search_path("cbindgen", when=bootstrap_cbindgen),
|
||||
rust_search_path,
|
||||
when=cbindgen_is_needed,
|
||||
)
|
||||
|
@ -93,6 +93,11 @@ def checking(what, callback=None):
|
||||
# that will cause the given path(s) to be searched rather than $PATH. Input
|
||||
# paths may either be individual paths or delimited by os.pathsep, to allow
|
||||
# passing $PATH (for example) as an element.
|
||||
# - `bootstrap` is a path relative to the bootstrap root path (e.g ~/.mozbuild)
|
||||
# where to find the program if it's bootstrapped.
|
||||
#
|
||||
# - `bootstrap_search_path` is not an argument that users of the template are
|
||||
# supposed to pass. See the override of check_prog in top-level moz.configure.
|
||||
#
|
||||
# The simplest form is:
|
||||
# check_prog('PROG', ('a', 'b'))
|
||||
@ -108,7 +113,9 @@ def check_prog(
|
||||
input=None,
|
||||
allow_missing=False,
|
||||
paths=None,
|
||||
bootstrap=None,
|
||||
when=None,
|
||||
bootstrap_search_path=None,
|
||||
):
|
||||
if input is not None:
|
||||
# Wrap input with type checking and normalization.
|
||||
@ -140,6 +147,20 @@ def check_prog(
|
||||
paths = dependable(paths)
|
||||
allow_missing = dependable(allow_missing)
|
||||
|
||||
if bootstrap:
|
||||
if input is var:
|
||||
# A when is needed when depending on an option, so normalize
|
||||
# to a function that can used without.
|
||||
has_input = depends(input, when=when)(lambda x: x)
|
||||
else:
|
||||
has_input = input
|
||||
# We don't want to bootstrap when an explicit value was given as input.
|
||||
if when:
|
||||
bootstrap_when = depends(when, has_input)(lambda w, i: w and not i)
|
||||
else:
|
||||
bootstrap_when = depends(has_input)(lambda i: not i)
|
||||
paths = bootstrap_search_path(bootstrap, paths, when=bootstrap_when)
|
||||
|
||||
# Avoid displaying the "Checking for" message when the inputs are such
|
||||
# that we don't actually want anything to be checked. It is a bit
|
||||
# convoluted because of how `when` works.
|
||||
|
@ -8,7 +8,11 @@ option("--disable-nodejs", help="Require Node.js to build")
|
||||
option(env="NODEJS", nargs=1, help="Path to nodejs")
|
||||
|
||||
|
||||
@depends("--enable-nodejs", "NODEJS", bootstrap_search_path("node"))
|
||||
@depends(
|
||||
"--enable-nodejs",
|
||||
"NODEJS",
|
||||
bootstrap_search_path("node", when=depends("NODEJS")(lambda x: not x)),
|
||||
)
|
||||
@checking(
|
||||
"for nodejs", callback=lambda x: "%s (%s)" % (x.path, x.str_version) if x else "no"
|
||||
)
|
||||
|
@ -391,22 +391,35 @@ def bootstrap_path(path, **kwargs):
|
||||
|
||||
|
||||
@template
|
||||
def bootstrap_search_path(path, **kwargs):
|
||||
def bootstrap_search_path(path, paths=original_path, **kwargs):
|
||||
@depends(
|
||||
bootstrap_path(path, **kwargs),
|
||||
bootstrap_search_path_order,
|
||||
paths,
|
||||
original_path,
|
||||
)
|
||||
def bootstrap_search_path(path, order, original_path):
|
||||
def bootstrap_search_path(path, order, paths, original_path):
|
||||
if paths is None:
|
||||
paths = original_path
|
||||
if not path:
|
||||
return original_path
|
||||
return paths
|
||||
if order == "prepend":
|
||||
return [path] + original_path
|
||||
return original_path + [path]
|
||||
return [path] + paths
|
||||
return paths + [path]
|
||||
|
||||
return bootstrap_search_path
|
||||
|
||||
|
||||
# The execution model of the configure sandbox doesn't allow for
|
||||
# check_prog to use bootstrap_search_path directly because check_prog
|
||||
# comes first, so we use a trick to allow it. No use of check_prog
|
||||
# happening before here won't allow bootstrap.
|
||||
@template
|
||||
def check_prog(*args, **kwargs):
|
||||
kwargs["bootstrap_search_path"] = bootstrap_search_path
|
||||
return check_prog(*args, **kwargs)
|
||||
|
||||
|
||||
@depends(target, host)
|
||||
def want_wine(target, host):
|
||||
return target.kernel == "WINNT" and host.kernel != "WINNT"
|
||||
@ -417,7 +430,7 @@ wine = check_prog(
|
||||
["wine64", "wine"],
|
||||
allow_missing=True,
|
||||
when=want_wine,
|
||||
paths=bootstrap_search_path("wine/bin", when=want_wine),
|
||||
bootstrap="wine/bin",
|
||||
)
|
||||
check_prog("WGET", ("wget",), allow_missing=True)
|
||||
|
||||
|
@ -1943,7 +1943,7 @@ nasm = check_prog(
|
||||
"NASM",
|
||||
["nasm"],
|
||||
allow_missing=True,
|
||||
paths=bootstrap_search_path("nasm", when=need_nasm),
|
||||
bootstrap="nasm",
|
||||
when=need_nasm,
|
||||
)
|
||||
|
||||
@ -2083,7 +2083,7 @@ set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
|
||||
set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
|
||||
|
||||
with only_when(requires_wasm_sandboxing & compile_environment):
|
||||
lucetc = check_prog("LUCETC", ["lucetc"], paths=bootstrap_search_path("lucetc"))
|
||||
lucetc = check_prog("LUCETC", ["lucetc"], bootstrap="lucetc")
|
||||
|
||||
option(
|
||||
"--with-wasi-sysroot",
|
||||
@ -2333,7 +2333,7 @@ check_prog(
|
||||
"DUMP_SYMS",
|
||||
["dump_syms"],
|
||||
allow_missing=True,
|
||||
paths=bootstrap_search_path("dump_syms", when=compile_environment),
|
||||
bootstrap="dump_syms",
|
||||
when=compile_environment,
|
||||
)
|
||||
|
||||
@ -2342,7 +2342,7 @@ check_prog(
|
||||
"PDBSTR",
|
||||
["pdbstr.exe"],
|
||||
allow_missing=True,
|
||||
paths=bootstrap_search_path("pdbstr", when=compile_environment & target_is_windows),
|
||||
bootstrap="pdbstr",
|
||||
when=compile_environment & target_is_windows,
|
||||
)
|
||||
|
||||
@ -2358,9 +2358,7 @@ def allow_missing_winchecksec(automation, c_compiler):
|
||||
check_prog(
|
||||
"WINCHECKSEC",
|
||||
["winchecksec.exe", "winchecksec"],
|
||||
paths=bootstrap_search_path(
|
||||
"winchecksec", when=compile_environment & target_is_windows
|
||||
),
|
||||
bootstrap="winchecksec",
|
||||
allow_missing=allow_missing_winchecksec,
|
||||
when=compile_environment & target_is_windows,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user