forked from pubref/rules_protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.bzl
More file actions
186 lines (156 loc) · 5.08 KB
/
rules.bzl
File metadata and controls
186 lines (156 loc) · 5.08 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//protobuf:rules.bzl", "proto_compile", "proto_repositories")
load("//go:rules.bzl", "go_proto_repositories")
load("//go:deps.bzl", GO_DEPS = "DEPS")
load("//gogo:deps.bzl", GOGO_DEPS = "DEPS")
def gogo_proto_repositories(
lang_deps = GO_DEPS + GOGO_DEPS,
lang_requires = [
"com_github_golang_protobuf",
"com_github_golang_glog",
"org_golang_google_grpc",
"org_golang_x_net",
"com_github_gogo_protobuf",
], **kwargs):
go_proto_repositories(lang_deps = lang_deps,
lang_requires = lang_requires,
**kwargs)
PB_COMPILE_DEPS = [
"@com_github_gogo_protobuf//proto:go_default_library",
]
GRPC_COMPILE_DEPS = PB_COMPILE_DEPS + [
"@com_github_golang_glog//:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context:go_default_library",
]
def gogo_proto_compile(langs = [str(Label("//gogo"))], **kwargs):
proto_compile(langs = langs, **kwargs)
def gogofast_proto_compile(langs = [str(Label("//gogo:gogofast"))], **kwargs):
proto_compile(langs = langs, **kwargs)
def gogofaster_proto_compile(langs = [str(Label("//gogo:gogofaster"))], **kwargs):
proto_compile(langs = langs, **kwargs)
def gogoslick_proto_compile(langs = [str(Label("//gogo:gogoslick"))], **kwargs):
proto_compile(langs = langs, **kwargs)
def gogofast_proto_library(
name,
langs = [str(Label("//gogo:gogofast"))],
go_prefix = Label("//:go_prefix", relative_to_caller_repository=True),
protos = [],
importmap = {},
imports = [],
inputs = [],
proto_deps = [],
output_to_workspace = False,
protoc = None,
pb_plugin = None,
pb_options = [],
grpc_plugin = None,
grpc_options = [],
proto_compile_args = {},
with_grpc = True,
srcs = [],
deps = [],
go_proto_deps = [],
verbose = 0,
**kwargs):
gogo_proto_library(name, langs, go_prefix, protos, importmap, imports, inputs, proto_deps, output_to_workspace, protoc, pb_plugin, pb_options, grpc_plugin, grpc_options, proto_compile_args, with_grpc, srcs, deps, go_proto_deps, verbose, **kwargs)
def gogofaster_proto_library(
name,
langs = [str(Label("//gogo:gogofaster"))],
go_prefix = Label("//:go_prefix", relative_to_caller_repository=True),
protos = [],
importmap = {},
imports = [],
inputs = [],
proto_deps = [],
output_to_workspace = False,
protoc = None,
pb_plugin = None,
pb_options = [],
grpc_plugin = None,
grpc_options = [],
proto_compile_args = {},
with_grpc = True,
srcs = [],
deps = [],
go_proto_deps = [],
verbose = 0,
**kwargs):
gogo_proto_library(name, langs, go_prefix, protos, importmap, imports, inputs, proto_deps, output_to_workspace, protoc, pb_plugin, pb_options, grpc_plugin, grpc_options, proto_compile_args, with_grpc, srcs, deps, go_proto_deps, verbose, **kwargs)
def gogoslick_proto_library(
name,
langs = [str(Label("//gogo:gogoslick"))],
go_prefix = Label("//:go_prefix", relative_to_caller_repository=True),
protos = [],
importmap = {},
imports = [],
inputs = [],
proto_deps = [],
output_to_workspace = False,
protoc = None,
pb_plugin = None,
pb_options = [],
grpc_plugin = None,
grpc_options = [],
proto_compile_args = {},
with_grpc = True,
srcs = [],
deps = [],
go_proto_deps = [],
verbose = 0,
**kwargs):
gogo_proto_library(name, langs, go_prefix, protos, importmap, imports, inputs, proto_deps, output_to_workspace, protoc, pb_plugin, pb_options, grpc_plugin, grpc_options, proto_compile_args, with_grpc, srcs, deps, go_proto_deps, verbose, **kwargs)
def gogo_proto_library(
name,
langs = [str(Label("//gogo"))],
go_prefix = Label("//:go_prefix", relative_to_caller_repository=True),
protos = [],
importmap = {},
imports = [],
inputs = [],
proto_deps = [],
output_to_workspace = False,
protoc = None,
pb_plugin = None,
pb_options = [],
grpc_plugin = None,
grpc_options = [],
proto_compile_args = {},
with_grpc = True,
srcs = [],
deps = [],
go_proto_deps = [],
verbose = 0,
**kwargs):
if not go_proto_deps:
if with_grpc:
go_proto_deps += GRPC_COMPILE_DEPS
else:
go_proto_deps += PB_COMPILE_DEPS
proto_compile_args += {
"name": name + ".pb",
"protos": protos,
"deps": [dep + ".pb" for dep in proto_deps],
"go_prefix": go_prefix,
"langs": langs,
"importmap": importmap,
"imports": imports,
"inputs": inputs,
"pb_options": pb_options,
"grpc_options": grpc_options,
"output_to_workspace": output_to_workspace,
"verbose": verbose,
"with_grpc": with_grpc,
}
if protoc:
proto_compile_args["protoc"] = protoc
if pb_plugin:
proto_compile_args["pb_plugin"] = pb_plugin
if grpc_plugin:
proto_compile_args["grpc_plugin"] = grpc_plugin
proto_compile(**proto_compile_args)
go_library(
name = name,
srcs = srcs + [name + ".pb"],
deps = depset(deps + proto_deps + go_proto_deps).to_list(),
**kwargs)