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