• 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
72proto_library(
73    name = "helloworld_moved_proto",
74    srcs = ["helloworld.proto"],
75    import_prefix = "google/cloud",
76    strip_import_prefix = "",
77    deps = [
78        "@com_google_protobuf//:duration_proto",
79        "@com_google_protobuf//:timestamp_proto",
80    ],
81)
82
83# Also test the custom plugin execution parameter
84py_proto_library(
85    name = "helloworld_moved_py_pb2",
86    plugin = ":dummy_plugin",
87    deps = [":helloworld_moved_proto"],
88)
89
90py_grpc_library(
91    name = "helloworld_moved_py_pb2_grpc",
92    srcs = [":helloworld_moved_proto"],
93    deps = [":helloworld_moved_py_pb2"],
94)
95
96py2and3_test(
97    name = "import_moved_test",
98    srcs = ["helloworld_moved.py"],
99    main = "helloworld_moved.py",
100    deps = [
101        ":duration_py_pb2",
102        ":helloworld_moved_py_pb2",
103        ":helloworld_moved_py_pb2_grpc",
104        ":timestamp_py_pb2",
105    ],
106)
107
108py_binary(
109    name = "dummy_plugin",
110    srcs = [":dummy_plugin.py"],
111    deps = [
112        "@com_google_protobuf//:protobuf_python",
113    ],
114)
115