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("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") 16load("@rules_cc//cc:cc_library.bzl", "cc_library") 17load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 18load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 19load( 20 "//pw_protobuf_compiler:pw_proto_library.bzl", 21 "pw_proto_filegroup", 22 "pwpb_proto_library", 23 "pwpb_rpc_proto_library", 24) 25load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 26 27package( 28 default_visibility = ["//visibility:public"], 29 features = ["-layering_check"], 30) 31 32licenses(["notice"]) 33 34cc_library( 35 name = "rpc_transport", 36 hdrs = ["public/pw_rpc_transport/rpc_transport.h"], 37 strip_include_prefix = "public", 38 deps = [ 39 "//pw_bytes", 40 "//pw_function", 41 "//pw_status", 42 ], 43) 44 45cc_library( 46 name = "service_registry", 47 hdrs = ["public/pw_rpc_transport/service_registry.h"], 48 strip_include_prefix = "public", 49 deps = [ 50 ":rpc_transport", 51 "//pw_rpc:client_server", 52 "//pw_span", 53 "//pw_status", 54 ], 55) 56 57cc_library( 58 name = "test_loopback_service_registry", 59 hdrs = ["public/pw_rpc_transport/test_loopback_service_registry.h"], 60 strip_include_prefix = "public", 61 deps = [ 62 ":egress_ingress", 63 ":service_registry", 64 "//pw_work_queue", 65 "//pw_work_queue:test_thread_header", 66 ], 67) 68 69cc_library( 70 name = "packet_buffer_queue", 71 hdrs = ["public/pw_rpc_transport/internal/packet_buffer_queue.h"], 72 strip_include_prefix = "public", 73 deps = [ 74 "//pw_bytes", 75 "//pw_containers:intrusive_list", 76 "//pw_log", 77 "//pw_result", 78 "//pw_status", 79 "//pw_sync:lock_annotations", 80 "//pw_sync:mutex", 81 ], 82) 83 84pw_cc_test( 85 name = "packet_buffer_queue_test", 86 srcs = [ 87 "internal/packet_buffer_queue_test.cc", 88 ], 89 deps = [ 90 ":packet_buffer_queue", 91 "//pw_bytes", 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 strip_include_prefix = "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 = incompatible_with_mcu(), 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 strip_include_prefix = "public", 147 deps = [ 148 ":rpc_transport", 149 "//pw_bytes", 150 "//pw_hdlc", 151 "//pw_hdlc:default_addresses", 152 "//pw_result", 153 "//pw_status", 154 "//pw_stream", 155 ], 156) 157 158pw_cc_test( 159 name = "hdlc_framing_test", 160 srcs = [ 161 "hdlc_framing_test.cc", 162 ], 163 deps = [ 164 ":hdlc_framing", 165 "//pw_bytes", 166 "//pw_status", 167 ], 168) 169 170cc_library( 171 name = "simple_framing", 172 srcs = [ 173 "simple_framing.cc", 174 ], 175 hdrs = ["public/pw_rpc_transport/simple_framing.h"], 176 strip_include_prefix = "public", 177 deps = [ 178 ":rpc_transport", 179 "//pw_assert:assert", 180 "//pw_bytes", 181 "//pw_log", 182 "//pw_status", 183 ], 184) 185 186pw_cc_test( 187 name = "simple_framing_test", 188 srcs = ["simple_framing_test.cc"], 189 deps = [ 190 ":simple_framing", 191 "//pw_bytes", 192 "//pw_log", 193 "//pw_status", 194 ], 195) 196 197cc_library( 198 name = "egress_ingress", 199 srcs = [ 200 "egress_ingress.cc", 201 ], 202 hdrs = ["public/pw_rpc_transport/egress_ingress.h"], 203 strip_include_prefix = "public", 204 deps = [ 205 ":hdlc_framing", 206 ":rpc_transport", 207 ":simple_framing", 208 "//pw_bytes", 209 "//pw_log", 210 "//pw_metric:metric", 211 "//pw_rpc:client_server", 212 "//pw_status", 213 "//pw_sync:mutex", 214 ], 215) 216 217pw_cc_test( 218 name = "egress_ingress_test", 219 srcs = ["egress_ingress_test.cc"], 220 deps = [ 221 ":egress_ingress", 222 ":service_registry", 223 ":test_protos_pwpb_rpc", 224 "//pw_bytes", 225 "//pw_metric:metric", 226 "//pw_status", 227 "//pw_sync:thread_notification", 228 ], 229) 230 231cc_library( 232 name = "socket_rpc_transport", 233 srcs = ["socket_rpc_transport.cc"], 234 hdrs = ["public/pw_rpc_transport/socket_rpc_transport.h"], 235 strip_include_prefix = "public", 236 target_compatible_with = incompatible_with_mcu(), 237 deps = [ 238 ":rpc_transport", 239 "//pw_assert:assert", 240 "//pw_chrono:system_clock", 241 "//pw_log", 242 "//pw_status", 243 "//pw_stream", 244 "//pw_stream:socket_stream", 245 "//pw_sync:lock_annotations", 246 "//pw_sync:mutex", 247 "//pw_sync:thread_notification", 248 "//pw_sync_stl:condition_variable", 249 "//pw_thread:sleep", 250 "//pw_thread:thread_core", 251 ], 252) 253 254cc_library( 255 name = "stream_rpc_frame_sender", 256 hdrs = ["public/pw_rpc_transport/stream_rpc_frame_sender.h"], 257 strip_include_prefix = "public", 258 deps = [ 259 ":rpc_transport", 260 "//pw_status", 261 "//pw_stream", 262 ], 263) 264 265cc_library( 266 name = "stream_rpc_dispatcher", 267 hdrs = ["public/pw_rpc_transport/stream_rpc_dispatcher.h"], 268 strip_include_prefix = "public", 269 tags = ["noclangtidy"], 270 deps = [ 271 ":egress_ingress", 272 "//pw_metric:metric", 273 "//pw_status", 274 "//pw_stream", 275 "//pw_thread:thread_core", 276 ], 277) 278 279pw_cc_test( 280 name = "socket_rpc_transport_test", 281 srcs = ["socket_rpc_transport_test.cc"], 282 target_compatible_with = incompatible_with_mcu(), 283 deps = [ 284 ":socket_rpc_transport", 285 "//pw_bytes", 286 "//pw_log", 287 "//pw_status", 288 "//pw_sync:mutex", 289 "//pw_sync:thread_notification", 290 "//pw_thread:sleep", 291 "//pw_thread:thread", 292 ], 293) 294 295pw_cc_test( 296 name = "stream_rpc_dispatcher_test", 297 srcs = ["stream_rpc_dispatcher_test.cc"], 298 target_compatible_with = incompatible_with_mcu(), 299 deps = [ 300 ":stream_rpc_dispatcher", 301 "//pw_bytes", 302 "//pw_log", 303 "//pw_status", 304 "//pw_sync:thread_notification", 305 "//pw_thread:thread", 306 ], 307) 308 309pw_cc_test( 310 name = "rpc_integration_test", 311 srcs = ["rpc_integration_test.cc"], 312 target_compatible_with = incompatible_with_mcu(), 313 deps = [ 314 ":egress_ingress", 315 ":local_rpc_egress", 316 ":service_registry", 317 ":socket_rpc_transport", 318 ":test_protos_pwpb_rpc", 319 "//pw_chrono:system_clock", 320 "//pw_log", 321 "//pw_rpc:client_server", 322 "//pw_rpc:synchronous_client_api", 323 "//pw_string", 324 "//pw_thread:thread", 325 ], 326) 327 328pw_proto_filegroup( 329 name = "test_protos_and_options", 330 srcs = ["internal/test.proto"], 331 options_files = ["internal/test.pwpb_options"], 332) 333 334proto_library( 335 name = "test_protos", 336 srcs = [":test_protos_and_options"], 337) 338 339pwpb_proto_library( 340 name = "test_protos_pwpb", 341 deps = [":test_protos"], 342) 343 344pwpb_rpc_proto_library( 345 name = "test_protos_pwpb_rpc", 346 pwpb_proto_library_deps = [":test_protos_pwpb"], 347 deps = [":test_protos"], 348) 349 350sphinx_docs_library( 351 name = "docs", 352 srcs = [ 353 "docs.rst", 354 ], 355 prefix = "pw_rpc_transport/", 356 target_compatible_with = incompatible_with_mcu(), 357) 358