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