blob: 286fc699f9de6105691d9f649586ffaf9c49fe3e [file] [log] [blame]
Yao Chend54f9dd2017-10-17 17:37:48 +00001//
Colin Crossbc2dc312018-10-26 22:34:06 -07002// Copyright (C) 2017 The Android Open Source Project
Yao Chend54f9dd2017-10-17 17:37:48 +00003//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// ==========================================================
18// Build the library for use on the host
19// ==========================================================
20cc_library_host_shared {
21 name: "libstats_proto_host",
22 srcs: [
Stefan Lafonae2df012017-11-14 09:17:21 -080023 "src/atoms.proto",
Yao Chen9c1debe2018-02-19 14:39:19 -080024 "src/atom_field_options.proto",
Yao Chend54f9dd2017-10-17 17:37:48 +000025 ],
26
27 shared_libs: [
28 "libplatformprotos",
29 ],
30
31 proto: {
32 type: "full",
33 export_proto_headers: true,
Yao Chen9c1debe2018-02-19 14:39:19 -080034 include_dirs: [
35 "external/protobuf/src",
36 ],
Yao Chend54f9dd2017-10-17 17:37:48 +000037 },
Joe Onorato62c220b2017-11-18 20:32:56 -080038
39 export_shared_lib_headers: [
40 "libplatformprotos",
41 ]
42
Yao Chend54f9dd2017-10-17 17:37:48 +000043}
44
Colin Crossbc2dc312018-10-26 22:34:06 -070045cc_defaults {
46 name: "statsd_defaults",
47 aidl: {
48 include_dirs: ["frameworks/base/core/java"],
49 },
50
51 srcs: [
52 ":statsd_aidl",
Chenjie Yuc7939cb2019-02-04 17:25:45 -080053 "src/active_config_list.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -070054 "src/anomaly/AlarmMonitor.cpp",
55 "src/anomaly/AlarmTracker.cpp",
56 "src/anomaly/AnomalyTracker.cpp",
57 "src/anomaly/DurationAnomalyTracker.cpp",
58 "src/anomaly/subscriber_util.cpp",
59 "src/condition/CombinationConditionTracker.cpp",
60 "src/condition/condition_util.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070061 "src/condition/ConditionWizard.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070062 "src/condition/SimpleConditionTracker.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -070063 "src/condition/StateConditionTracker.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070064 "src/config/ConfigKey.cpp",
65 "src/config/ConfigListener.cpp",
66 "src/config/ConfigManager.cpp",
Jonathan Nguyena0e6de12020-01-28 18:33:55 -080067 "src/experiment_ids.proto",
Yiwei Zhang7e633032019-03-01 17:25:27 -080068 "src/external/GpuStatsPuller.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070069 "src/external/Perfetto.cpp",
Tej Singh6a5c9432019-10-11 11:07:06 -070070 "src/external/PullResultReceiver.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070071 "src/external/puller_util.cpp",
Tej Singha0c89dd2019-01-25 16:39:18 -080072 "src/external/StatsCallbackPuller.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070073 "src/external/StatsPuller.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070074 "src/external/StatsPullerManager.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070075 "src/external/TrainInfoPuller.cpp",
76 "src/FieldValue.cpp",
77 "src/guardrail/StatsdStats.cpp",
78 "src/hash.cpp",
79 "src/HashableDimensionKey.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070080 "src/logd/LogEvent.cpp",
Yao Chen0f861862019-03-27 11:51:15 -070081 "src/logd/LogEventQueue.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070082 "src/matchers/CombinationLogMatchingTracker.cpp",
83 "src/matchers/EventMatcherWizard.cpp",
84 "src/matchers/matcher_util.cpp",
85 "src/matchers/SimpleLogMatchingTracker.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070086 "src/metrics/CountMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070087 "src/metrics/duration_helper/MaxDurationTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070088 "src/metrics/duration_helper/OringDurationTracker.cpp",
89 "src/metrics/DurationMetricProducer.cpp",
90 "src/metrics/EventMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070091 "src/metrics/GaugeMetricProducer.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070092 "src/metrics/MetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070093 "src/metrics/metrics_manager_util.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070094 "src/metrics/MetricsManager.cpp",
95 "src/metrics/ValueMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070096 "src/packages/UidMap.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070097 "src/shell/shell_config.proto",
98 "src/shell/ShellSubscriber.cpp",
99 "src/socket/StatsSocketListener.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700100 "src/state/StateManager.cpp",
101 "src/state/StateTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700102 "src/stats_log_util.cpp",
103 "src/statscompanion_util.cpp",
104 "src/statsd_config.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700105 "src/StatsLogProcessor.cpp",
106 "src/StatsService.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700107 "src/storage/StorageManager.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700108 "src/subscriber/IncidentdReporter.cpp",
109 "src/subscriber/SubscriberReporter.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700110 "src/uid_data.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700111 ],
112
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800113 cflags: [
Muhammad Qureshiaf77b792020-01-17 11:28:45 -0800114 "-DNEW_ENCODING_SCHEME",
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800115 ],
116
Colin Crossbc2dc312018-10-26 22:34:06 -0700117 local_include_dirs: [
118 "src",
119 ],
120
121 static_libs: [
Colin Crossbc2dc312018-10-26 22:34:06 -0700122 "android.frameworks.stats@1.0",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700123 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700124 "libcutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800125 "liblog",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800126 "libprotoutil",
127 "libstatslog",
128 "libstatssocket",
129 "libsysutils",
130 ],
131 shared_libs: [
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800132 "libbinder",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700133 "libgraphicsenv",
134 "libhidlbase",
135 "libincident",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700136 "libservices",
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800137 "libstatsmetadata",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700138 "libutils",
Colin Crossbc2dc312018-10-26 22:34:06 -0700139 ],
140}
141
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800142// ================
143// libstatsmetadata
144// ================
145
146genrule {
147 name: "atoms_info.h",
148 tools: ["stats-log-api-gen"],
149 cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h",
150 out: [
151 "atoms_info.h",
152 ],
153}
154
155genrule {
156 name: "atoms_info.cpp",
157 tools: ["stats-log-api-gen"],
158 cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp",
159 out: [
160 "atoms_info.cpp",
161 ],
162}
163
164cc_library_shared {
165 name: "libstatsmetadata",
166 host_supported: true,
167 generated_sources: [
168 "atoms_info.cpp",
169 ],
170 generated_headers: [
171 "atoms_info.h",
172 ],
173 cflags: [
174 "-Wall",
175 "-Werror",
176 ],
177 export_generated_headers: [
178 "atoms_info.h",
179 ],
180 shared_libs: [
181 "libcutils",
182 "libstatslog",
183 ],
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800184}
185
186
Colin Crossbc2dc312018-10-26 22:34:06 -0700187// =========
188// statsd
189// =========
190
191cc_binary {
192 name: "statsd",
193 defaults: ["statsd_defaults"],
194
195 srcs: ["src/main.cpp"],
196
197 cflags: [
198 "-Wall",
199 "-Wextra",
200 "-Werror",
201 "-Wno-unused-parameter",
202 // optimize for size (protobuf glop can get big)
203 "-Os",
204 // "-g",
205 // "-O0",
206 ],
207
208 product_variables: {
209 eng: {
210 // Enable sanitizer ONLY on eng builds
211 //sanitize: {
212 // address: true,
213 //},
214 },
215 debuggable: {
216 // Add a flag to enable stats log printing from statsd on debug builds.
217 cflags: ["-DVERY_VERBOSE_PRINTING"],
218 },
219 },
220
221 proto: {
222 type: "lite",
223 },
224
225 shared_libs: ["libgtest_prod"],
226
Howard Ro1260bb42018-10-29 17:22:36 -0700227 vintf_fragments: ["android.frameworks.stats@1.0-service.xml"],
228
Colin Crossbc2dc312018-10-26 22:34:06 -0700229 init_rc: ["statsd.rc"],
230}
231
232// ==============
233// statsd_test
234// ==============
235
236cc_test {
237 name: "statsd_test",
238 defaults: ["statsd_defaults"],
239 test_suites: ["device-tests"],
240
241 cflags: [
242 "-Wall",
243 "-Werror",
244 "-Wno-missing-field-initializers",
245 "-Wno-unused-variable",
246 "-Wno-unused-function",
247 "-Wno-unused-parameter",
248 ],
249
250 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700251 // atom_field_options.proto needs field_options.proto, but that is
252 // not included in libprotobuf-cpp-lite, so compile it here.
253 ":libprotobuf-internal-protos",
254
Colin Crossbc2dc312018-10-26 22:34:06 -0700255 "src/atom_field_options.proto",
256 "src/atoms.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700257 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700258 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700259 "tests/AlarmMonitor_test.cpp",
260 "tests/anomaly/AlarmTracker_test.cpp",
261 "tests/anomaly/AnomalyTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700262 "tests/condition/CombinationConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700263 "tests/condition/ConditionTimer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700264 "tests/condition/SimpleConditionTracker_test.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -0700265 "tests/condition/StateConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700266 "tests/ConfigManager_test.cpp",
267 "tests/e2e/Alarm_e2e_test.cpp",
268 "tests/e2e/Anomaly_count_e2e_test.cpp",
269 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp",
270 "tests/e2e/Attribution_e2e_test.cpp",
271 "tests/e2e/ConfigTtl_e2e_test.cpp",
tsaichristined21aacf2019-10-07 14:47:38 -0700272 "tests/e2e/CountMetric_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700273 "tests/e2e/DurationMetric_e2e_test.cpp",
274 "tests/e2e/GaugeMetric_e2e_pull_test.cpp",
275 "tests/e2e/GaugeMetric_e2e_push_test.cpp",
276 "tests/e2e/MetricActivation_e2e_test.cpp",
277 "tests/e2e/MetricConditionLink_e2e_test.cpp",
278 "tests/e2e/PartialBucket_e2e_test.cpp",
279 "tests/e2e/ValueMetric_pull_e2e_test.cpp",
280 "tests/e2e/WakelockDuration_e2e_test.cpp",
281 "tests/external/GpuStatsPuller_test.cpp",
282 "tests/external/IncidentReportArgs_test.cpp",
283 "tests/external/puller_util_test.cpp",
Tej Singh89817632019-12-09 16:58:08 -0800284 "tests/external/StatsCallbackPuller_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700285 "tests/external/StatsPuller_test.cpp",
286 "tests/FieldValue_test.cpp",
287 "tests/guardrail/StatsdStats_test.cpp",
288 "tests/indexed_priority_queue_test.cpp",
289 "tests/log_event/LogEventQueue_test.cpp",
290 "tests/LogEntryMatcher_test.cpp",
291 "tests/LogEvent_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700292 "tests/metrics/CountMetricProducer_test.cpp",
293 "tests/metrics/DurationMetricProducer_test.cpp",
294 "tests/metrics/EventMetricProducer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700295 "tests/metrics/GaugeMetricProducer_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700296 "tests/metrics/MaxDurationTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700297 "tests/metrics/metrics_test_helper.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700298 "tests/metrics/OringDurationTracker_test.cpp",
299 "tests/metrics/ValueMetricProducer_test.cpp",
300 "tests/MetricsManager_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700301 "tests/shell/ShellSubscriber_test.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700302 "tests/state/StateTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700303 "tests/statsd_test_util.cpp",
304 "tests/StatsLogProcessor_test.cpp",
305 "tests/StatsService_test.cpp",
306 "tests/storage/StorageManager_test.cpp",
307 "tests/UidMap_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700308 ],
309
310 static_libs: [
311 "libgmock",
312 "libplatformprotos",
313 ],
314
315 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700316 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700317 include_dirs: ["external/protobuf/src"],
318 },
319
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800320 shared_libs: [
321 "libprotobuf-cpp-lite",
322 "libstatssocket"
323 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700324
325}
326
327//#############################
328// statsd micro benchmark
329//#############################
330
331cc_benchmark {
332 name: "statsd_benchmark",
333 defaults: ["statsd_defaults"],
334
335 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700336 // atom_field_options.proto needs field_options.proto, but that is
337 // not included in libprotobuf-cpp-lite, so compile it here.
338 ":libprotobuf-internal-protos",
339
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700340 "benchmark/duration_metric_benchmark.cpp",
341 "benchmark/filter_value_benchmark.cpp",
342 "benchmark/get_dimensions_for_condition_benchmark.cpp",
343 "benchmark/hello_world_benchmark.cpp",
344 "benchmark/log_event_benchmark.cpp",
345 "benchmark/main.cpp",
346 "benchmark/metric_util.cpp",
347 "benchmark/stats_write_benchmark.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700348 "src/atom_field_options.proto",
349 "src/atoms.proto",
350 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700351 ],
352
353 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700354 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700355 include_dirs: ["external/protobuf/src"],
356 },
357
358 cflags: [
359 "-Wall",
360 "-Werror",
361 "-Wno-unused-parameter",
362 "-Wno-unused-variable",
363 "-Wno-unused-function",
364
365 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800366 "-Wno-varargs",
Colin Crossbc2dc312018-10-26 22:34:06 -0700367 ],
368
369 static_libs: [
370 "libplatformprotos",
371 ],
372
373 shared_libs: [
374 "libgtest_prod",
Colin Cross3f51ab52018-10-26 23:28:02 -0700375 "libprotobuf-cpp-lite",
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800376 "libstatslog",
377 "libstatssocket",
Colin Crossbc2dc312018-10-26 22:34:06 -0700378 ],
379}
Joe Onorato62c220b2017-11-18 20:32:56 -0800380
gopinatha9864fd2018-08-22 16:45:57 -0700381// ==== java proto device library (for test only) ==============================
382java_library {
383 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000384 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700385 proto: {
386 type: "lite",
387 include_dirs: ["external/protobuf/src"],
388 },
389
390 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700391 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800392 "src/shell/shell_config.proto",
393 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700394 "src/stats_log.proto",
395 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700396 ],
397
398 static_libs: [
399 "platformprotoslite",
400 ],
401 // Protos have lots of MissingOverride and similar.
402 errorprone: {
403 javacflags: ["-XepDisableAllChecks"],
404 },
405}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800406
407// Filegroup for statsd config proto definition.
408filegroup {
409 name: "statsd-config-proto-def",
410 srcs: ["src/statsd_config.proto"],
411}