xref: /aosp_15_r20/external/pigweed/pw_rpc/raw/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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_compilation_testing/negative_compilation_test.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_sync/backend.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/raw/internal/method.h",
33    "public/pw_rpc/raw/internal/method_union.h",
34    "public/pw_rpc/raw/server_reader_writer.h",
35  ]
36  sources = [ "method.cc" ]
37  public_deps = [
38    "..:server",
39    dir_pw_bytes,
40  ]
41}
42
43pw_source_set("client_api") {
44  public_configs = [ ":public" ]
45  public = [ "public/pw_rpc/raw/client_reader_writer.h" ]
46  public_deps = [
47    "..:client",
48    dir_pw_bytes,
49  ]
50}
51
52pw_source_set("fake_channel_output") {
53  public = [ "public/pw_rpc/raw/fake_channel_output.h" ]
54  public_configs = [ ":public" ]
55  public_deps = [ "..:fake_channel_output" ]
56}
57
58pw_source_set("test_method_context") {
59  public_configs = [ ":public" ]
60  public = [ "public/pw_rpc/raw/test_method_context.h" ]
61  public_deps = [
62    ":fake_channel_output",
63    ":server_api",
64    "..:test_utils",
65    dir_pw_assert,
66    dir_pw_containers,
67  ]
68}
69
70pw_source_set("client_testing") {
71  public = [ "public/pw_rpc/raw/client_testing.h" ]
72  sources = [ "client_testing.cc" ]
73  public_deps = [
74    ":fake_channel_output",
75    "..:client",
76  ]
77  deps = [ "..:log_config" ]
78}
79
80pw_test_group("tests") {
81  tests = [
82    ":codegen_test",
83    ":client_test",
84    ":client_reader_writer_test",
85    ":method_test",
86    ":method_info_test",
87    ":method_union_test",
88    ":server_reader_writer_test",
89    ":stub_generation_test",
90    ":synchronous_call_test",
91  ]
92}
93
94pw_test("codegen_test") {
95  deps = [
96    ":client_testing",
97    ":test_method_context",
98    "..:test_protos.pwpb",
99    "..:test_protos.raw_rpc",
100    dir_pw_protobuf,
101  ]
102  sources = [ "codegen_test.cc" ]
103}
104
105pw_test("client_test") {
106  deps = [
107    ":client_api",
108    ":client_testing",
109    "..:test_utils",
110  ]
111  sources = [ "client_test.cc" ]
112}
113
114pw_test("client_reader_writer_test") {
115  deps = [
116    ":client_api",
117    ":client_testing",
118    "..:test_protos.raw_rpc",
119  ]
120  sources = [ "client_reader_writer_test.cc" ]
121}
122
123pw_test("method_test") {
124  deps = [
125    ":server_api",
126    ":service_nc_test",  # Pull in the service NC test through this test
127    "$dir_pw_containers",
128    "..:test_protos.pwpb",
129    "..:test_protos.raw_rpc",
130    "..:test_utils",
131    dir_pw_protobuf,
132  ]
133  sources = [ "method_test.cc" ]
134}
135
136pw_test("method_info_test") {
137  deps = [
138    "..:common",
139    "..:test_protos.raw_rpc",
140    "..:test_utils",
141  ]
142  sources = [ "method_info_test.cc" ]
143}
144
145pw_test("method_union_test") {
146  deps = [
147    ":server_api",
148    "..:test_protos.pwpb",
149    "..:test_utils",
150    dir_pw_protobuf,
151  ]
152  sources = [ "method_union_test.cc" ]
153}
154
155pw_test("server_reader_writer_test") {
156  deps = [
157    ":server_api",
158    ":test_method_context",
159    "..:test_protos.raw_rpc",
160  ]
161  sources = [ "server_reader_writer_test.cc" ]
162}
163
164pw_test("stub_generation_test") {
165  deps = [ "..:test_protos.raw_rpc" ]
166  sources = [ "stub_generation_test.cc" ]
167}
168
169pw_test("synchronous_call_test") {
170  deps = [
171    ":test_method_context",
172    "$dir_pw_thread:thread",
173    "$dir_pw_work_queue:pw_work_queue",
174    "$dir_pw_work_queue:stl_test_thread",
175    "$dir_pw_work_queue:test_thread",
176    "..:synchronous_client_api",
177    "..:test_protos.raw_rpc",
178  ]
179  sources = [ "synchronous_call_test.cc" ]
180  enable_if = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != ""
181
182  # TODO: https://pwbug.dev/325509758 - Doesn't work on the Pico yet; hangs
183  # indefinitely.
184  if (pw_build_EXECUTABLE_TARGET_TYPE == "pico_executable") {
185    enable_if = false
186  }
187}
188
189pw_cc_negative_compilation_test("service_nc_test") {
190  sources = [ "service_nc_test.cc" ]
191  deps = [ "..:test_protos.raw_rpc" ]
192}
193