• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# gRPC Bazel BUILD file.
2#
3# Copyright 2019 The gRPC authors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17load("@rules_proto//proto:defs.bzl", "proto_library")
18load(
19    "@com_github_grpc_grpc//bazel:python_rules.bzl",
20    "py2and3_test",
21    "py_grpc_library",
22    "py_proto_library",
23)
24
25package(default_testonly = 1)
26
27proto_library(
28    name = "helloworld_proto",
29    srcs = ["helloworld.proto"],
30    deps = [
31        "@com_google_protobuf//:duration_proto",
32        "@com_google_protobuf//:timestamp_proto",
33    ],
34)
35
36py_proto_library(
37    name = "helloworld_py_pb2",
38    deps = [":helloworld_proto"],
39)
40
41py_grpc_library(
42    name = "helloworld_py_pb2_grpc",
43    srcs = [":helloworld_proto"],
44    deps = [":helloworld_py_pb2"],
45)
46
47py_proto_library(
48    name = "duration_py_pb2",
49    deps = ["@com_google_protobuf//:duration_proto"],
50)
51
52py_proto_library(
53    name = "timestamp_py_pb2",
54    deps = ["@com_google_protobuf//:timestamp_proto"],
55)
56
57py2and3_test(
58    name = "import_test",
59    srcs = ["helloworld.py"],
60    main = "helloworld.py",
61    deps = [
62        ":duration_py_pb2",
63        ":helloworld_py_pb2",
64        ":helloworld_py_pb2_grpc",
65        ":timestamp_py_pb2",
66    ],
67)
68
69# Test compatibility of py_proto_library and py_grpc_library rules with
70# proto_library targets as deps when the latter use import_prefix and/or
71# strip_import_prefix arguments
72#
73# See namespaced/upper/example for more encompassing tests.
74proto_library(
75    name = "helloworld_moved_proto",
76    srcs = ["helloworld.proto"],
77    import_prefix = "google/cloud",
78    strip_import_prefix = "",
79    deps = [
80        "@com_google_protobuf//:duration_proto",
81        "@com_google_protobuf//:timestamp_proto",
82    ],
83)
84
85# Also test the custom plugin execution parameter
86py_proto_library(
87    name = "helloworld_moved_py_pb2",
88    plugin = ":dummy_plugin",
89    deps = [":helloworld_moved_proto"],
90)
91
92py_grpc_library(
93    name = "helloworld_moved_py_pb2_grpc",
94    srcs = [":helloworld_moved_proto"],
95    deps = [":helloworld_moved_py_pb2"],
96)
97
98py2and3_test(
99    name = "import_moved_test",
100    srcs = ["helloworld_moved.py"],
101    main = "helloworld_moved.py",
102    deps = [
103        ":duration_py_pb2",
104        ":helloworld_moved_py_pb2",
105        ":helloworld_moved_py_pb2_grpc",
106        ":timestamp_py_pb2",
107    ],
108)
109
110py_binary(
111    name = "dummy_plugin",
112    srcs = [":dummy_plugin.py"],
113    deps = [
114        "@com_google_protobuf//:protobuf_python",
115    ],
116)
117