-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_defs.bzl
More file actions
90 lines (84 loc) · 2.48 KB
/
build_defs.bzl
File metadata and controls
90 lines (84 loc) · 2.48 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
90
load("//node_binding/private:napi_versions.bzl", "NAPI_VERSIONS")
# Sanitize a dependency so that it works correctly from external repositories.
def _clean_dep(dep):
return str(Label(dep))
NODE_BINDING_CC_LIBRARY_COPTS = [
# Used in node-api-headers
"-DBUILDING_NODE_EXTENSION",
# Used in node-addon-api
"-DNAPI_DISABLE_CPP_EXCEPTIONS",
"-DNODE_ADDON_API_DISABLE_DEPRECATED",
"-DNODE_ADDON_API_ENABLE_MAYBE",
] + select({
_clean_dep(":napi_version_%s_enabled" % version): ["-DNAPI_VERSION=%s" % version]
for version in NAPI_VERSIONS
}) + select({
_clean_dep(":macos"): [
"-D_DARWIN_USE_64_BIT_INODE=1",
],
"//conditions:default": [],
}) + select({
_clean_dep(":msvc_compiler"): [],
"//conditions:default": [
"-D_LARGEFILE_SOURCE",
"-D_FILE_OFFSET_BITS=64",
],
})
NODE_BINDING_CC_LIBRARY_DEPS = [
_clean_dep("@node_addon_api"),
]
def node_extension(
name,
copts = [],
linkopts = [],
deps = [],
visibility = None,
testonly = None,
**kwargs):
native.cc_binary(
name = "%s_cc_binary" % name,
testonly = testonly,
copts = copts + NODE_BINDING_CC_LIBRARY_COPTS + select({
_clean_dep(":msvc_compiler"): [],
"//conditions:default": [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
],
}),
linkopts = linkopts + select({
_clean_dep(":macos"): [
"-undefined",
"dynamic_lookup",
],
"//conditions:default": [],
}),
linkshared = True,
visibility = ["//visibility:private"],
deps = deps + NODE_BINDING_CC_LIBRARY_DEPS + select({
_clean_dep(":msvc_compiler"): [
_clean_dep("//node_binding/private:win_delay_load_hook"),
_clean_dep("//node_binding/private:node_api.lib"),
],
"//conditions:default": [],
}),
**kwargs
)
native.genrule(
name = name,
testonly = testonly,
srcs = ["%s_cc_binary" % name],
outs = ["%s.node" % name],
cmd = "cp $< $@",
visibility = visibility,
)
def node_binding_cc_library(
name,
copts = [],
deps = [],
**kwargs):
native.cc_library(
name = name,
copts = copts + NODE_BINDING_CC_LIBRARY_COPTS,
deps = deps + NODE_BINDING_CC_LIBRARY_DEPS,
**kwargs
)