• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("//pw_build:pigweed.bzl", "pw_cc_library", "pw_cc_test")
16load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library")
17load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
18load("@rules_proto//proto:defs.bzl", "proto_library")
19load("@rules_proto_grpc//:defs.bzl", "proto_plugin")
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"])
24
25proto_library(
26    name = "benchmark_proto",
27    srcs = [
28        "benchmark.proto",
29    ],
30)
31
32pw_proto_library(
33    name = "benchmark_cc",
34    deps = [":benchmark_proto"],
35)
36
37pw_cc_library(
38    name = "benchmark",
39    srcs = ["benchmark.cc"],
40    hdrs = ["public/pw_rpc/benchmark.h"],
41    includes = ["public"],
42    deps = [
43        ":benchmark_cc.pwpb",
44        ":benchmark_cc.raw_rpc",
45    ],
46)
47
48# TODO(pwbug/507): Build this as a cc_binary and use it in integration tests.
49filegroup(
50    name = "test_rpc_server",
51    srcs = ["test_rpc_server.cc"],
52    # deps = [
53    #     "system_server",
54    #     ":benchmark",
55    #     "//pw_log",
56    # ],
57)
58
59pw_cc_library(
60    name = "client_server",
61    srcs = ["client_server.cc"],
62    hdrs = ["public/pw_rpc/client_server.h"],
63    deps = [":pw_rpc"],
64)
65
66pw_cc_library(
67    name = "pw_rpc",
68    srcs = [
69        "call.cc",
70        "channel.cc",
71        "channel_list.cc",
72        "client.cc",
73        "client_call.cc",
74        "endpoint.cc",
75        "packet.cc",
76        "public/pw_rpc/internal/call.h",
77        "public/pw_rpc/internal/call_context.h",
78        "public/pw_rpc/internal/channel.h",
79        "public/pw_rpc/internal/channel_list.h",
80        "public/pw_rpc/internal/client_call.h",
81        "public/pw_rpc/internal/config.h",
82        "public/pw_rpc/internal/endpoint.h",
83        "public/pw_rpc/internal/hash.h",
84        "public/pw_rpc/internal/lock.h",
85        "public/pw_rpc/internal/log_config.h",
86        "public/pw_rpc/internal/method.h",
87        "public/pw_rpc/internal/method_info.h",
88        "public/pw_rpc/internal/method_lookup.h",
89        "public/pw_rpc/internal/method_union.h",
90        "public/pw_rpc/internal/packet.h",
91        "public/pw_rpc/internal/server_call.h",
92        "public/pw_rpc/method_type.h",
93        "public/pw_rpc/writer.h",
94        "server.cc",
95        "server_call.cc",
96        "service.cc",
97    ],
98    hdrs = [
99        "public/pw_rpc/channel.h",
100        "public/pw_rpc/client.h",
101        "public/pw_rpc/internal/service_client.h",
102        "public/pw_rpc/server.h",
103        "public/pw_rpc/service.h",
104    ],
105    includes = ["public"],
106    deps = [
107        ":internal_packet_cc.pwpb",
108        "//pw_assert",
109        "//pw_bytes",
110        "//pw_containers",
111        "//pw_containers:intrusive_list",
112        "//pw_function",
113        "//pw_log",
114        "//pw_result",
115        "//pw_span",
116        "//pw_status",
117        "//pw_sync:lock_annotations",
118    ],
119)
120
121pw_cc_library(
122    name = "thread_testing",
123    hdrs = ["public/pw_rpc/thread_testing.h"],
124    includes = ["public"],
125    deps = [
126        ":internal_test_utils",
127        "//pw_assert",
128        "//pw_sync:counting_semaphore",
129    ],
130)
131
132pw_cc_library(
133    name = "internal_test_utils",
134    srcs = ["fake_channel_output.cc"],
135    hdrs = [
136        "public/pw_rpc/internal/fake_channel_output.h",
137        "public/pw_rpc/internal/method_impl_tester.h",
138        "public/pw_rpc/internal/method_info_tester.h",
139        "public/pw_rpc/internal/test_method.h",
140        "public/pw_rpc/internal/test_method_context.h",
141        "public/pw_rpc/internal/test_utils.h",
142        "public/pw_rpc/payloads_view.h",
143        "pw_rpc_private/fake_server_reader_writer.h",
144    ],
145    includes = [
146        ".",
147        "public",
148    ],
149    visibility = [":__subpackages__"],
150    deps = [
151        ":pw_rpc",
152        "//pw_assert",
153        "//pw_bytes",
154        "//pw_containers:filtered_view",
155        "//pw_containers:vector",
156        "//pw_containers:wrapped_iterator",
157        "//pw_rpc/raw:fake_channel_output",
158        "//pw_span",
159        "//pw_sync:mutex",
160    ],
161)
162
163# TODO(pwbug/507): Enable this library when logging_event_handler can be used.
164filegroup(
165    name = "integration_testing",
166    srcs = [
167        "integration_testing.cc",
168        # ],
169        # hdrs = [
170        "public/pw_rpc/integration_test_socket_client.h",
171        "public/pw_rpc/integration_testing.h",
172    ],
173    #deps = [
174    #    ":client",
175    #    "//pw_assert",
176    #    "//pw_hdlc:pw_rpc",
177    #    "//pw_hdlc:rpc_channel_output",
178    #    "//pw_log",
179    #    "//pw_stream:socket_stream",
180    #    "//pw_unit_test",
181    #    "//pw_unit_test:logging_event_handler",
182    #],
183)
184
185# TODO(pwbug/507): Add the client integration test to the build.
186filegroup(
187    name = "client_integration_test",
188    srcs = ["client_integration_test.cc"],
189)
190
191pw_cc_test(
192    name = "call_test",
193    srcs = [
194        "call_test.cc",
195    ],
196    deps = [
197        ":internal_test_utils",
198        ":pw_rpc",
199    ],
200)
201
202pw_cc_test(
203    name = "channel_test",
204    srcs = ["channel_test.cc"],
205    deps = [
206        ":internal_test_utils",
207        ":pw_rpc",
208    ],
209)
210
211pw_cc_test(
212    name = "method_test",
213    srcs = ["method_test.cc"],
214    deps = [
215        ":internal_test_utils",
216        ":pw_rpc",
217    ],
218)
219
220pw_cc_test(
221    name = "packet_test",
222    srcs = [
223        "packet_test.cc",
224    ],
225    deps = [
226        ":pw_rpc",
227    ],
228)
229
230pw_cc_test(
231    name = "client_server_test",
232    srcs = ["client_server_test.cc"],
233    deps = [
234        ":client_server",
235        ":internal_test_utils",
236        "//pw_rpc/raw:server_api",
237    ],
238)
239
240pw_cc_test(
241    name = "server_test",
242    srcs = [
243        "server_test.cc",
244    ],
245    deps = [
246        ":internal_test_utils",
247        ":pw_rpc",
248        "//pw_assert",
249    ],
250)
251
252pw_cc_test(
253    name = "service_test",
254    srcs = [
255        "service_test.cc",
256    ],
257    deps = [
258        ":internal_test_utils",
259        ":pw_rpc",
260        "//pw_assert",
261    ],
262)
263
264pw_cc_test(
265    name = "fake_channel_output_test",
266    srcs = ["fake_channel_output_test.cc"],
267    deps = [":internal_test_utils"],
268)
269
270proto_library(
271    name = "internal_packet_proto",
272    srcs = ["internal/packet.proto"],
273    visibility = [":__subpackages__"],
274)
275
276java_lite_proto_library(
277    name = "packet_proto_java_lite",
278    deps = [":internal_packet_proto"],
279)
280
281py_proto_library(
282    name = "internal_packet_proto_pb2",
283    srcs = ["internal/packet.proto"],
284)
285
286pw_proto_library(
287    name = "internal_packet_cc",
288    deps = [":internal_packet_proto"],
289)
290
291proto_library(
292    name = "pw_rpc_test_proto",
293    srcs = ["pw_rpc_test_protos/test.proto"],
294    strip_import_prefix = "//pw_rpc",
295)
296
297pw_proto_library(
298    name = "pw_rpc_test_cc",
299    deps = [":pw_rpc_test_proto"],
300)
301
302proto_plugin(
303    name = "pw_cc_plugin_raw",
304    outputs = [
305        "{protopath}.raw_rpc.pb.h",
306    ],
307    protoc_plugin_name = "raw_rpc",
308    tool = "@pigweed//pw_rpc/py:plugin_raw",
309    use_built_in_shell_environment = True,
310    visibility = ["//visibility:public"],
311)
312
313proto_plugin(
314    name = "pw_cc_plugin_nanopb_rpc",
315    outputs = [
316        "{protopath}.rpc.pb.h",
317    ],
318    protoc_plugin_name = "nanopb_rpc",
319    tool = "@pigweed//pw_rpc/py:plugin_nanopb",
320    use_built_in_shell_environment = True,
321    visibility = ["//visibility:public"],
322)
323
324proto_plugin(
325    name = "nanopb_plugin",
326    options = [
327        "--library-include-format='#include\"%s\"'",
328    ],
329    outputs = [
330        "{protopath}.pb.h",
331        "{protopath}.pb.c",
332    ],
333    separate_options_flag = True,
334    tool = "@com_github_nanopb_nanopb//:bazel_generator",
335    use_built_in_shell_environment = True,
336    visibility = ["//visibility:public"],
337)
338
339proto_library(
340    name = "echo_proto",
341    srcs = [
342        "echo.proto",
343    ],
344)
345
346pw_proto_library(
347    name = "echo_cc",
348    deps = [":echo_proto"],
349    # TODO(tpudlik): We should provide echo.options to nanopb here, but the
350    # current proto codegen implementation provides no mechanism for doing so.
351)
352