1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# -*- 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")
option(env="NODEJS", nargs=1, help="Path to nodejs")
@depends("--enable-nodejs", "NODEJS", bootstrap_search_path("node"))
@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")
def nodejs(require, env_node, search_path):
# 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
node_exe = env_node[0] if env_node else None
nodejs, version = find_node_executable(node_exe)
MAYBE_FILE_A_BUG = """
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>
"""
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)
)
if require:
raise FatalCheckError(msg)
else:
log.warning(msg)
log.warning("(This will become an error in the near future.)")
return
if not version:
msg = "NODEJS must point to node %s or newer; found node location: %s. %s" % (
NODE_MIN_VERSION,
nodejs,
MAYBE_FILE_A_BUG,
)
if require:
raise FatalCheckError(msg)
else:
log.warning(msg)
return
return namespace(
path=nodejs,
version=version,
str_version=".".join(str(v) for v in version),
)
set_config("NODEJS", depends_if(nodejs)(lambda p: p.path))
|