• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_build:pigweed.bzl",
18    "pw_cc_test",
19)
20load("//pw_protobuf_compiler:pw_proto_library.bzl", "pw_proto_filegroup", "pw_proto_library")
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"])
25
26cc_library(
27    name = "metric",
28    srcs = ["metric.cc"],
29    hdrs = [
30        "public/pw_metric/global.h",
31        "public/pw_metric/metric.h",
32    ],
33    includes = ["public"],
34    deps = [
35        "//pw_assert",
36        "//pw_containers",
37        "//pw_log",
38        "//pw_span",
39        "//pw_tokenizer:base64",
40    ],
41)
42
43cc_library(
44    name = "global",
45    srcs = ["global.cc"],
46    hdrs = [
47        "public/pw_metric/global.h",
48    ],
49    deps = [
50        ":metric",
51    ],
52)
53
54# Common MetricWalker/MetricWriter used by RPC service.
55cc_library(
56    name = "metric_walker",
57    hdrs = ["pw_metric_private/metric_walker.h"],
58    visibility = ["//visibility:private"],
59    deps = [
60        ":metric",
61        "//pw_assert",
62        "//pw_containers",
63        "//pw_status",
64        "//pw_tokenizer",
65    ],
66)
67
68cc_library(
69    name = "metric_service_nanopb",
70    srcs = ["metric_service_nanopb.cc"],
71    hdrs = ["public/pw_metric/metric_service_nanopb.h"],
72    deps = [
73        ":metric",
74        ":metric_proto_cc.nanopb_rpc",
75        ":metric_walker",
76    ],
77)
78
79cc_library(
80    name = "metric_service_pwpb",
81    srcs = ["metric_service_pwpb.cc"],
82    hdrs = ["public/pw_metric/metric_service_pwpb.h"],
83    includes = [
84        "metric_proto_cc.pwpb.pb/pw_metric",
85        "metric_proto_cc.raw_rpc.pb/pw_metric",
86    ],
87    deps = [
88        ":metric",
89        ":metric_proto_cc.pwpb",
90        ":metric_proto_cc.pwpb_rpc",
91        ":metric_proto_cc.raw_rpc",
92        ":metric_walker",
93        "//pw_assert",
94        "//pw_bytes",
95        "//pw_containers",
96        "//pw_preprocessor",
97        "//pw_rpc/raw:server_api",
98        "//pw_span",
99        "//pw_status",
100    ],
101)
102
103pw_proto_filegroup(
104    name = "metric_proto_and_options",
105    srcs = [
106        "pw_metric_proto/metric_service.proto",
107    ],
108    options_files = ["pw_metric_proto/metric_service.options"],
109)
110
111proto_library(
112    name = "metric_proto",
113    srcs = [":metric_proto_and_options"],
114    strip_import_prefix = "/pw_metric",
115)
116
117py_proto_library(
118    name = "metric_proto_py_pb2",
119    deps = [":metric_proto"],
120)
121
122pw_proto_library(
123    name = "metric_proto_cc",
124    deps = [":metric_proto"],
125)
126
127pw_cc_test(
128    name = "metric_test",
129    srcs = [
130        "metric_test.cc",
131    ],
132    deps = [
133        ":metric",
134    ],
135)
136
137pw_cc_test(
138    name = "global_test",
139    srcs = [
140        "global_test.cc",
141    ],
142    deps = [
143        ":global",
144    ],
145)
146
147pw_cc_test(
148    name = "metric_service_nanopb_test",
149    srcs = [
150        "metric_service_nanopb_test.cc",
151    ],
152    deps = [
153        ":metric_service_nanopb",
154        "//pw_rpc/nanopb:test_method_context",
155    ],
156)
157
158pw_cc_test(
159    name = "metric_service_pwpb_test",
160    srcs = [
161        "metric_service_pwpb_test.cc",
162    ],
163    deps = [
164        ":metric_service_pwpb",
165        "//pw_rpc/pwpb:test_method_context",
166        "//pw_rpc/raw:test_method_context",
167    ],
168)
169