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_python//python:proto.bzl", "py_proto_library") 16load( 17 "//pw_protobuf_compiler:pw_proto_library.bzl", 18 "nanopb_proto_library", 19 "nanopb_rpc_proto_library", 20 "pw_proto_filegroup", 21 "pwpb_proto_library", 22 "raw_rpc_proto_library", 23) 24load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 25 26package(default_visibility = ["//visibility:public"]) 27 28licenses(["notice"]) 29 30cc_library( 31 name = "metric", 32 srcs = ["metric.cc"], 33 hdrs = [ 34 "public/pw_metric/global.h", 35 "public/pw_metric/metric.h", 36 ], 37 strip_include_prefix = "public", 38 deps = [ 39 "//pw_assert", 40 "//pw_containers", 41 "//pw_log", 42 "//pw_span", 43 "//pw_tokenizer:base64", 44 ], 45) 46 47cc_library( 48 name = "global", 49 srcs = ["global.cc"], 50 hdrs = [ 51 "public/pw_metric/global.h", 52 ], 53 deps = [ 54 ":metric", 55 ], 56) 57 58# Common MetricWalker/MetricWriter used by RPC service. 59cc_library( 60 name = "metric_walker", 61 hdrs = ["pw_metric_private/metric_walker.h"], 62 visibility = ["//visibility:private"], 63 deps = [ 64 ":metric", 65 "//pw_assert", 66 "//pw_containers", 67 "//pw_status", 68 "//pw_tokenizer", 69 ], 70) 71 72cc_library( 73 name = "metric_service_nanopb", 74 srcs = ["metric_service_nanopb.cc"], 75 hdrs = ["public/pw_metric/metric_service_nanopb.h"], 76 strip_include_prefix = "public", 77 deps = [ 78 ":metric", 79 ":metric_proto_nanopb_rpc", 80 ":metric_walker", 81 ], 82) 83 84cc_library( 85 name = "metric_service_pwpb", 86 srcs = ["metric_service_pwpb.cc"], 87 hdrs = ["public/pw_metric/metric_service_pwpb.h"], 88 includes = [ 89 "metric_proto_cc.pwpb.pb/pw_metric", 90 "metric_proto_cc.raw_rpc.pb/pw_metric", 91 ], 92 strip_include_prefix = "public", 93 deps = [ 94 ":metric", 95 ":metric_proto_pwpb", 96 ":metric_proto_raw_rpc", 97 ":metric_walker", 98 "//pw_assert", 99 "//pw_bytes", 100 "//pw_containers", 101 "//pw_preprocessor", 102 "//pw_rpc/raw:server_api", 103 "//pw_span", 104 "//pw_status", 105 ], 106) 107 108pw_proto_filegroup( 109 name = "metric_proto_and_options", 110 srcs = [ 111 "pw_metric_proto/metric_service.proto", 112 ], 113 options_files = [ 114 "pw_metric_proto/metric_service.options", 115 "pw_metric_proto/metric_service.pwpb_options", 116 ], 117) 118 119proto_library( 120 name = "metric_proto", 121 srcs = [":metric_proto_and_options"], 122 strip_import_prefix = "/pw_metric", 123) 124 125py_proto_library( 126 name = "metric_proto_py_pb2", 127 deps = [":metric_proto"], 128) 129 130pwpb_proto_library( 131 name = "metric_proto_pwpb", 132 deps = [":metric_proto"], 133) 134 135nanopb_proto_library( 136 name = "metric_proto_nanopb", 137 deps = [":metric_proto"], 138) 139 140nanopb_rpc_proto_library( 141 name = "metric_proto_nanopb_rpc", 142 nanopb_proto_library_deps = [":metric_proto_nanopb"], 143 deps = [":metric_proto"], 144) 145 146raw_rpc_proto_library( 147 name = "metric_proto_raw_rpc", 148 deps = [":metric_proto"], 149) 150 151pw_cc_test( 152 name = "metric_test", 153 srcs = [ 154 "metric_test.cc", 155 ], 156 deps = [ 157 ":metric", 158 ], 159) 160 161pw_cc_test( 162 name = "global_test", 163 srcs = [ 164 "global_test.cc", 165 ], 166 # TODO: https://pwbug.dev/325509758 - Doesn't work on the Pico yet; has test 167 # failures. 168 target_compatible_with = select({ 169 "//pw_build/constraints/chipset:rp2040": ["@platforms//:incompatible"], 170 "//conditions:default": [], 171 }), 172 deps = [ 173 ":global", 174 ], 175) 176 177pw_cc_test( 178 name = "metric_service_nanopb_test", 179 srcs = [ 180 "metric_service_nanopb_test.cc", 181 ], 182 deps = [ 183 ":metric_service_nanopb", 184 "//pw_rpc/nanopb:test_method_context", 185 ], 186) 187 188pw_cc_test( 189 name = "metric_service_pwpb_test", 190 srcs = [ 191 "metric_service_pwpb_test.cc", 192 ], 193 deps = [ 194 ":metric_service_pwpb", 195 "//pw_rpc/pwpb:test_method_context", 196 "//pw_rpc/raw:test_method_context", 197 ], 198) 199