-
Notifications
You must be signed in to change notification settings - Fork 6
/
hh.bzl
55 lines (51 loc) · 1.32 KB
/
hh.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
cmd_template = """\
#!/bin/bash
set -euo pipefail
# ls -R
/usr/bin/hhvm \
-d hhvm.repo.central.path=/tmp/proto-gen-hack.repo\
{args} \
"$@"
"""
def _hh_test(ctx):
out = ctx.outputs.out
script_content = cmd_template.format(
args = ctx.attr.hh_args,
)
ctx.actions.write(out, script_content, is_executable = True)
runfiles = ctx.runfiles(files = ctx.files.srcs)
return [DefaultInfo(executable = out, runfiles = runfiles)]
hh_test = rule(
_hh_test,
attrs = {
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
),
"hh_args": attr.string(mandatory = True),
},
outputs = {
"out": "%{name}.bin",
},
test = True,
)
# TODO this is broken because hh_client isn't following symlinks?
def _hh_client_test(ctx):
out = ctx.outputs.out
script_content = "#!/bin/bash\nset -euo pipefail\nhh_client"
ctx.actions.write(out, script_content, is_executable = True)
runfiles = ctx.runfiles(files = ctx.files.srcs)
return [DefaultInfo(executable = out, runfiles = runfiles)]
hh_client_test = rule(
_hh_client_test,
attrs = {
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
),
},
outputs = {
"out": "%{name}.bin",
},
test = True,
)