blob: 3fc335c38a70a6c4236877ae947c58b726a21918 [file] [log] [blame]
Keir Mierle45fa7852020-08-10 21:09:54 -07001# 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
Keir Mierle45fa7852020-08-10 21:09:54 -070015import("//build_overrides/pigweed.gni")
16
Keir Mierle9b51cdf2020-08-19 09:46:19 -070017import("$dir_pw_bloat/bloat.gni")
Keir Mierle45fa7852020-08-10 21:09:54 -070018import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
Keir Mierlef4dfd872020-08-12 20:53:26 -070020import("$dir_pw_protobuf_compiler/proto.gni")
21import("$dir_pw_third_party/nanopb/nanopb.gni")
Keir Mierle45fa7852020-08-10 21:09:54 -070022import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070023
Keir Mierle45fa7852020-08-10 21:09:54 -070024config("default_config") {
25 include_dirs = [ "public" ]
26}
27
28pw_source_set("pw_metric") {
29 public_configs = [ ":default_config" ]
30 public = [ "public/pw_metric/metric.h" ]
31 sources = [ "metric.cc" ]
32 public_deps = [
33 "$dir_pw_tokenizer:base64",
34 dir_pw_assert,
35 dir_pw_containers,
36 dir_pw_log,
37 dir_pw_tokenizer,
38 ]
39}
40
41# This gives access to the "PW_METRIC_GLOBAL()" macros, for globally-registered
42# metric definitions.
43pw_source_set("global") {
44 public_configs = [ ":default_config" ]
45 public = [ "public/pw_metric/global.h" ]
46 sources = [ "global.cc" ]
47 public_deps = [
48 ":pw_metric",
49 dir_pw_tokenizer,
50 ]
Wyatt Heplerc66851d2021-06-16 09:55:13 -070051 deps = [ dir_pw_polyfill ]
Keir Mierle45fa7852020-08-10 21:09:54 -070052}
53
Keir Mierlef4dfd872020-08-12 20:53:26 -070054################################################################################
55# Service
56pw_proto_library("metric_service_proto") {
57 sources = [ "pw_metric_proto/metric_service.proto" ]
58 inputs = [ "pw_metric_proto/metric_service.options" ]
59}
60
61# TODO(keir): Consider moving the nanopb service into the nanopb/ directory
62# instead of having it directly inside pw_metric/.
63if (dir_pw_third_party_nanopb != "") {
64 pw_source_set("metric_service_nanopb") {
65 public_configs = [ ":default_config" ]
66 public_deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -070067 ":metric_service_proto.nanopb_rpc",
Keir Mierlef4dfd872020-08-12 20:53:26 -070068 ":pw_metric",
69 ]
70 public = [ "public/pw_metric/metric_service_nanopb.h" ]
71 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -070072 ":metric_service_proto.nanopb_rpc",
Keir Mierlef4dfd872020-08-12 20:53:26 -070073 "$dir_pw_containers:vector",
74 dir_pw_tokenizer,
75 ]
76 sources = [ "metric_service_nanopb.cc" ]
77 }
78
79 pw_test("metric_service_nanopb_test") {
80 deps = [
81 ":global",
82 ":metric_service_nanopb",
83 "$dir_pw_rpc/nanopb:test_method_context",
84 ]
85 sources = [ "metric_service_nanopb_test.cc" ]
86 }
87}
88
89################################################################################
90
Keir Mierle45fa7852020-08-10 21:09:54 -070091pw_test_group("tests") {
92 tests = [
93 ":metric_test",
94 ":global_test",
95 ]
Keir Mierlef4dfd872020-08-12 20:53:26 -070096 if (dir_pw_third_party_nanopb != "") {
Alexei Frolovd98a99d2020-10-20 13:51:24 -070097 tests += [ ":metric_service_nanopb_test" ]
Keir Mierlef4dfd872020-08-12 20:53:26 -070098 }
Keir Mierle45fa7852020-08-10 21:09:54 -070099}
100
101pw_test("metric_test") {
102 sources = [ "metric_test.cc" ]
103 deps = [ ":pw_metric" ]
104}
105
106pw_test("global_test") {
107 sources = [ "global_test.cc" ]
108 deps = [ ":global" ]
109}
Keir Mierle9b51cdf2020-08-19 09:46:19 -0700110
111pw_size_report("metric_size_report") {
112 title = "Typical pw_metric use (no RPC service)"
113
114 # To see all the symbols, uncomment the following:
115 # Note: The size report RST table won't be generated when full_report = true.
116 #full_report = true
117
118 binaries = [
119 {
120 target = "size_report:one_metric"
121 base = "size_report:base"
122 label = "1 metric and 1 group no dump or export"
123 },
124 {
125 target = "size_report:dump"
126 base = "size_report:base"
127 label = "(+) dump group and metrics to log"
128 },
129 {
130 target = "size_report:more_metrics"
131 base = "size_report:dump"
132 label = "(+) 1 group (+) 4 metrics"
133 },
134 ]
135}
136
137pw_doc_group("docs") {
138 sources = [ "docs.rst" ]
139 report_deps = [ ":metric_size_report" ]
140}