blob: 25953c41886db7070c25589528bd94b5df1150c6 [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" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -070049 public_deps = [ ":common" ]
Wyatt Heplercbd09c22020-09-15 11:17:24 -070050 deps = [ dir_pw_log ]
Wyatt Heplerd1591422020-09-15 10:04:41 -070051 public = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -070052 "public/pw_rpc/server.h",
53 "public/pw_rpc/server_context.h",
Wyatt Heplerd1591422020-09-15 10:04:41 -070054 "public/pw_rpc/service.h",
55 ]
Alexei Frolov5d6d3922020-05-08 13:57:02 -070056 sources = [
Wyatt Hepler7da973a2020-06-09 10:04:48 -070057 "public/pw_rpc/internal/call.h",
Wyatt Hepler1532e522020-07-30 11:44:58 -070058 "public/pw_rpc/internal/hash.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070059 "public/pw_rpc/internal/method.h",
Wyatt Heplerafd29142020-11-23 07:58:59 -080060 "public/pw_rpc/internal/method_lookup.h",
Alexei Frolova4d71502020-10-14 12:43:14 -070061 "public/pw_rpc/internal/method_union.h",
Wyatt Hepler74e7ab62021-06-15 19:44:32 -070062 "public/pw_rpc/internal/responder.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070063 "public/pw_rpc/internal/server.h",
Wyatt Hepler74e7ab62021-06-15 19:44:32 -070064 "responder.cc",
Wyatt Heplercbd09c22020-09-15 11:17:24 -070065 "server.cc",
66 "service.cc",
Alexei Frolov5d6d3922020-05-08 13:57:02 -070067 ]
Wyatt Hepler948f5472020-06-02 16:52:28 -070068 friend = [ "./*" ]
Wyatt Hepler948f5472020-06-02 16:52:28 -070069}
70
Alexei Frolov4d2adde2020-08-04 10:19:24 -070071pw_source_set("client") {
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080072 public_configs = [ ":public_include_path" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -070073 public_deps = [ ":common" ]
74 deps = [ dir_pw_log ]
75 public = [
76 "public/pw_rpc/client.h",
77 "public/pw_rpc/internal/base_client_call.h",
78 ]
79 sources = [
80 "base_client_call.cc",
81 "client.cc",
82 ]
83}
84
Alexei Frolov3e280922021-04-12 14:53:06 -070085pw_source_set("client_server") {
86 public_configs = [ ":public_include_path" ]
87 public_deps = [
88 ":client",
89 ":server",
90 ]
91 public = [ "public/pw_rpc/client_server.h" ]
92 sources = [ "client_server.cc" ]
93}
94
Alexei Frolov4d2adde2020-08-04 10:19:24 -070095# Classes shared by the server and client.
96pw_source_set("common") {
Wyatt Heplerdb5a7cc2020-11-25 10:53:25 -080097 public_configs = [ ":public_include_path" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -070098 public_deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -070099 ":protos.pwpb",
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700100 "$dir_pw_containers:intrusive_list",
101 dir_pw_assert,
102 dir_pw_bytes,
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700103 dir_pw_status,
104 ]
105 deps = [ dir_pw_log ]
106 public = [ "public/pw_rpc/channel.h" ]
107 sources = [
108 "channel.cc",
109 "packet.cc",
110 "public/pw_rpc/internal/channel.h",
111 "public/pw_rpc/internal/method_type.h",
112 "public/pw_rpc/internal/packet.h",
113 ]
114 friend = [ "./*" ]
115}
116
Alexei Frolove39af8d2020-12-30 14:55:09 -0800117pw_source_set("synchronized_channel_output") {
118 public_configs = [ ":public_include_path" ]
119 public_deps = [
120 ":common",
Ewout van Bekkumcc9ef832021-04-08 08:51:16 -0700121 "$dir_pw_sync:lock_annotations",
Alexei Frolove39af8d2020-12-30 14:55:09 -0800122 "$dir_pw_sync:mutex",
123 ]
124 public = [ "public/pw_rpc/synchronized_channel_output.h" ]
125}
126
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700127pw_source_set("test_utils") {
128 public = [
129 "public/pw_rpc/internal/test_method.h",
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700130 "pw_rpc_private/fake_channel_output.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700131 "pw_rpc_private/internal_test_utils.h",
Wyatt Heplerb6495b32020-11-23 07:50:59 -0800132 "pw_rpc_private/method_impl_tester.h",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700133 ]
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700134 sources = [ "fake_channel_output.cc" ]
135 public_configs = [
136 ":public_include_path",
137 ":private_includes",
138 ]
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700139 public_deps = [
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700140 ":client",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700141 ":server",
Wyatt Hepler5ba80642021-06-18 12:56:17 -0700142 dir_pw_assert,
143 dir_pw_bytes,
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700144 ]
145 visibility = [ "./*" ]
146}
147
Wyatt Hepler948f5472020-06-02 16:52:28 -0700148config("private_includes") {
149 include_dirs = [ "." ]
Wyatt Hepler7da973a2020-06-09 10:04:48 -0700150 visibility = [ ":*" ]
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700151}
152
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700153pw_proto_library("protos") {
Wyatt Hepler91741472021-02-03 08:45:10 -0800154 sources = [
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800155 "echo.proto",
156 "internal/packet.proto",
Wyatt Hepler91741472021-02-03 08:45:10 -0800157 ]
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800158 inputs = [ "echo.options" ]
Wyatt Heplerba325e42021-03-08 14:23:34 -0800159 python_package = "py"
160 prefix = "pw_rpc"
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700161}
162
163pw_doc_group("docs") {
164 sources = [ "docs.rst" ]
Alexei Frolov7c7a3862020-07-16 15:36:02 -0700165 inputs = [
Wyatt Hepler752d7d32021-03-02 09:02:23 -0800166 "echo.proto",
167 "internal/packet.proto",
Alexei Frolov7c7a3862020-07-16 15:36:02 -0700168 ]
Wyatt Hepler830d26d2021-02-17 09:07:43 -0800169 group_deps = [
170 "nanopb:docs",
171 "py:docs",
172 ]
Alexei Frolovbf33d212020-09-15 17:13:45 -0700173 report_deps = [ ":server_size" ]
174}
175
176pw_size_report("server_size") {
177 title = "Pigweed RPC server size report"
178
179 binaries = [
180 {
181 target = "size_report:server_only"
182 base = "size_report:base"
183 label = "Server by itself"
184 },
185 ]
186
187 if (dir_pw_third_party_nanopb != "") {
188 binaries += [
189 {
190 target = "size_report:server_with_echo_service"
191 base = "size_report:base_with_nanopb"
192 label = "Server with a registered nanopb EchoService"
193 },
194 ]
195 }
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700196}
197
198pw_test_group("tests") {
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700199 tests = [
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700200 ":base_client_call_test",
Wyatt Hepler671946e2020-06-09 14:39:33 -0700201 ":channel_test",
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700202 ":client_test",
Alexei Frolov3e280922021-04-12 14:53:06 -0700203 ":client_server_test",
Wyatt Hepler541a1902020-10-12 08:09:47 -0700204 ":ids_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700205 ":packet_test",
Wyatt Heplerea9b8a12021-06-18 15:14:26 -0700206 ":responder_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700207 ":server_test",
Wyatt Heplerd1591422020-09-15 10:04:41 -0700208 ":service_test",
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700209 ]
Alexei Frolovb7059712020-10-07 10:02:00 -0700210 group_deps = [
211 "nanopb:tests",
212 "raw:tests",
213 ]
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700214}
215
Wyatt Hepler948f5472020-06-02 16:52:28 -0700216pw_proto_library("test_protos") {
217 sources = [ "pw_rpc_test_protos/test.proto" ]
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700218 inputs = [ "pw_rpc_test_protos/test.options" ]
Wyatt Hepler948f5472020-06-02 16:52:28 -0700219 visibility = [ "./*" ]
Alexei Frolov26e3ae62020-05-04 17:06:17 -0700220}
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700221
Wyatt Heplerea9b8a12021-06-18 15:14:26 -0700222pw_test("responder_test") {
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700223 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700224 ":server",
225 ":test_utils",
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700226 ]
Wyatt Hepler74e7ab62021-06-15 19:44:32 -0700227 sources = [ "responder_test.cc" ]
Wyatt Heplercb9d9572020-06-01 11:25:58 -0700228}
229
Wyatt Hepler671946e2020-06-09 14:39:33 -0700230pw_test("channel_test") {
231 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700232 ":server",
233 ":test_utils",
Wyatt Hepler671946e2020-06-09 14:39:33 -0700234 ]
235 sources = [ "channel_test.cc" ]
236}
237
Wyatt Hepler438caa02021-01-15 17:13:11 -0800238pw_python_action("generate_ids_test") {
Wyatt Hepler541a1902020-10-12 08:09:47 -0700239 outputs = [ "$target_gen_dir/generated_ids_test.cc" ]
Wyatt Heplerba325e42021-03-08 14:23:34 -0800240
241 script = "py/tests/ids_test.py"
Michael Spangc8b93902021-05-30 15:53:56 -0400242 args = [ "--generate-cc-test" ] + rebase_path(outputs, root_build_dir)
Wyatt Hepler438caa02021-01-15 17:13:11 -0800243 python_deps = [
244 "$dir_pw_build/py",
245 "py",
246 ]
Wyatt Hepler541a1902020-10-12 08:09:47 -0700247}
248
249pw_test("ids_test") {
250 deps = [
251 ":generate_ids_test",
252 ":server",
253 ]
254 sources = get_target_outputs(":generate_ids_test")
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700255}
256
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700257pw_test("packet_test") {
258 deps = [
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700259 ":server",
Wyatt Hepler0f262352020-07-29 09:51:27 -0700260 dir_pw_bytes,
Alexei Frolov5d6d3922020-05-08 13:57:02 -0700261 dir_pw_protobuf,
262 ]
263 sources = [ "packet_test.cc" ]
264}
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700265
Wyatt Heplerd1591422020-09-15 10:04:41 -0700266pw_test("service_test") {
267 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -0700268 ":protos.pwpb",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700269 ":server",
Wyatt Heplerd1591422020-09-15 10:04:41 -0700270 dir_pw_assert,
271 ]
272 sources = [ "service_test.cc" ]
273}
274
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700275pw_test("client_test") {
276 deps = [
277 ":client",
278 ":test_utils",
279 ]
280 sources = [ "client_test.cc" ]
281}
282
Alexei Frolov3e280922021-04-12 14:53:06 -0700283pw_test("client_server_test") {
284 deps = [
285 ":client_server",
286 ":test_utils",
287 "raw:method_union",
288 ]
289 sources = [ "client_server_test.cc" ]
290}
291
Alexei Frolov4d2adde2020-08-04 10:19:24 -0700292pw_test("base_client_call_test") {
293 deps = [
294 ":client",
295 ":test_utils",
296 ]
297 sources = [ "base_client_call_test.cc" ]
298}
299
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700300pw_test("server_test") {
301 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -0700302 ":protos.pwpb",
Wyatt Heplercbd09c22020-09-15 11:17:24 -0700303 ":server",
304 ":test_utils",
Wyatt Hepler80f26ff2020-06-01 09:30:17 -0700305 dir_pw_assert,
306 ]
307 sources = [ "server_test.cc" ]
308}