forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.bzl
69 lines (63 loc) · 1.79 KB
/
header.bzl
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
_browser_names = [
"android",
"chrome",
"firefox",
"ie",
"ios",
]
def _closure_lang_file_impl(ctx):
binaries = {}
suffixes = ["_%s" % n for n in _browser_names]
for d in ctx.attr.deps:
if getattr(d, "closure_js_binary", None):
name = d.label.name.replace("-", "_")
for suffix in suffixes:
if name.endswith(suffix):
name = name[0:-len(suffix)]
binaries.update({name: d.closure_js_binary.bin})
args = ctx.actions.args()
args.add(ctx.attr.lang)
args.add(ctx.outputs.out)
args.add(ctx.attr.preamble)
args.add(ctx.attr.utf8)
for key in sorted(binaries.keys()):
args.add(key)
args.add(binaries[key])
ctx.actions.run(
executable = ctx.executable._lang_gen,
arguments = [args],
inputs = binaries.values(),
outputs = [
ctx.outputs.out,
],
)
return [
DefaultInfo(files = depset([ctx.outputs.out])),
]
closure_lang_file = rule(
_closure_lang_file_impl,
attrs = {
"deps": attr.label_list(
allow_empty = False,
allow_files = False,
),
"lang": attr.string(
values = ["cc", "hdecl", "hh", "java"],
mandatory = True,
),
"preamble": attr.string(
default = "",
),
"out": attr.output(),
"_lang_gen": attr.label(
default = "//javascript/private:gen_file",
executable = True,
cfg = "host",
),
"utf8": attr.bool(
doc = "Generate utf8 or not. UTF8 with generate string and char. " +
"If false, genereation with use wchar_t and wstring. Defaults to False",
default = False,
),
},
)