forked from rules-proto-grpc/rules_proto_grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rust_grpc_compile.bzl
53 lines (50 loc) · 1.57 KB
/
rust_grpc_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
49
50
51
52
53
load("//:plugin.bzl", "ProtoPluginInfo")
load(
"//:aspect.bzl",
"ProtoLibraryAspectNodeInfo",
"proto_compile_aspect_attrs",
"proto_compile_aspect_impl",
"proto_compile_attrs",
"proto_compile_impl",
)
# Create aspect for rust_grpc_compile
rust_grpc_compile_aspect = aspect(
implementation = proto_compile_aspect_impl,
provides = [ProtoLibraryAspectNodeInfo],
attr_aspects = ["deps"],
attrs = dict(
proto_compile_aspect_attrs,
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//rust:rust_plugin"),
Label("//rust:grpc_rust_plugin"),
],
),
_prefix = attr.string(
doc = "String used to disambiguate aspects when generating outputs",
default = "rust_grpc_compile_aspect",
)
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)
# Create compile rule to apply aspect
_rule = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
deps = attr.label_list(
mandatory = True,
providers = [ProtoInfo, ProtoLibraryAspectNodeInfo],
aspects = [rust_grpc_compile_aspect],
),
),
)
# Create macro for converting attrs and passing to compile
def rust_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
)