forked from rules-proto-grpc/rules_proto_grpc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdoc_template_compile.bzl
48 lines (42 loc) · 1.39 KB
/
doc_template_compile.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
"""Generated definition of doc_template_compile."""
load(
"//:defs.bzl",
"ProtoPluginInfo",
"proto_compile_attrs",
)
load("//internal:compile.bzl", "proto_compile")
# Create compile rule
def doc_template_compile_impl(ctx): # buildifier: disable=function-docstring
# Load attrs that we pass as args
options = ctx.attr.options
extra_protoc_args = getattr(ctx.attr, "extra_protoc_args", [])
extra_protoc_files = ctx.files.extra_protoc_files
# Make mutable
options = {k: v for (k, v) in options.items()}
extra_protoc_files = [] + extra_protoc_files
# Mutate args with template
options["*"] = [
ctx.file.template.path,
ctx.attr.name,
]
extra_protoc_files.append(ctx.file.template)
# Execute with extracted attrs
return proto_compile(ctx, options, extra_protoc_args, extra_protoc_files)
doc_template_compile = rule(
implementation = doc_template_compile_impl,
attrs = dict(
proto_compile_attrs,
template = attr.label(
allow_single_file = True,
doc = "The documentation template file.",
),
_plugins = attr.label_list(
providers = [ProtoPluginInfo],
default = [
Label("//doc:template_plugin"),
],
doc = "List of protoc plugins to apply",
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)