Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_metric / BUILD.gn
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
15 import("//build_overrides/pigweed.gni")
16
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")
23
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
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 = [
66       ":metric_service_proto.nanopb_rpc",
67       ":pw_metric",
68     ]
69     public = [ "public/pw_metric/metric_service_nanopb.h" ]
70     deps = [
71       ":metric_service_proto.nanopb_rpc",
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
90 pw_test_group("tests") {
91   tests = [
92     ":metric_test",
93     ":global_test",
94   ]
95   if (dir_pw_third_party_nanopb != "") {
96     tests += [ ":metric_service_nanopb_test" ]
97   }
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 }
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 }