forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.bzl
More file actions
89 lines (81 loc) Β· 2.35 KB
/
rules.bzl
File metadata and controls
89 lines (81 loc) Β· 2.35 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
load("//deps/v8:bazel/defs.bzl", "v8_target_cpu_transition")
def _node_mksnapshot_impl(ctx):
out = ctx.actions.declare_file("node_snapshot.cc")
if ctx.files.srcs:
src_args = [ "--build-snapshot" ] + [x.path for x in ctx.files.srcs]
else:
src_args = []
ctx.actions.run(
outputs = [out],
inputs = ctx.files.srcs,
arguments = src_args + [ out.path ],
executable = ctx.executable.tool,
progress_message = "Running node_mksnapshot",
)
return [DefaultInfo(files = depset([out]))]
def _node_configure_impl(ctx):
out = ctx.actions.declare_file("config.gypi")
args = []
if ctx.attr.shared:
args.append("--shared")
if ctx.attr.cross_compiling:
args.append("--cross-compiling")
args += [
"--dest-os={}".format(ctx.attr.os),
"--dest-cpu={}".format(ctx.attr.cpu),
"--config-gypi-output={}".format(out.path),
]
ctx.actions.run(
outputs = [out],
inputs = ctx.files.srcs,
arguments = args,
use_default_shell_env = True,
executable = ctx.executable.configure_tool,
progress_message = "Running node_configure",
)
return [DefaultInfo(files = depset([out]))]
node_mksnapshot = rule(
implementation = _node_mksnapshot_impl,
attrs = {
"srcs": attr.label_list(
default = [],
allow_files = True,
),
"tool": attr.label(
mandatory = True,
allow_single_file = True,
executable = True,
cfg = "exec",
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
cfg = v8_target_cpu_transition,
)
node_configure = rule(
implementation = _node_configure_impl,
attrs = {
"cross_compiling": attr.bool(
mandatory = True,
),
"shared": attr.bool(
mandatory = True,
),
"cpu": attr.string(
mandatory = True,
),
"os": attr.string(
mandatory = True,
),
"srcs": attr.label_list(
default = [],
allow_files = True,
),
"configure_tool": attr.label(
mandatory = True,
executable = True,
cfg = "exec",
),
},
)