Skip to content

Commit a0099b9

Browse files
committed
rename closure_ts_library -> closure_ts_compile
1 parent 9038a8c commit a0099b9

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
load("@bazel_skylib//lib:paths.bzl", "paths")
2+
3+
def _output_for_input(ctx, src):
4+
filename = paths.replace_extension(src.basename, ".js")
5+
return ctx.actions.declare_file(filename, sibling = src)
6+
7+
def _tsickle_action(ctx):
8+
args = ctx.actions.args()
9+
args.add_all([src.short_path for src in ctx.files.srcs])
10+
11+
inputs = ctx.files.srcs
12+
outputs = [_output_for_input(ctx, f) for f in ctx.files.srcs]
13+
14+
ctx.actions.run(
15+
mnemonic = "TsickleCompile",
16+
executable = ctx.executable._compiler,
17+
arguments = [args],
18+
inputs = inputs,
19+
outputs = outputs,
20+
env = {
21+
"BAZEL_BINDIR": ctx.bin_dir.path,
22+
"BAZEL_WORKSPACE": ctx.label.workspace_name,
23+
"BAZEL_PACKAGE": ctx.label.package,
24+
},
25+
)
26+
27+
return outputs
28+
29+
def _closure_ts_compile_impl(ctx):
30+
outputs = _tsickle_action(ctx)
31+
32+
return [DefaultInfo(
33+
files = depset(outputs),
34+
)]
35+
36+
closure_ts_compile = rule(
37+
implementation = _closure_ts_compile_impl,
38+
attrs = {
39+
"srcs": attr.label_list(
40+
doc = "list of .ts files",
41+
allow_files = True,
42+
mandatory = True,
43+
),
44+
"_compiler": attr.label(
45+
default = "//tools/tsicklecompiler",
46+
doc = "the tsickle driver tool",
47+
executable = True,
48+
cfg = "exec",
49+
),
50+
},
51+
)

0 commit comments

Comments
 (0)