1# Copyright 2022 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( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_test", 18) 19load( 20 "//pw_build:selects.bzl", 21 "TARGET_COMPATIBLE_WITH_HOST_SELECT", 22) 23 24package(default_visibility = ["//visibility:public"]) 25 26licenses(["notice"]) 27 28cc_library( 29 name = "server_api", 30 srcs = [ 31 "method.cc", 32 "server_reader_writer.cc", 33 ], 34 hdrs = [ 35 "public/pw_rpc/nanopb/internal/method.h", 36 "public/pw_rpc/nanopb/internal/method_union.h", 37 "public/pw_rpc/nanopb/server_reader_writer.h", 38 ], 39 includes = ["public"], 40 deps = [ 41 ":common", 42 "//pw_rpc/raw:server_api", 43 ], 44) 45 46cc_library( 47 name = "client_api", 48 hdrs = ["public/pw_rpc/nanopb/client_reader_writer.h"], 49 includes = ["public"], 50 deps = [ 51 ":common", 52 ], 53) 54 55cc_library( 56 name = "common", 57 srcs = ["common.cc"], 58 hdrs = [ 59 "public/pw_rpc/nanopb/internal/common.h", 60 "public/pw_rpc/nanopb/server_reader_writer.h", 61 ], 62 includes = ["public"], 63 deps = [ 64 "//pw_rpc", 65 "@com_github_nanopb_nanopb//:nanopb", 66 ], 67) 68 69cc_library( 70 name = "test_method_context", 71 hdrs = [ 72 "public/pw_rpc/nanopb/fake_channel_output.h", 73 "public/pw_rpc/nanopb/test_method_context.h", 74 ], 75 includes = ["public"], 76 deps = [ 77 "//pw_containers", 78 "//pw_rpc:internal_test_utils", 79 ], 80) 81 82cc_library( 83 name = "client_testing", 84 hdrs = [ 85 "public/pw_rpc/nanopb/client_testing.h", 86 ], 87 includes = ["public"], 88 deps = [ 89 ":test_method_context", 90 "//pw_rpc", 91 "//pw_rpc/raw:client_testing", 92 ], 93) 94 95cc_library( 96 name = "client_server_testing", 97 hdrs = [ 98 "public/pw_rpc/nanopb/client_server_testing.h", 99 ], 100 includes = ["public"], 101 deps = [ 102 ":test_method_context", 103 "//pw_rpc:client_server_testing", 104 ], 105) 106 107cc_library( 108 name = "client_server_testing_threaded", 109 hdrs = [ 110 "public/pw_rpc/nanopb/client_server_testing_threaded.h", 111 ], 112 includes = ["public"], 113 deps = [ 114 ":test_method_context", 115 "//pw_rpc:client_server_testing_threaded", 116 ], 117) 118 119cc_library( 120 name = "internal_test_utils", 121 hdrs = ["pw_rpc_nanopb_private/internal_test_utils.h"], 122 deps = ["//pw_rpc:internal_test_utils"], 123) 124 125cc_library( 126 name = "echo_service", 127 hdrs = ["public/pw_rpc/echo_service_nanopb.h"], 128 deps = [ 129 "//pw_rpc:echo_cc.nanopb_rpc", 130 ], 131) 132 133pw_cc_test( 134 name = "callback_test", 135 srcs = ["callback_test.cc"], 136 deps = [ 137 ":client_testing", 138 "//pw_rpc", 139 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 140 "//pw_sync:binary_semaphore", 141 "//pw_thread:non_portable_test_thread_options", 142 "//pw_thread:sleep", 143 "//pw_thread:yield", 144 "//pw_thread_stl:non_portable_test_thread_options", 145 ], 146) 147 148# TODO: b/242059613 - Enable this library when logging_event_handler can be used. 149filegroup( 150 name = "client_integration_test", 151 srcs = [ 152 "client_integration_test.cc", 153 ], 154 #deps = [ 155 # "//pw_rpc:integration_testing", 156 # "//pw_sync:binary_semaphore", 157 # "//pw_rpc:benchmark_cc.nanopb_rpc", 158 #] 159) 160 161pw_cc_test( 162 name = "client_call_test", 163 srcs = [ 164 "client_call_test.cc", 165 ], 166 deps = [ 167 ":client_api", 168 ":internal_test_utils", 169 "//pw_rpc", 170 "//pw_rpc:pw_rpc_test_cc.nanopb", 171 ], 172) 173 174pw_cc_test( 175 name = "client_reader_writer_test", 176 srcs = [ 177 "client_reader_writer_test.cc", 178 ], 179 deps = [ 180 ":client_api", 181 ":client_testing", 182 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 183 ], 184) 185 186pw_cc_test( 187 name = "client_server_context_test", 188 srcs = [ 189 "client_server_context_test.cc", 190 ], 191 deps = [ 192 ":client_api", 193 ":client_server_testing", 194 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 195 "//pw_sync:mutex", 196 ], 197) 198 199pw_cc_test( 200 name = "client_server_context_threaded_test", 201 srcs = [ 202 "client_server_context_threaded_test.cc", 203 ], 204 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 205 deps = [ 206 ":client_api", 207 ":client_server_testing_threaded", 208 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 209 "//pw_sync:binary_semaphore", 210 "//pw_sync:mutex", 211 "//pw_thread:non_portable_test_thread_options", 212 "//pw_thread_stl:non_portable_test_thread_options", 213 ], 214) 215 216pw_cc_test( 217 name = "codegen_test", 218 srcs = [ 219 "codegen_test.cc", 220 ], 221 deps = [ 222 ":internal_test_utils", 223 ":test_method_context", 224 "//pw_preprocessor", 225 "//pw_rpc:internal_test_utils", 226 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 227 ], 228) 229 230pw_cc_test( 231 name = "fake_channel_output_test", 232 srcs = ["fake_channel_output_test.cc"], 233 deps = [ 234 ":common", 235 ":server_api", 236 ":test_method_context", 237 "//pw_rpc:internal_test_utils", 238 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 239 ], 240) 241 242pw_cc_test( 243 name = "method_test", 244 srcs = ["method_test.cc"], 245 deps = [ 246 ":internal_test_utils", 247 ":server_api", 248 "//pw_containers", 249 "//pw_rpc", 250 "//pw_rpc:internal_test_utils", 251 "//pw_rpc:pw_rpc_test_cc.nanopb", 252 ], 253) 254 255pw_cc_test( 256 name = "method_info_test", 257 srcs = ["method_info_test.cc"], 258 deps = [ 259 "//pw_rpc", 260 "//pw_rpc:internal_test_utils", 261 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 262 ], 263) 264 265pw_cc_test( 266 name = "method_lookup_test", 267 srcs = ["method_lookup_test.cc"], 268 deps = [ 269 ":test_method_context", 270 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 271 "//pw_rpc/raw:test_method_context", 272 ], 273) 274 275pw_cc_test( 276 name = "method_union_test", 277 srcs = ["method_union_test.cc"], 278 deps = [ 279 ":internal_test_utils", 280 ":server_api", 281 "//pw_rpc:internal_test_utils", 282 "//pw_rpc:pw_rpc_test_cc.nanopb", 283 ], 284) 285 286# TODO: b/234874064 - Requires nanopb options file support to compile. 287filegroup( 288 name = "echo_service_test", 289 srcs = ["echo_service_test.cc"], 290 # deps = [ 291 # ":echo_service", 292 # ":test_method_context", 293 # ], 294) 295 296pw_cc_test( 297 name = "server_reader_writer_test", 298 srcs = ["server_reader_writer_test.cc"], 299 deps = [ 300 ":server_api", 301 ":test_method_context", 302 "//pw_rpc", 303 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 304 ], 305) 306 307pw_cc_test( 308 name = "serde_test", 309 srcs = ["serde_test.cc"], 310 deps = [ 311 ":common", 312 "//pw_rpc:pw_rpc_test_cc.nanopb", 313 ], 314) 315 316pw_cc_test( 317 name = "server_callback_test", 318 srcs = ["server_callback_test.cc"], 319 deps = [ 320 ":test_method_context", 321 "//pw_rpc", 322 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 323 "@com_github_nanopb_nanopb//:nanopb", 324 ], 325) 326 327pw_cc_test( 328 name = "stub_generation_test", 329 srcs = ["stub_generation_test.cc"], 330 deps = [ 331 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 332 ], 333) 334 335pw_cc_test( 336 name = "synchronous_call_test", 337 srcs = ["synchronous_call_test.cc"], 338 deps = [ 339 ":test_method_context", 340 "//pw_rpc:pw_rpc_test_cc.nanopb_rpc", 341 "//pw_rpc:synchronous_client_api", 342 "//pw_work_queue", 343 "//pw_work_queue:stl_test_thread", 344 "//pw_work_queue:test_thread_header", 345 ], 346) 347