blob: 6cc8dbcfbac61c34709a24cef855a70b05f48452 [file] [log] [blame]
Wyatt Hepler01145c92021-02-05 09:07:12 -08001# Copyright 2021 The Pigweed Authors
Alexei Frolov26e3ae62020-05-04 17:06:17 -07002#
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
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Alexei Frolovbf33d212020-09-15 17:13:45 -070017import("$dir_pw_bloat/bloat.gni")
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080018import("$dir_pw_build/module_config.gni")
Wyatt Hepler91741472021-02-03 08:45:10 -080019import("$dir_pw_build/python.gni")
Wyatt Hepler438caa02021-01-15 17:13:11 -080020import("$dir_pw_build/python_action.gni")
Alexei Frolovedd2f142020-06-09 19:11:27 -070021import("$dir_pw_build/target_types.gni")
Alexei Frolov26e3ae62020-05-04 17:06:17 -070022import("$dir_pw_docgen/docs.gni")
Alexei Frolov5d6d3922020-05-08 13:57:02 -070023import("$dir_pw_protobuf_compiler/proto.gni")
Alexei Frolovbf33d212020-09-15 17:13:45 -070024import("$dir_pw_third_party/nanopb/nanopb.gni")
Alexei Frolov26e3ae62020-05-04 17:06:17 -070025import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070026
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080027declare_args() {
28 # The build target that overrides the default configuration options for this
29 # module. This should point to a source set that provides defines through a
30 # public config (which may -include a file or add defines directly).
31 pw_rpc_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
32}
33
34config("public_include_path") {
Alexei Frolov26e3ae62020-05-04 17:06:17 -070035 include_dirs = [ "public" ]
Wyatt Hepler80f26ff2020-06-01 09:30:17 -070036 visibility = [ ":*" ]
Alexei Frolov26e3ae62020-05-04 17:06:17 -070037}
38
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080039pw_source_set("config") {
40 sources = [ "public/pw_rpc/internal/config.h" ]
41 public_configs = [ ":public_include_path" ]
42 public_deps = [ pw_rpc_CONFIG ]
43 visibility = [ "./*" ]
44 friend = [ "./*" ]
45}
46
Wyatt Heplercbd09c22020-09-15 11:17:24 -070047pw_source_set("server") {
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080048 public_configs = [ ":public_include_path" ]
Wyatt Hepler379b2fc2021-06-22 22:54:33 -070049 public_deps = [
50 ":common",
51 ":config",
52 ]
Wyatt Heplercbd09c22020-09-15 11:17:24 -070053 deps = [ dir_pw_log ]
Wyatt Heplerd1591422020-09-15 10:04:41 -070054 public = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -070055 "public/pw_rpc/server.h",
56 "public/pw_rpc/server_context.h",
Wyatt Heplerd1591422020-09-15 10:04:41 -070057 "public/pw_rpc/service.h",
58 ]
Alexei Frolov5d6d3922020-05-08 13:57:02 -070059 sources = [
Wyatt Hepler7da973a2020-06-09 10:04:48 -070060 "public/pw_rpc/internal/call.h",
Wyatt Hepler1532e522020-07-30 11:44:58 -070061 "public/pw_rpc/internal/hash.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070062 "public/pw_rpc/internal/method.h",
Wyatt Heplerafd29142020-11-23 07:58:59 -080063 "public/pw_rpc/internal/method_lookup.h",
Alexei Frolova4d71502020-10-14 12:43:14 -070064 "public/pw_rpc/internal/method_union.h",
Wyatt Hepler74e7ab62021-06-15 19:44:32 -070065 "public/pw_rpc/internal/responder.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070066 "public/pw_rpc/internal/server.h",
Wyatt Hepler74e7ab62021-06-15 19:44:32 -070067 "responder.cc",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070068 "server.cc",
69 "service.cc",
Alexei Frolov5d6d3922020-05-08 13:57:02 -070070 ]
Wyatt Hepler948f5472020-06-02 16:52:28 -070071 friend = [ "./*" ]
Wyatt Hepler948f5472020-06-02 16:52:28 -070072}
73
Alexei Frolov4d2adde2020-08-04 10:19:24 -070074pw_source_set("client") {
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080075 public_configs = [ ":public_include_path" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -070076 public_deps = [ ":common" ]
77 deps = [ dir_pw_log ]
78 public = [
79 "public/pw_rpc/client.h",
80 "public/pw_rpc/internal/base_client_call.h",
81 ]
82 sources = [
83 "base_client_call.cc",
84 "client.cc",
85 ]
86}
87
Alexei Frolov3e280922021-04-12 14:53:06 -070088pw_source_set("client_server") {
89 public_configs = [ ":public_include_path" ]
90 public_deps = [
91 ":client",
92 ":server",
93 ]
94 public = [ "public/pw_rpc/client_server.h" ]
95 sources = [ "client_server.cc" ]
96}
97
Alexei Frolov4d2adde2020-08-04 10:19:24 -070098# Classes shared by the server and client.
99pw_source_set("common") {
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -0800100 public_configs = [ ":public_include_path" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700101 public_deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -0700102 ":protos.pwpb",
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700103 "$dir_pw_containers:intrusive_list",
104 dir_pw_assert,
105 dir_pw_bytes,
Wyatt Hepler01fc15b2021-06-10 18:15:59 -0700106 dir_pw_function,
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700107 dir_pw_status,
108 ]
109 deps = [ dir_pw_log ]
110 public = [ "public/pw_rpc/channel.h" ]
111 sources = [
112 "channel.cc",
113 "packet.cc",
114 "public/pw_rpc/internal/channel.h",
115 "public/pw_rpc/internal/method_type.h",
116 "public/pw_rpc/internal/packet.h",
117 ]
118 friend = [ "./*" ]
119}
120
Alexei Frolove39af8d2020-12-30 14:55:09 -0800121pw_source_set("synchronized_channel_output") {
122 public_configs = [ ":public_include_path" ]
123 public_deps = [
124 ":common",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700125 "$dir_pw_sync:lock_annotations",
Alexei Frolove39af8d2020-12-30 14:55:09 -0800126 "$dir_pw_sync:mutex",
127 ]
128 public = [ "public/pw_rpc/synchronized_channel_output.h" ]
129}
130
Wyatt Hepler31b16ea2021-07-21 08:52:02 -0700131pw_source_set("benchmark") {
132 public_configs = [ ":public_include_path" ]
133 public_deps = [ ":protos.raw_rpc" ]
134 public = [ "public/pw_rpc/benchmark.h" ]
135 sources = [ "benchmark.cc" ]
136}
137
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700138pw_source_set("test_utils") {
139 public = [
140 "public/pw_rpc/internal/test_method.h",
Wyatt Hepler07e3ba02021-07-02 00:54:13 -0700141 "public/pw_rpc/internal/test_method_context.h",
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700142 "pw_rpc_private/fake_channel_output.h",
Wyatt Hepler01fc15b2021-06-10 18:15:59 -0700143 "pw_rpc_private/fake_server_reader_writer.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700144 "pw_rpc_private/internal_test_utils.h",
Wyatt Heplerb6495b32020-11-23 07:50:59 -0800145 "pw_rpc_private/method_impl_tester.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700146 ]
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700147 sources = [ "fake_channel_output.cc" ]
148 public_configs = [
149 ":public_include_path",
150 ":private_includes",
151 ]
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700152 public_deps = [
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700153 ":client",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700154 ":server",
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700155 dir_pw_assert,
156 dir_pw_bytes,
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700157 ]
158 visibility = [ "./*" ]
159}
160
Wyatt Hepler948f5472020-06-02 16:52:28 -0700161config("private_includes") {
162 include_dirs = [ "." ]
Wyatt Hepler7da973a2020-06-09 10:04:48 -0700163 visibility = [ ":*" ]
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700164}
165
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700166pw_proto_library("protos") {
Wyatt Hepler91741472021-02-03 08:45:10 -0800167 sources = [
Wyatt Hepler31b16ea2021-07-21 08:52:02 -0700168 "benchmark.proto",
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800169 "echo.proto",
170 "internal/packet.proto",
Wyatt Hepler91741472021-02-03 08:45:10 -0800171 ]
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800172 inputs = [ "echo.options" ]
Wyatt Hepler31b16ea2021-07-21 08:52:02 -0700173 deps = [ "$dir_pw_protobuf:common_protos" ]
Wyatt Heplerba325e42021-03-08 14:23:34 -0800174 python_package = "py"
175 prefix = "pw_rpc"
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700176}
177
178pw_doc_group("docs") {
Wyatt Hepler31b16ea2021-07-21 08:52:02 -0700179 sources = [
180 "benchmark.rst",
181 "docs.rst",
182 ]
Alexei Frolov7c7a3862020-07-16 15:36:02 -0700183 inputs = [
Wyatt Hepler31b16ea2021-07-21 08:52:02 -0700184 "benchmark.proto",
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800185 "echo.proto",
186 "internal/packet.proto",
Alexei Frolov7c7a3862020-07-16 15:36:02 -0700187 ]
Wyatt Hepler830d26d2021-02-17 09:07:43 -0800188 group_deps = [
189 "nanopb:docs",
190 "py:docs",
191 ]
Alexei Frolovbf33d212020-09-15 17:13:45 -0700192 report_deps = [ ":server_size" ]
193}
194
195pw_size_report("server_size") {
196 title = "Pigweed RPC server size report"
197
198 binaries = [
199 {
200 target = "size_report:server_only"
201 base = "size_report:base"
202 label = "Server by itself"
203 },
204 ]
205
206 if (dir_pw_third_party_nanopb != "") {
207 binaries += [
208 {
209 target = "size_report:server_with_echo_service"
210 base = "size_report:base_with_nanopb"
211 label = "Server with a registered nanopb EchoService"
212 },
213 ]
214 }
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700215}
216
217pw_test_group("tests") {
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700218 tests = [
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700219 ":base_client_call_test",
Wyatt Hepler671946e2020-06-09 14:39:33 -0700220 ":channel_test",
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700221 ":client_test",
Alexei Frolov3e280922021-04-12 14:53:06 -0700222 ":client_server_test",
Wyatt Hepler541a1902020-10-12 08:09:47 -0700223 ":ids_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700224 ":packet_test",
Wyatt Heplerea9b8a12021-06-18 15:14:26 -0700225 ":responder_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700226 ":server_test",
Wyatt Heplerd1591422020-09-15 10:04:41 -0700227 ":service_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700228 ]
Alexei Frolovb7059712020-10-07 10:02:00 -0700229 group_deps = [
230 "nanopb:tests",
231 "raw:tests",
232 ]
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700233}
234
Wyatt Hepler948f5472020-06-02 16:52:28 -0700235pw_proto_library("test_protos") {
236 sources = [ "pw_rpc_test_protos/test.proto" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700237 inputs = [ "pw_rpc_test_protos/test.options" ]
Wyatt Hepler948f5472020-06-02 16:52:28 -0700238 visibility = [ "./*" ]
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700239}
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700240
Wyatt Heplerea9b8a12021-06-18 15:14:26 -0700241pw_test("responder_test") {
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700242 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700243 ":server",
244 ":test_utils",
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700245 ]
Wyatt Hepler74e7ab62021-06-15 19:44:32 -0700246 sources = [ "responder_test.cc" ]
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700247}
248
Wyatt Hepler671946e2020-06-09 14:39:33 -0700249pw_test("channel_test") {
250 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700251 ":server",
252 ":test_utils",
Wyatt Hepler671946e2020-06-09 14:39:33 -0700253 ]
254 sources = [ "channel_test.cc" ]
255}
256
Wyatt Hepler438caa02021-01-15 17:13:11 -0800257pw_python_action("generate_ids_test") {
Wyatt Hepler541a1902020-10-12 08:09:47 -0700258 outputs = [ "$target_gen_dir/generated_ids_test.cc" ]
Wyatt Heplerba325e42021-03-08 14:23:34 -0800259
260 script = "py/tests/ids_test.py"
Michael Spangc8b93902021-05-30 15:53:56 -0400261 args = [ "--generate-cc-test" ] + rebase_path(outputs, root_build_dir)
Wyatt Hepler438caa02021-01-15 17:13:11 -0800262 python_deps = [
263 "$dir_pw_build/py",
264 "py",
265 ]
Wyatt Hepler541a1902020-10-12 08:09:47 -0700266}
267
268pw_test("ids_test") {
269 deps = [
270 ":generate_ids_test",
271 ":server",
272 ]
273 sources = get_target_outputs(":generate_ids_test")
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700274}
275
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700276pw_test("packet_test") {
277 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700278 ":server",
Wyatt Hepler0f262352020-07-29 09:51:27 -0700279 dir_pw_bytes,
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700280 dir_pw_protobuf,
281 ]
282 sources = [ "packet_test.cc" ]
283}
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700284
Wyatt Heplerd1591422020-09-15 10:04:41 -0700285pw_test("service_test") {
286 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -0700287 ":protos.pwpb",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700288 ":server",
Wyatt Heplerd1591422020-09-15 10:04:41 -0700289 dir_pw_assert,
290 ]
291 sources = [ "service_test.cc" ]
292}
293
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700294pw_test("client_test") {
295 deps = [
296 ":client",
297 ":test_utils",
298 ]
299 sources = [ "client_test.cc" ]
300}
301
Alexei Frolov3e280922021-04-12 14:53:06 -0700302pw_test("client_server_test") {
303 deps = [
304 ":client_server",
305 ":test_utils",
306 "raw:method_union",
307 ]
308 sources = [ "client_server_test.cc" ]
309}
310
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700311pw_test("base_client_call_test") {
312 deps = [
313 ":client",
314 ":test_utils",
315 ]
316 sources = [ "base_client_call_test.cc" ]
317}
318
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700319pw_test("server_test") {
320 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -0700321 ":protos.pwpb",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700322 ":server",
323 ":test_utils",
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700324 dir_pw_assert,
325 ]
326 sources = [ "server_test.cc" ]
327}