blob: 0abc44909d3955789bad99206b4821f73b8d8658 [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 ]
51}
52
Keir Mierlef4dfd872020-08-12 20:53:26 -070053################################################################################
54# Service
55pw_proto_library("metric_service_proto") {
56 sources = [ "pw_metric_proto/metric_service.proto" ]
57 inputs = [ "pw_metric_proto/metric_service.options" ]
58}
59
60# TODO(keir): Consider moving the nanopb service into the nanopb/ directory
61# instead of having it directly inside pw_metric/.
62if (dir_pw_third_party_nanopb != "") {
63 pw_source_set("metric_service_nanopb") {
64 public_configs = [ ":default_config" ]
65 public_deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -070066 ":metric_service_proto.nanopb_rpc",
Keir Mierlef4dfd872020-08-12 20:53:26 -070067 ":pw_metric",
68 ]
69 public = [ "public/pw_metric/metric_service_nanopb.h" ]
70 deps = [
Alexei Frolov8e30d462020-10-22 13:54:36 -070071 ":metric_service_proto.nanopb_rpc",
Keir Mierlef4dfd872020-08-12 20:53:26 -070072 "$dir_pw_containers:vector",
73 dir_pw_tokenizer,
74 ]
75 sources = [ "metric_service_nanopb.cc" ]
76 }
77
78 pw_test("metric_service_nanopb_test") {
79 deps = [
80 ":global",
81 ":metric_service_nanopb",
82 "$dir_pw_rpc/nanopb:test_method_context",
83 ]
84 sources = [ "metric_service_nanopb_test.cc" ]
85 }
86}
87
88################################################################################
89
Keir Mierle45fa7852020-08-10 21:09:54 -070090pw_test_group("tests") {
91 tests = [
92 ":metric_test",
93 ":global_test",
94 ]
Keir Mierlef4dfd872020-08-12 20:53:26 -070095 if (dir_pw_third_party_nanopb != "") {
Alexei Frolovd98a99d2020-10-20 13:51:24 -070096 tests += [ ":metric_service_nanopb_test" ]
Keir Mierlef4dfd872020-08-12 20:53:26 -070097 }
Keir Mierle45fa7852020-08-10 21:09:54 -070098}
99
100pw_test("metric_test") {
101 sources = [ "metric_test.cc" ]
102 deps = [ ":pw_metric" ]
103}
104
105pw_test("global_test") {
106 sources = [ "global_test.cc" ]
107 deps = [ ":global" ]
108}
Keir Mierle9b51cdf2020-08-19 09:46:19 -0700109
110pw_size_report("metric_size_report") {
111 title = "Typical pw_metric use (no RPC service)"
112
113 # To see all the symbols, uncomment the following:
114 # Note: The size report RST table won't be generated when full_report = true.
115 #full_report = true
116
117 binaries = [
118 {
119 target = "size_report:one_metric"
120 base = "size_report:base"
121 label = "1 metric and 1 group no dump or export"
122 },
123 {
124 target = "size_report:dump"
125 base = "size_report:base"
126 label = "(+) dump group and metrics to log"
127 },
128 {
129 target = "size_report:more_metrics"
130 base = "size_report:dump"
131 label = "(+) 1 group (+) 4 metrics"
132 },
133 ]
134}
135
136pw_doc_group("docs") {
137 sources = [ "docs.rst" ]
138 report_deps = [ ":metric_size_report" ]
139}