xref: /aosp_15_r20/external/pigweed/pw_log_rpc/BUILD.bazel (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
15load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
16
17package(default_visibility = ["//visibility:public"])
18
19licenses(["notice"])
20
21cc_library(
22    name = "config",
23    hdrs = [
24        "public/pw_log_rpc/internal/config.h",
25    ],
26    strip_include_prefix = "public",
27    visibility = ["//visibility:private"],
28    deps = [
29        ":config_override",
30    ],
31)
32
33label_flag(
34    name = "config_override",
35    build_setting_default = "//pw_build:default_module_config",
36)
37
38cc_library(
39    name = "log_service",
40    srcs = [
41        "log_service.cc",
42    ],
43    hdrs = [
44        "public/pw_log_rpc/internal/log_config.h",
45        "public/pw_log_rpc/log_service.h",
46    ],
47    strip_include_prefix = "public",
48    deps = [
49        ":config",
50        ":log_filter",
51        ":rpc_log_drain",
52        "//pw_log",
53        "//pw_log:log_proto_pwpb",
54        "//pw_log:log_proto_raw_rpc",
55    ],
56)
57
58cc_library(
59    name = "log_filter_service",
60    srcs = ["log_filter_service.cc"],
61    hdrs = ["public/pw_log_rpc/log_filter_service.h"],
62    strip_include_prefix = "public",
63    deps = [
64        ":log_filter",
65        "//pw_log",
66        "//pw_log:log_proto_pwpb",
67        "//pw_log:log_proto_raw_rpc",
68        "//pw_protobuf",
69        "//pw_protobuf:bytes_utils",
70    ],
71)
72
73cc_library(
74    name = "log_filter",
75    srcs = [
76        "log_filter.cc",
77    ],
78    hdrs = [
79        "public/pw_log_rpc/log_filter.h",
80        "public/pw_log_rpc/log_filter_map.h",
81    ],
82    strip_include_prefix = "public",
83    deps = [
84        ":config",
85        "//pw_assert",
86        "//pw_bytes",
87        "//pw_containers:vector",
88        "//pw_log",
89        "//pw_log:log_proto_pwpb",
90        "//pw_protobuf",
91        "//pw_status",
92    ],
93)
94
95cc_library(
96    name = "rpc_log_drain",
97    srcs = [
98        "rpc_log_drain.cc",
99    ],
100    hdrs = [
101        "public/pw_log_rpc/rpc_log_drain.h",
102        "public/pw_log_rpc/rpc_log_drain_map.h",
103    ],
104    strip_include_prefix = "public",
105    deps = [
106        ":config",
107        ":log_filter",
108        "//pw_assert",
109        "//pw_chrono:system_clock",
110        "//pw_function",
111        "//pw_log:log_proto_pwpb",
112        "//pw_log:log_proto_raw_rpc",
113        "//pw_multisink",
114        "//pw_protobuf",
115        "//pw_result",
116        "//pw_status",
117        "//pw_sync:lock_annotations",
118        "//pw_sync:mutex",
119    ],
120)
121
122cc_library(
123    name = "rpc_log_drain_thread",
124    hdrs = ["public/pw_log_rpc/rpc_log_drain_thread.h"],
125    strip_include_prefix = "public",
126    deps = [
127        ":log_service",
128        ":rpc_log_drain",
129        "//pw_chrono:system_clock",
130        "//pw_multisink",
131        "//pw_result",
132        "//pw_rpc/raw:server_api",
133        "//pw_status",
134        "//pw_sync:timed_thread_notification",
135        "//pw_thread:thread",
136    ],
137)
138
139cc_library(
140    name = "test_utils",
141    testonly = True,
142    srcs = ["test_utils.cc"],
143    hdrs = ["pw_log_rpc_private/test_utils.h"],
144    deps = [
145        "//pw_bytes",
146        "//pw_containers:vector",
147        "//pw_log",
148        "//pw_log:log_proto_pwpb",
149        "//pw_log_tokenized:headers",
150        "//pw_protobuf",
151        "//pw_protobuf:bytes_utils",
152        "//pw_unit_test",
153    ],
154)
155
156pw_cc_test(
157    name = "log_service_test",
158    srcs = ["log_service_test.cc"],
159    deps = [
160        ":log_filter",
161        ":log_service",
162        ":test_utils",
163        "//pw_containers:vector",
164        "//pw_log",
165        "//pw_log:log_proto_pwpb",
166        "//pw_log:proto_utils",
167        "//pw_log_tokenized:headers",
168        "//pw_protobuf",
169        "//pw_protobuf:bytes_utils",
170        "//pw_result",
171        "//pw_rpc/raw:test_method_context",
172        "//pw_status",
173        "//pw_unit_test",
174    ],
175)
176
177pw_cc_test(
178    name = "log_filter_service_test",
179    srcs = ["log_filter_service_test.cc"],
180    deps = [
181        ":log_filter",
182        ":log_filter_service",
183        "//pw_log:log_proto_pwpb",
184        "//pw_protobuf",
185        "//pw_protobuf:bytes_utils",
186        "//pw_result",
187        "//pw_rpc/raw:test_method_context",
188        "//pw_unit_test",
189    ],
190)
191
192pw_cc_test(
193    name = "log_filter_test",
194    srcs = ["log_filter_test.cc"],
195    deps = [
196        ":log_filter",
197        "//pw_log:log_proto_pwpb",
198        "//pw_log:proto_utils",
199        "//pw_log_tokenized:headers",
200        "//pw_result",
201        "//pw_status",
202        "//pw_unit_test",
203    ],
204)
205
206pw_cc_test(
207    name = "rpc_log_drain_test",
208    srcs = ["rpc_log_drain_test.cc"],
209    # TODO: https://pwbug.dev/325509758 - Doesn't work on the Pico yet; hangs
210    # indefinitely.
211    target_compatible_with = select({
212        "//pw_build/constraints/chipset:rp2040": ["@platforms//:incompatible"],
213        "//conditions:default": [],
214    }),
215    deps = [
216        ":log_service",
217        ":rpc_log_drain",
218        ":test_utils",
219        "//pw_bytes",
220        "//pw_log:log_proto_pwpb",
221        "//pw_log:proto_utils",
222        "//pw_multisink",
223        "//pw_protobuf",
224        "//pw_rpc",
225        "//pw_rpc/raw:server_api",
226        "//pw_rpc/raw:test_method_context",
227        "//pw_status",
228        "//pw_sync:mutex",
229        "//pw_unit_test",
230    ],
231)
232