blob: d4e287ab7859d55243281a2a38049ced01965388 [file]
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 python_grpc_compile
python_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("//python:python"),
Label("//python:grpc_python"),
],
),
),
toolchains = ["@build_stack_rules_proto//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 = [python_grpc_compile_aspect],
),
),
)
# Create macro for converting attrs and passing to compile
def python_grpc_compile(**kwargs):
_rule(
verbose_string = "%s" % kwargs.get("verbose", 0),
**kwargs
)