forked from rules-proto-grpc/rules_proto_grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go_proto_library.bzl
46 lines (41 loc) · 1.87 KB
/
go_proto_library.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
"""Generated definition of go_proto_library."""
load("//go:go_proto_compile.bzl", "go_proto_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
def go_proto_library(name, **kwargs):
# Compile protos
name_pb = name + "_pb"
go_proto_compile(
name = name_pb,
prefix_path = kwargs.get("prefix_path", kwargs.get("importpath", "")),
**{
k: v
for (k, v) in kwargs.items()
if k in proto_compile_attrs.keys() and k != "prefix_path"
} # Forward args
)
# Create go library
go_library(
name = name,
srcs = [name_pb],
deps = kwargs.get("go_deps", []) + PROTO_DEPS + kwargs.get("deps", []),
importpath = kwargs.get("importpath"),
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
PROTO_DEPS = [
"@com_github_golang_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
"@org_golang_google_protobuf//runtime/protoimpl:go_default_library",
# Well-known types
"@org_golang_google_protobuf//types/known/anypb:go_default_library",
"@org_golang_google_protobuf//types/known/apipb:go_default_library",
"@org_golang_google_protobuf//types/known/durationpb:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_google_protobuf//types/known/fieldmaskpb:go_default_library",
"@org_golang_google_protobuf//types/known/sourcecontextpb:go_default_library",
"@org_golang_google_protobuf//types/known/structpb:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
"@org_golang_google_protobuf//types/known/typepb:go_default_library",
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
]