Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 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 | |
Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Keir Mierle | 9b51cdf | 2020-08-19 09:46:19 -0700 | [diff] [blame] | 17 | import("$dir_pw_bloat/bloat.gni") |
Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 18 | import("$dir_pw_build/target_types.gni") |
| 19 | import("$dir_pw_docgen/docs.gni") |
Keir Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 20 | import("$dir_pw_protobuf_compiler/proto.gni") |
| 21 | import("$dir_pw_third_party/nanopb/nanopb.gni") |
Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 22 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 23 | |
Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 24 | config("default_config") { |
| 25 | include_dirs = [ "public" ] |
| 26 | } |
| 27 | |
| 28 | pw_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. |
| 43 | pw_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 Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 53 | ################################################################################ |
| 54 | # Service |
| 55 | pw_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/. |
| 62 | if (dir_pw_third_party_nanopb != "") { |
| 63 | pw_source_set("metric_service_nanopb") { |
| 64 | public_configs = [ ":default_config" ] |
| 65 | public_deps = [ |
Alexei Frolov | 8e30d46 | 2020-10-22 13:54:36 -0700 | [diff] [blame] | 66 | ":metric_service_proto.nanopb_rpc", |
Keir Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 67 | ":pw_metric", |
| 68 | ] |
| 69 | public = [ "public/pw_metric/metric_service_nanopb.h" ] |
| 70 | deps = [ |
Alexei Frolov | 8e30d46 | 2020-10-22 13:54:36 -0700 | [diff] [blame] | 71 | ":metric_service_proto.nanopb_rpc", |
Keir Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 72 | "$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 Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 90 | pw_test_group("tests") { |
| 91 | tests = [ |
| 92 | ":metric_test", |
| 93 | ":global_test", |
| 94 | ] |
Keir Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 95 | if (dir_pw_third_party_nanopb != "") { |
Alexei Frolov | d98a99d | 2020-10-20 13:51:24 -0700 | [diff] [blame] | 96 | tests += [ ":metric_service_nanopb_test" ] |
Keir Mierle | f4dfd87 | 2020-08-12 20:53:26 -0700 | [diff] [blame] | 97 | } |
Keir Mierle | 45fa785 | 2020-08-10 21:09:54 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | pw_test("metric_test") { |
| 101 | sources = [ "metric_test.cc" ] |
| 102 | deps = [ ":pw_metric" ] |
| 103 | } |
| 104 | |
| 105 | pw_test("global_test") { |
| 106 | sources = [ "global_test.cc" ] |
| 107 | deps = [ ":global" ] |
| 108 | } |
Keir Mierle | 9b51cdf | 2020-08-19 09:46:19 -0700 | [diff] [blame] | 109 | |
| 110 | pw_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 | |
| 136 | pw_doc_group("docs") { |
| 137 | sources = [ "docs.rst" ] |
| 138 | report_deps = [ ":metric_size_report" ] |
| 139 | } |