-
Notifications
You must be signed in to change notification settings - Fork 9
/
untar.bzl
40 lines (35 loc) · 841 Bytes
/
untar.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
load(":util.bzl", "path_join")
def _impl(ctx):
outputs = [
ctx.actions.declare_file(f.name)
for f in ctx.attr.outs
]
args = ctx.actions.args()
args.add("-x")
args.add("--file")
args.add(ctx.file.archive)
args.add("--directory")
args.add(path_join(
ctx.bin_dir.path,
ctx.label.workspace_root,
ctx.label.package,
))
ctx.actions.run(
outputs = outputs,
inputs = ctx.files.archive,
executable = "tar",
arguments = [args],
)
return [DefaultInfo(files = depset(outputs))]
untar = rule(
implementation = _impl,
attrs = {
"archive": attr.label(
allow_single_file = True,
mandatory = True,
),
"outs": attr.output_list(
mandatory = True,
),
},
)