-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathrules.bzl
73 lines (61 loc) · 1.72 KB
/
rules.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
load("//protobuf:rules.bzl", "proto_compile", "proto_repositories")
load("//python:deps.bzl", "DEPS")
load("//cpp:rules.bzl", "cpp_proto_repositories")
def py_proto_repositories(
omit_cpp_repositories = False,
lang_deps = DEPS,
lang_requires = [
"protoc_gen_grpc_python",
], **kwargs):
if not omit_cpp_repositories:
cpp_proto_repositories(**kwargs)
proto_repositories(lang_deps = lang_deps,
lang_requires = lang_requires,
**kwargs)
def py_proto_compile(langs = [str(Label("//python"))], **kwargs):
proto_compile(langs = langs, **kwargs)
def py_proto_library(
name,
langs = [str(Label("//python"))],
protos = [],
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 = [],
py_proto_deps = [],
verbose = 0,
**kwargs):
proto_compile_args += {
"name": name + ".pb",
"protos": protos,
"deps": [dep + ".pb" for dep in proto_deps],
"langs": langs,
"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)
native.py_library(
name = name,
srcs = srcs + [name + ".pb"],
deps = depset(deps + proto_deps).to_list(),
**kwargs)