2018-07-04 00:24:58 +03:00
|
|
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
|
|
# vim: set filetype=python:
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
option("--disable-nodejs", help="Require Node.js to build")
|
2018-09-25 21:15:51 +03:00
|
|
|
option(env="NODEJS", nargs=1, help="Path to nodejs")
|
2018-07-04 00:24:58 +03:00
|
|
|
|
|
|
|
|
2021-02-24 05:01:33 +03:00
|
|
|
@depends(
|
|
|
|
"--enable-nodejs",
|
|
|
|
"NODEJS",
|
|
|
|
bootstrap_search_path("node", when=depends("NODEJS")(lambda x: not x)),
|
2021-03-17 05:11:51 +03:00
|
|
|
host,
|
2021-02-24 05:01:33 +03:00
|
|
|
)
|
2018-09-25 21:15:51 +03:00
|
|
|
@checking(
|
|
|
|
"for nodejs", callback=lambda x: "%s (%s)" % (x.path, x.str_version) if x else "no"
|
|
|
|
)
|
|
|
|
@imports(_from="mozbuild.nodeutil", _import="find_node_executable")
|
|
|
|
@imports(_from="mozbuild.nodeutil", _import="NODE_MIN_VERSION")
|
2021-03-17 05:11:51 +03:00
|
|
|
@imports(_from="__builtin__", _import="OSError")
|
|
|
|
@imports("errno")
|
|
|
|
def nodejs(require, env_node, search_path, host):
|
Bug 1553230 - Allow to opt-in to automatically update some bootstrapped toolchains. r=firefox-build-system-reviewers,nalexander,mhentges
This adds a --enable-bootstrap build flag that will automatically update
cbindgen, node, clang, sccache, nasm, wine, lucetc, dump_syms, pdbstr,
and winchecksec if they are already installed in ~/.mozbuild.
Eventually, we'll want to allow to install toolchains that weren't
already install, but one step at a time.
This explicitly doesn't cover rustc, which is its own can of worms, or
android-{ndk,sdk}, which are not installed via toolchain artifacts
currently.
Differential Revision: https://phabricator.services.mozilla.com/D101723
2021-01-16 01:15:51 +03:00
|
|
|
# We don't use the dependency directly, but having it ensures the
|
|
|
|
# auto-upgrade code in bootstrap_search_path is triggered, while
|
|
|
|
# find_node_executable will use more or less the same search path.
|
|
|
|
# We do however need to use the variable for the configure lint
|
|
|
|
# not to fail.
|
|
|
|
search_path
|
|
|
|
|
2018-09-25 21:15:51 +03:00
|
|
|
node_exe = env_node[0] if env_node else None
|
2018-07-17 22:51:33 +03:00
|
|
|
|
2021-03-17 05:11:51 +03:00
|
|
|
try:
|
|
|
|
nodejs, version = find_node_executable(node_exe)
|
|
|
|
except OSError as e:
|
|
|
|
if host.cpu == "aarch64" and host.os == "OSX" and e.errno == errno.EBADARCH:
|
|
|
|
# Ideally we'd do it when --enable-bootstrap is set, but when we're wrapped in
|
|
|
|
# mach build or mach configure, running the command doesn't print anything and
|
|
|
|
# waits on input (for license agreement) that it can't actually get.
|
|
|
|
# mach bootstrap should have taken care of it anyways, but in case it hasn't,
|
|
|
|
# it's simpler to ask to run the rosetta install than the whole mach bootstrap.
|
|
|
|
die(
|
|
|
|
"Rosetta is needed to run node. Please run `softwareupdate --install-rosetta`"
|
|
|
|
)
|
|
|
|
raise
|
2018-07-04 00:24:58 +03:00
|
|
|
|
2018-08-15 19:26:23 +03:00
|
|
|
MAYBE_FILE_A_BUG = """
|
|
|
|
|
2018-09-25 21:15:51 +03:00
|
|
|
Executing `mach bootstrap --no-system-changes` should
|
|
|
|
install a compatible version in ~/.mozbuild on most platforms.
|
|
|
|
If you believe this is a bug, <https://mzl.la/2vLbXAv> is a good way
|
|
|
|
to file. More details: <https://bit.ly/2BbyD1E>
|
2020-10-26 21:34:53 +03:00
|
|
|
"""
|
2018-08-15 19:26:23 +03:00
|
|
|
|
2018-09-25 21:15:51 +03:00
|
|
|
if not nodejs:
|
|
|
|
msg = (
|
|
|
|
"could not find Node.js executable later than %s; ensure "
|
|
|
|
"`node` or `nodejs` is in PATH or set NODEJS in environment "
|
|
|
|
"to point to an executable.%s" % (NODE_MIN_VERSION, MAYBE_FILE_A_BUG)
|
2018-08-15 19:26:23 +03:00
|
|
|
)
|
2018-07-04 00:24:58 +03:00
|
|
|
|
|
|
|
if require:
|
|
|
|
raise FatalCheckError(msg)
|
|
|
|
else:
|
|
|
|
log.warning(msg)
|
2018-07-19 10:36:36 +03:00
|
|
|
log.warning("(This will become an error in the near future.)")
|
2018-07-04 00:24:58 +03:00
|
|
|
return
|
|
|
|
|
|
|
|
if not version:
|
2018-09-25 21:15:51 +03:00
|
|
|
msg = "NODEJS must point to node %s or newer; found node location: %s. %s" % (
|
|
|
|
NODE_MIN_VERSION,
|
|
|
|
nodejs,
|
|
|
|
MAYBE_FILE_A_BUG,
|
|
|
|
)
|
|
|
|
|
2018-07-04 00:24:58 +03:00
|
|
|
if require:
|
|
|
|
raise FatalCheckError(msg)
|
|
|
|
else:
|
|
|
|
log.warning(msg)
|
|
|
|
return
|
|
|
|
|
2018-09-25 21:15:51 +03:00
|
|
|
return namespace(
|
2020-04-07 21:31:56 +03:00
|
|
|
path=nodejs,
|
2018-09-25 21:15:51 +03:00
|
|
|
version=version,
|
|
|
|
str_version=".".join(str(v) for v in version),
|
|
|
|
)
|
2018-07-04 00:24:58 +03:00
|
|
|
|
2018-09-25 21:15:51 +03:00
|
|
|
|
|
|
|
set_config("NODEJS", depends_if(nodejs)(lambda p: p.path))
|