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