1 # Copyright 2020 The Pigweed Authors
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
7 # https://www.apache.org/licenses/LICENSE-2.0
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
15 import("//build_overrides/pigweed.gni")
17 import("$dir_pw_bloat/bloat.gni")
18 import("$dir_pw_build/target_types.gni")
19 import("$dir_pw_docgen/docs.gni")
20 import("$dir_pw_protobuf_compiler/proto.gni")
21 import("$dir_pw_third_party/nanopb/nanopb.gni")
22 import("$dir_pw_unit_test/test.gni")
24 config("default_config") {
25 include_dirs = [ "public" ]
28 pw_source_set("pw_metric") {
29 public_configs = [ ":default_config" ]
30 public = [ "public/pw_metric/metric.h" ]
31 sources = [ "metric.cc" ]
33 "$dir_pw_tokenizer:base64",
41 # This gives access to the "PW_METRIC_GLOBAL()" macros, for globally-registered
43 pw_source_set("global") {
44 public_configs = [ ":default_config" ]
45 public = [ "public/pw_metric/global.h" ]
46 sources = [ "global.cc" ]
53 ################################################################################
55 pw_proto_library("metric_service_proto") {
56 sources = [ "pw_metric_proto/metric_service.proto" ]
57 inputs = [ "pw_metric_proto/metric_service.options" ]
60 # TODO(keir): Consider moving the nanopb service into the nanopb/ directory
61 # instead of having it directly inside pw_metric/.
62 if (dir_pw_third_party_nanopb != "") {
63 pw_source_set("metric_service_nanopb") {
64 public_configs = [ ":default_config" ]
66 ":metric_service_proto.nanopb_rpc",
69 public = [ "public/pw_metric/metric_service_nanopb.h" ]
71 ":metric_service_proto.nanopb_rpc",
72 "$dir_pw_containers:vector",
75 sources = [ "metric_service_nanopb.cc" ]
78 pw_test("metric_service_nanopb_test") {
81 ":metric_service_nanopb",
82 "$dir_pw_rpc/nanopb:test_method_context",
84 sources = [ "metric_service_nanopb_test.cc" ]
88 ################################################################################
90 pw_test_group("tests") {
95 if (dir_pw_third_party_nanopb != "") {
96 tests += [ ":metric_service_nanopb_test" ]
100 pw_test("metric_test") {
101 sources = [ "metric_test.cc" ]
102 deps = [ ":pw_metric" ]
105 pw_test("global_test") {
106 sources = [ "global_test.cc" ]
110 pw_size_report("metric_size_report") {
111 title = "Typical pw_metric use (no RPC service)"
113 # To see all the symbols, uncomment the following:
114 # Note: The size report RST table won't be generated when full_report = true.
119 target = "size_report:one_metric"
120 base = "size_report:base"
121 label = "1 metric and 1 group no dump or export"
124 target = "size_report:dump"
125 base = "size_report:base"
126 label = "(+) dump group and metrics to log"
129 target = "size_report:more_metrics"
130 base = "size_report:dump"
131 label = "(+) 1 group (+) 4 metrics"
136 pw_doc_group("docs") {
137 sources = [ "docs.rst" ]
138 report_deps = [ ":metric_size_report" ]