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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/target_types.gni") 18import("$dir_pw_docgen/docs.gni") 19import("$dir_pw_sync/backend.gni") 20import("$dir_pw_third_party/nanopb/nanopb.gni") 21import("$dir_pw_thread/backend.gni") 22import("$dir_pw_unit_test/test.gni") 23 24config("public") { 25 include_dirs = [ "public" ] 26 visibility = [ ":*" ] 27} 28 29pw_source_set("server_api") { 30 public_configs = [ ":public" ] 31 public = [ 32 "public/pw_rpc/nanopb/internal/method.h", 33 "public/pw_rpc/nanopb/internal/method_union.h", 34 "public/pw_rpc/nanopb/server_reader_writer.h", 35 ] 36 sources = [ 37 "method.cc", 38 "server_reader_writer.cc", 39 ] 40 public_deps = [ 41 ":common", 42 "$dir_pw_rpc/raw:server_api", 43 "..:config", 44 "..:server", 45 dir_pw_bytes, 46 dir_pw_span, 47 ] 48 deps = [ 49 "..:log_config", 50 dir_pw_log, 51 ] 52 allow_circular_includes_from = [ ":common" ] 53} 54 55pw_source_set("client_api") { 56 public_configs = [ ":public" ] 57 public_deps = [ 58 ":common", 59 "..:client", 60 dir_pw_function, 61 ] 62 public = [ "public/pw_rpc/nanopb/client_reader_writer.h" ] 63} 64 65pw_source_set("common") { 66 public_deps = [ 67 "..:common", 68 dir_pw_bytes, 69 ] 70 public_configs = [ ":public" ] 71 deps = [ 72 "..:client", 73 "..:log_config", 74 dir_pw_log, 75 ] 76 public = [ "public/pw_rpc/nanopb/internal/common.h" ] 77 sources = [ "common.cc" ] 78 79 if (dir_pw_third_party_nanopb != "") { 80 public_deps += [ "$dir_pw_third_party/nanopb" ] 81 } 82} 83 84pw_source_set("test_method_context") { 85 public_configs = [ ":public" ] 86 public = [ 87 "public/pw_rpc/nanopb/fake_channel_output.h", 88 "public/pw_rpc/nanopb/test_method_context.h", 89 ] 90 public_deps = [ 91 ":server_api", 92 "..:test_utils", 93 dir_pw_assert, 94 dir_pw_containers, 95 ] 96} 97 98pw_source_set("client_testing") { 99 public = [ "public/pw_rpc/nanopb/client_testing.h" ] 100 public_deps = [ 101 ":test_method_context", 102 "..:client", 103 "../raw:client_testing", 104 ] 105} 106 107pw_source_set("client_server_testing") { 108 public = [ "public/pw_rpc/nanopb/client_server_testing.h" ] 109 public_deps = [ 110 ":test_method_context", 111 "..:client_server_testing", 112 ] 113} 114 115pw_source_set("client_server_testing_threaded") { 116 public = [ "public/pw_rpc/nanopb/client_server_testing_threaded.h" ] 117 public_deps = [ 118 ":test_method_context", 119 "..:client_server_testing_threaded", 120 ] 121} 122 123pw_source_set("internal_test_utils") { 124 public = [ "pw_rpc_nanopb_private/internal_test_utils.h" ] 125 public_deps = [ dir_pw_span ] 126 if (dir_pw_third_party_nanopb != "") { 127 public_deps += [ "$dir_pw_third_party/nanopb" ] 128 } 129} 130 131pw_source_set("echo_service") { 132 public_configs = [ ":public" ] 133 public_deps = [ "..:protos.nanopb_rpc" ] 134 sources = [ "public/pw_rpc/echo_service_nanopb.h" ] 135} 136 137pw_source_set("client_integration_test") { 138 testonly = pw_unit_test_TESTONLY 139 public_configs = [ ":public" ] 140 public_deps = [ 141 "$dir_pw_sync:binary_semaphore", 142 "..:integration_testing", 143 "..:protos.nanopb_rpc", 144 dir_pw_assert, 145 dir_pw_unit_test, 146 ] 147 sources = [ "client_integration_test.cc" ] 148} 149 150pw_doc_group("docs") { 151 sources = [ "docs.rst" ] 152} 153 154pw_test_group("tests") { 155 tests = [ 156 ":callback_test", 157 ":client_call_test", 158 ":client_reader_writer_test", 159 ":client_server_context_test", 160 ":client_server_context_threaded_test", 161 ":codegen_test", 162 ":echo_service_test", 163 ":fake_channel_output_test", 164 ":method_lookup_test", 165 ":method_test", 166 ":method_info_test", 167 ":method_union_test", 168 ":server_callback_test", 169 ":server_reader_writer_test", 170 ":serde_test", 171 ":stub_generation_test", 172 ":synchronous_call_test", 173 ] 174} 175 176pw_test("callback_test") { 177 enable_if = dir_pw_third_party_nanopb != "" && 178 pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" 179 deps = [ 180 ":client_testing", 181 "$dir_pw_sync:binary_semaphore", 182 "$dir_pw_thread:non_portable_test_thread_options", 183 "$dir_pw_thread:sleep", 184 "$dir_pw_thread:yield", 185 "$dir_pw_thread_stl:non_portable_test_thread_options", 186 "..:client", 187 "..:server", 188 "..:test_protos.nanopb_rpc", 189 ] 190 sources = [ "callback_test.cc" ] 191} 192 193pw_test("client_call_test") { 194 deps = [ 195 ":client_api", 196 ":internal_test_utils", 197 "..:test_protos.nanopb", 198 "..:test_utils", 199 ] 200 sources = [ "client_call_test.cc" ] 201 enable_if = dir_pw_third_party_nanopb != "" 202 203 # TODO: https://pwbug.dev/325509758 - Doesn't work on the Pico yet; hangs 204 # indefinitely. 205 if (pw_build_EXECUTABLE_TARGET_TYPE == "pico_executable") { 206 enable_if = false 207 } 208} 209 210pw_test("client_reader_writer_test") { 211 deps = [ 212 ":client_api", 213 ":client_testing", 214 "..:test_protos.nanopb_rpc", 215 ] 216 sources = [ "client_reader_writer_test.cc" ] 217 enable_if = dir_pw_third_party_nanopb != "" 218} 219 220pw_test("client_server_context_test") { 221 deps = [ 222 ":client_api", 223 ":client_server_testing", 224 "$dir_pw_sync:mutex", 225 "..:test_protos.nanopb_rpc", 226 ] 227 sources = [ "client_server_context_test.cc" ] 228 enable_if = dir_pw_third_party_nanopb != "" && pw_sync_MUTEX_BACKEND != "" 229} 230 231_stl_threading_and_nanopb_enabled = 232 pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" && 233 pw_sync_BINARY_SEMAPHORE_BACKEND != "" && pw_sync_MUTEX_BACKEND != "" && 234 dir_pw_third_party_nanopb != "" 235 236pw_test("client_server_context_threaded_test") { 237 deps = [ 238 ":client_api", 239 ":client_server_testing_threaded", 240 "$dir_pw_sync:binary_semaphore", 241 "$dir_pw_sync:mutex", 242 "$dir_pw_thread:non_portable_test_thread_options", 243 "$dir_pw_thread_stl:non_portable_test_thread_options", 244 "..:test_protos.nanopb_rpc", 245 ] 246 sources = [ "client_server_context_threaded_test.cc" ] 247 enable_if = _stl_threading_and_nanopb_enabled 248} 249 250pw_test("codegen_test") { 251 deps = [ 252 ":client_api", 253 ":internal_test_utils", 254 ":server_api", 255 ":test_method_context", 256 "..:test_protos.nanopb_rpc", 257 "..:test_utils", 258 ] 259 sources = [ "codegen_test.cc" ] 260 enable_if = dir_pw_third_party_nanopb != "" 261} 262 263pw_test("fake_channel_output_test") { 264 deps = [ 265 ":server_api", 266 ":test_method_context", 267 "..:test_protos.nanopb_rpc", 268 ] 269 sources = [ "fake_channel_output_test.cc" ] 270 enable_if = dir_pw_third_party_nanopb != "" 271} 272 273pw_test("method_test") { 274 deps = [ 275 ":internal_test_utils", 276 ":server_api", 277 "$dir_pw_containers", 278 "..:test_protos.nanopb", 279 "..:test_utils", 280 ] 281 sources = [ "method_test.cc" ] 282 enable_if = dir_pw_third_party_nanopb != "" 283} 284 285pw_test("method_info_test") { 286 deps = [ 287 "..:common", 288 "..:test_protos.nanopb_rpc", 289 "..:test_utils", 290 ] 291 sources = [ "method_info_test.cc" ] 292 enable_if = dir_pw_third_party_nanopb != "" 293} 294 295pw_test("method_lookup_test") { 296 deps = [ 297 ":server_api", 298 ":test_method_context", 299 "..:test_protos.nanopb_rpc", 300 "..:test_utils", 301 "../raw:test_method_context", 302 ] 303 sources = [ "method_lookup_test.cc" ] 304 enable_if = dir_pw_third_party_nanopb != "" 305} 306 307pw_test("method_union_test") { 308 deps = [ 309 ":internal_test_utils", 310 ":server_api", 311 "..:test_protos.nanopb", 312 "..:test_utils", 313 ] 314 sources = [ "method_union_test.cc" ] 315 enable_if = dir_pw_third_party_nanopb != "" 316} 317 318pw_test("echo_service_test") { 319 deps = [ 320 ":echo_service", 321 ":server_api", 322 ":test_method_context", 323 ] 324 sources = [ "echo_service_test.cc" ] 325 enable_if = dir_pw_third_party_nanopb != "" 326} 327 328pw_test("serde_test") { 329 deps = [ 330 ":server_api", 331 "..:test_protos.nanopb", 332 ] 333 sources = [ "serde_test.cc" ] 334 enable_if = dir_pw_third_party_nanopb != "" 335} 336 337pw_test("server_callback_test") { 338 deps = [ 339 ":server_api", 340 ":test_method_context", 341 "..:test_protos.nanopb_rpc", 342 ] 343 sources = [ "server_callback_test.cc" ] 344 enable_if = dir_pw_third_party_nanopb != "" 345} 346 347pw_test("server_reader_writer_test") { 348 deps = [ 349 ":server_api", 350 ":test_method_context", 351 "..:test_protos.nanopb_rpc", 352 ] 353 sources = [ "server_reader_writer_test.cc" ] 354 enable_if = dir_pw_third_party_nanopb != "" 355} 356 357pw_test("stub_generation_test") { 358 deps = [ "..:test_protos.nanopb_rpc" ] 359 sources = [ "stub_generation_test.cc" ] 360 enable_if = dir_pw_third_party_nanopb != "" 361} 362 363pw_test("synchronous_call_test") { 364 deps = [ 365 ":test_method_context", 366 "$dir_pw_work_queue:pw_work_queue", 367 "$dir_pw_work_queue:stl_test_thread", 368 "$dir_pw_work_queue:test_thread", 369 "..:synchronous_client_api", 370 "..:test_protos.nanopb_rpc", 371 ] 372 sources = [ "synchronous_call_test.cc" ] 373 enable_if = dir_pw_third_party_nanopb != "" && 374 pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != "" 375 376 # TODO: https://pwbug.dev/325509758 - Doesn't work on the Pico yet; hangs 377 # indefinitely. 378 if (pw_build_EXECUTABLE_TARGET_TYPE == "pico_executable") { 379 enable_if = false 380 } 381} 382