xref: /aosp_15_r20/external/pigweed/pw_rpc_transport/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 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("@rules_proto//proto:defs.bzl", "proto_library")
16load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
17load(
18    "//pw_protobuf_compiler:pw_proto_library.bzl",
19    "pw_proto_filegroup",
20    "pwpb_proto_library",
21    "pwpb_rpc_proto_library",
22)
23load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
24
25package(default_visibility = ["//visibility:public"])
26
27licenses(["notice"])
28
29cc_library(
30    name = "rpc_transport",
31    hdrs = ["public/pw_rpc_transport/rpc_transport.h"],
32    strip_include_prefix = "public",
33    deps = [
34        "//pw_bytes",
35        "//pw_function",
36        "//pw_status",
37    ],
38)
39
40cc_library(
41    name = "service_registry",
42    hdrs = ["public/pw_rpc_transport/service_registry.h"],
43    strip_include_prefix = "public",
44    deps = [
45        ":rpc_transport",
46        "//pw_rpc:client_server",
47        "//pw_span",
48        "//pw_status",
49    ],
50)
51
52cc_library(
53    name = "test_loopback_service_registry",
54    hdrs = ["public/pw_rpc_transport/test_loopback_service_registry.h"],
55    strip_include_prefix = "public",
56    deps = [
57        ":egress_ingress",
58        ":service_registry",
59        "//pw_work_queue",
60        "//pw_work_queue:test_thread_header",
61    ],
62)
63
64cc_library(
65    name = "packet_buffer_queue",
66    hdrs = ["public/pw_rpc_transport/internal/packet_buffer_queue.h"],
67    strip_include_prefix = "public",
68    deps = [
69        "//pw_assert",
70        "//pw_bytes",
71        "//pw_containers",
72        "//pw_log",
73        "//pw_result",
74        "//pw_status",
75        "//pw_sync:lock_annotations",
76        "//pw_sync:mutex",
77    ],
78)
79
80pw_cc_test(
81    name = "packet_buffer_queue_test",
82    srcs = [
83        "internal/packet_buffer_queue_test.cc",
84    ],
85    deps = [
86        ":packet_buffer_queue",
87        "//pw_bytes",
88        "//pw_containers",
89        "//pw_result",
90        "//pw_status",
91        "//pw_sync:lock_annotations",
92        "//pw_sync:mutex",
93    ],
94)
95
96cc_library(
97    name = "local_rpc_egress",
98    srcs = ["local_rpc_egress.cc"],
99    hdrs = ["public/pw_rpc_transport/local_rpc_egress.h"],
100    strip_include_prefix = "public",
101    deps = [
102        ":packet_buffer_queue",
103        ":rpc_transport",
104        ":test_protos_pwpb_rpc",
105        "//pw_bytes",
106        "//pw_log",
107        "//pw_result",
108        "//pw_rpc:client_server",
109        "//pw_status",
110        "//pw_sync:thread_notification",
111        "//pw_thread:thread_core",
112    ],
113)
114
115pw_cc_test(
116    name = "local_rpc_egress_test",
117    srcs = [
118        "local_rpc_egress_test.cc",
119    ],
120    # TODO: b/343986281 - update to run on all compatible devices
121    target_compatible_with = incompatible_with_mcu(),
122    deps = [
123        ":local_rpc_egress",
124        ":rpc_transport",
125        ":service_registry",
126        ":test_protos_pwpb_rpc",
127        "//pw_bytes",
128        "//pw_chrono:system_clock",
129        "//pw_rpc:client_server",
130        "//pw_status",
131        "//pw_sync:counting_semaphore",
132        "//pw_sync:thread_notification",
133        "//pw_thread:sleep",
134        "//pw_thread:thread",
135    ],
136)
137
138cc_library(
139    name = "hdlc_framing",
140    hdrs = [
141        "public/pw_rpc_transport/hdlc_framing.h",
142    ],
143    strip_include_prefix = "public",
144    deps = [
145        ":rpc_transport",
146        "//pw_bytes",
147        "//pw_hdlc",
148        "//pw_hdlc:default_addresses",
149        "//pw_result",
150        "//pw_status",
151        "//pw_stream",
152    ],
153)
154
155pw_cc_test(
156    name = "hdlc_framing_test",
157    srcs = [
158        "hdlc_framing_test.cc",
159    ],
160    deps = [
161        ":hdlc_framing",
162        "//pw_bytes",
163        "//pw_status",
164    ],
165)
166
167cc_library(
168    name = "simple_framing",
169    srcs = [
170        "simple_framing.cc",
171    ],
172    hdrs = ["public/pw_rpc_transport/simple_framing.h"],
173    strip_include_prefix = "public",
174    deps = [
175        ":rpc_transport",
176        "//pw_assert",
177        "//pw_bytes",
178        "//pw_log",
179        "//pw_status",
180    ],
181)
182
183pw_cc_test(
184    name = "simple_framing_test",
185    srcs = ["simple_framing_test.cc"],
186    deps = [
187        ":simple_framing",
188        "//pw_bytes",
189        "//pw_log",
190        "//pw_status",
191    ],
192)
193
194cc_library(
195    name = "egress_ingress",
196    srcs = [
197        "egress_ingress.cc",
198    ],
199    hdrs = ["public/pw_rpc_transport/egress_ingress.h"],
200    strip_include_prefix = "public",
201    deps = [
202        ":hdlc_framing",
203        ":rpc_transport",
204        ":simple_framing",
205        "//pw_bytes",
206        "//pw_log",
207        "//pw_metric:metric",
208        "//pw_rpc:client_server",
209        "//pw_status",
210        "//pw_sync:mutex",
211    ],
212)
213
214pw_cc_test(
215    name = "egress_ingress_test",
216    srcs = ["egress_ingress_test.cc"],
217    deps = [
218        ":egress_ingress",
219        ":service_registry",
220        ":test_protos_pwpb_rpc",
221        "//pw_bytes",
222        "//pw_metric:metric",
223        "//pw_status",
224        "//pw_sync:thread_notification",
225    ],
226)
227
228cc_library(
229    name = "socket_rpc_transport",
230    srcs = ["socket_rpc_transport.cc"],
231    hdrs = ["public/pw_rpc_transport/socket_rpc_transport.h"],
232    strip_include_prefix = "public",
233    target_compatible_with = incompatible_with_mcu(),
234    deps = [
235        ":rpc_transport",
236        "//pw_assert",
237        "//pw_chrono:system_clock",
238        "//pw_log",
239        "//pw_status",
240        "//pw_stream",
241        "//pw_stream:socket_stream",
242        "//pw_sync:lock_annotations",
243        "//pw_sync:mutex",
244        "//pw_sync:thread_notification",
245        "//pw_sync_stl:condition_variable",
246        "//pw_thread:sleep",
247        "//pw_thread:thread_core",
248    ],
249)
250
251cc_library(
252    name = "stream_rpc_frame_sender",
253    hdrs = ["public/pw_rpc_transport/stream_rpc_frame_sender.h"],
254    strip_include_prefix = "public",
255    deps = [
256        ":rpc_transport",
257        "//pw_status",
258        "//pw_stream",
259    ],
260)
261
262cc_library(
263    name = "stream_rpc_dispatcher",
264    hdrs = ["public/pw_rpc_transport/stream_rpc_dispatcher.h"],
265    strip_include_prefix = "public",
266    deps = [
267        ":egress_ingress",
268        "//pw_metric:metric",
269        "//pw_status",
270        "//pw_stream",
271    ],
272)
273
274pw_cc_test(
275    name = "socket_rpc_transport_test",
276    srcs = ["socket_rpc_transport_test.cc"],
277    target_compatible_with = incompatible_with_mcu(),
278    deps = [
279        ":socket_rpc_transport",
280        "//pw_bytes",
281        "//pw_log",
282        "//pw_status",
283        "//pw_sync:mutex",
284        "//pw_sync:thread_notification",
285        "//pw_thread:sleep",
286        "//pw_thread:thread",
287    ],
288)
289
290pw_cc_test(
291    name = "stream_rpc_dispatcher_test",
292    srcs = ["stream_rpc_dispatcher_test.cc"],
293    target_compatible_with = incompatible_with_mcu(),
294    deps = [
295        ":stream_rpc_dispatcher",
296        "//pw_bytes",
297        "//pw_log",
298        "//pw_status",
299        "//pw_sync:thread_notification",
300        "//pw_thread:thread",
301    ],
302)
303
304pw_cc_test(
305    name = "rpc_integration_test",
306    srcs = ["rpc_integration_test.cc"],
307    target_compatible_with = incompatible_with_mcu(),
308    deps = [
309        ":egress_ingress",
310        ":local_rpc_egress",
311        ":service_registry",
312        ":socket_rpc_transport",
313        ":test_protos_pwpb_rpc",
314        "//pw_chrono:system_clock",
315        "//pw_log",
316        "//pw_rpc:client_server",
317        "//pw_rpc:synchronous_client_api",
318        "//pw_string",
319        "//pw_thread:thread",
320    ],
321)
322
323pw_proto_filegroup(
324    name = "test_protos_and_options",
325    srcs = ["internal/test.proto"],
326    options_files = ["internal/test.pwpb_options"],
327)
328
329proto_library(
330    name = "test_protos",
331    srcs = [":test_protos_and_options"],
332)
333
334pwpb_proto_library(
335    name = "test_protos_pwpb",
336    deps = [":test_protos"],
337)
338
339pwpb_rpc_proto_library(
340    name = "test_protos_pwpb_rpc",
341    pwpb_proto_library_deps = [":test_protos_pwpb"],
342    deps = [":test_protos"],
343)
344