blob: 776593d5c795d2fb1aa9ace1ad28ab0fd809bb96 [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",
Colin Crossbc2dc312018-10-26 22:34:06 -070047
48 srcs: [
Chenjie Yuc7939cb2019-02-04 17:25:45 -080049 "src/active_config_list.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -070050 "src/anomaly/AlarmMonitor.cpp",
51 "src/anomaly/AlarmTracker.cpp",
52 "src/anomaly/AnomalyTracker.cpp",
53 "src/anomaly/DurationAnomalyTracker.cpp",
54 "src/anomaly/subscriber_util.cpp",
55 "src/condition/CombinationConditionTracker.cpp",
56 "src/condition/condition_util.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070057 "src/condition/ConditionWizard.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070058 "src/condition/SimpleConditionTracker.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -070059 "src/condition/StateConditionTracker.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070060 "src/config/ConfigKey.cpp",
61 "src/config/ConfigListener.cpp",
62 "src/config/ConfigManager.cpp",
Jonathan Nguyena0e6de12020-01-28 18:33:55 -080063 "src/experiment_ids.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -070064 "src/external/Perfetto.cpp",
Tej Singh6a5c9432019-10-11 11:07:06 -070065 "src/external/PullResultReceiver.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070066 "src/external/puller_util.cpp",
Tej Singha0c89dd2019-01-25 16:39:18 -080067 "src/external/StatsCallbackPuller.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070068 "src/external/StatsPuller.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070069 "src/external/StatsPullerManager.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070070 "src/external/TrainInfoPuller.cpp",
71 "src/FieldValue.cpp",
72 "src/guardrail/StatsdStats.cpp",
73 "src/hash.cpp",
74 "src/HashableDimensionKey.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070075 "src/logd/LogEvent.cpp",
Yao Chen0f861862019-03-27 11:51:15 -070076 "src/logd/LogEventQueue.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070077 "src/matchers/CombinationLogMatchingTracker.cpp",
78 "src/matchers/EventMatcherWizard.cpp",
79 "src/matchers/matcher_util.cpp",
80 "src/matchers/SimpleLogMatchingTracker.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070081 "src/metrics/CountMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070082 "src/metrics/duration_helper/MaxDurationTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070083 "src/metrics/duration_helper/OringDurationTracker.cpp",
84 "src/metrics/DurationMetricProducer.cpp",
85 "src/metrics/EventMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070086 "src/metrics/GaugeMetricProducer.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070087 "src/metrics/MetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070088 "src/metrics/metrics_manager_util.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070089 "src/metrics/MetricsManager.cpp",
90 "src/metrics/ValueMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070091 "src/packages/UidMap.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070092 "src/shell/shell_config.proto",
93 "src/shell/ShellSubscriber.cpp",
94 "src/socket/StatsSocketListener.cpp",
tsaichristine10978642019-09-10 14:12:49 -070095 "src/state/StateManager.cpp",
96 "src/state/StateTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070097 "src/stats_log_util.cpp",
98 "src/statscompanion_util.cpp",
99 "src/statsd_config.proto",
Jeffrey Huang8a617e02020-03-19 15:38:43 -0700100 "src/statsd_metadata.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700101 "src/StatsLogProcessor.cpp",
102 "src/StatsService.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700103 "src/storage/StorageManager.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700104 "src/subscriber/IncidentdReporter.cpp",
105 "src/subscriber/SubscriberReporter.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700106 "src/uid_data.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700107 ],
108
109 local_include_dirs: [
110 "src",
111 ],
112
113 static_libs: [
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700114 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700115 "libcutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800116 "libprotoutil",
Howard Roe5edf8c2020-02-05 18:12:14 -0800117 "libstatsmetadata",
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800118 "libstatslog_statsd",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800119 "libsysutils",
Howard Ro47807e22020-02-06 23:17:33 -0800120 "libutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800121 ],
122 shared_libs: [
Ruchir Rastogie449b0c2020-02-10 17:40:09 -0800123 "libbinder_ndk",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700124 "libincident",
Howard Roe5edf8c2020-02-05 18:12:14 -0800125 "liblog",
Ruchir Rastogie449b0c2020-02-10 17:40:09 -0800126 "statsd-aidl-ndk_platform",
Colin Crossbc2dc312018-10-26 22:34:06 -0700127 ],
128}
129
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800130// ================
131// libstatsmetadata
132// ================
133
134genrule {
135 name: "atoms_info.h",
136 tools: ["stats-log-api-gen"],
137 cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h",
138 out: [
139 "atoms_info.h",
140 ],
141}
142
143genrule {
144 name: "atoms_info.cpp",
145 tools: ["stats-log-api-gen"],
146 cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp",
147 out: [
148 "atoms_info.cpp",
149 ],
150}
151
Howard Roe5edf8c2020-02-05 18:12:14 -0800152cc_library_static {
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800153 name: "libstatsmetadata",
154 host_supported: true,
155 generated_sources: [
156 "atoms_info.cpp",
157 ],
158 generated_headers: [
159 "atoms_info.h",
160 ],
161 cflags: [
162 "-Wall",
163 "-Werror",
164 ],
165 export_generated_headers: [
166 "atoms_info.h",
167 ],
Jeffrey Huang52e90022020-02-14 10:13:44 -0800168 apex_available: [
169 //TODO(b/149782403): Remove this once statsd no longer links against libstatsmetadata
170 "com.android.os.statsd",
171 "test_com.android.os.statsd",
172 ],
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800173}
174
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800175genrule {
176 name: "statslog_statsd.h",
177 tools: ["stats-log-api-gen"],
178 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsd.h --module statsd --namespace android,os,statsd,util",
179 out: [
180 "statslog_statsd.h",
181 ],
182}
183
184genrule {
185 name: "statslog_statsd.cpp",
186 tools: ["stats-log-api-gen"],
187 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsd.cpp --module statsd --namespace android,os,statsd,util --importHeader statslog_statsd.h",
188 out: [
189 "statslog_statsd.cpp",
190 ],
191}
192
Jeffrey Huang3eb84d42020-03-17 10:31:22 -0700193genrule {
194 name: "statslog_statsdtest.h",
195 tools: ["stats-log-api-gen"],
196 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsdtest.h --module statsdtest --namespace android,os,statsd,util",
197 out: [
198 "statslog_statsdtest.h",
199 ],
200}
201
202genrule {
203 name: "statslog_statsdtest.cpp",
204 tools: ["stats-log-api-gen"],
205 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsdtest.cpp --module statsdtest --namespace android,os,statsd,util --importHeader statslog_statsdtest.h",
206 out: [
207 "statslog_statsdtest.cpp",
208 ],
209}
210
211cc_library_static {
212 name: "libstatslog_statsdtest",
213 generated_sources: ["statslog_statsdtest.cpp"],
214 generated_headers: ["statslog_statsdtest.h"],
215 export_generated_headers: ["statslog_statsdtest.h"],
216 shared_libs: [
217 "libstatssocket",
218 ]
219}
220
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800221cc_library_static {
222 name: "libstatslog_statsd",
223 generated_sources: ["statslog_statsd.cpp"],
224 generated_headers: ["statslog_statsd.h"],
225 export_generated_headers: ["statslog_statsd.h"],
226 apex_available: [
227 "com.android.os.statsd",
228 "test_com.android.os.statsd",
229 ],
230 shared_libs: [
231 "libstatssocket",
232 ]
233}
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800234
Colin Crossbc2dc312018-10-26 22:34:06 -0700235// =========
236// statsd
237// =========
238
239cc_binary {
240 name: "statsd",
241 defaults: ["statsd_defaults"],
242
243 srcs: ["src/main.cpp"],
244
245 cflags: [
246 "-Wall",
247 "-Wextra",
248 "-Werror",
249 "-Wno-unused-parameter",
250 // optimize for size (protobuf glop can get big)
251 "-Os",
252 // "-g",
253 // "-O0",
254 ],
255
256 product_variables: {
257 eng: {
258 // Enable sanitizer ONLY on eng builds
259 //sanitize: {
260 // address: true,
261 //},
262 },
263 debuggable: {
264 // Add a flag to enable stats log printing from statsd on debug builds.
265 cflags: ["-DVERY_VERBOSE_PRINTING"],
266 },
267 },
268
269 proto: {
270 type: "lite",
271 },
272
Tej Singhb3915ea2020-03-05 14:33:15 -0800273 shared_libs: [
274 "libgtest_prod",
275 "libstatssocket",
276 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700277
Howard Roadc510f2020-02-20 04:57:00 +0000278 apex_available: [
279 "com.android.os.statsd",
280 "test_com.android.os.statsd",
281 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700282}
283
284// ==============
285// statsd_test
286// ==============
287
288cc_test {
289 name: "statsd_test",
290 defaults: ["statsd_defaults"],
291 test_suites: ["device-tests"],
292
293 cflags: [
294 "-Wall",
295 "-Werror",
296 "-Wno-missing-field-initializers",
297 "-Wno-unused-variable",
298 "-Wno-unused-function",
299 "-Wno-unused-parameter",
300 ],
301
302 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700303 // atom_field_options.proto needs field_options.proto, but that is
304 // not included in libprotobuf-cpp-lite, so compile it here.
305 ":libprotobuf-internal-protos",
306
Colin Crossbc2dc312018-10-26 22:34:06 -0700307 "src/atom_field_options.proto",
308 "src/atoms.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700309 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700310 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700311 "tests/AlarmMonitor_test.cpp",
312 "tests/anomaly/AlarmTracker_test.cpp",
313 "tests/anomaly/AnomalyTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700314 "tests/condition/CombinationConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700315 "tests/condition/ConditionTimer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700316 "tests/condition/SimpleConditionTracker_test.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -0700317 "tests/condition/StateConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700318 "tests/ConfigManager_test.cpp",
319 "tests/e2e/Alarm_e2e_test.cpp",
320 "tests/e2e/Anomaly_count_e2e_test.cpp",
321 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp",
322 "tests/e2e/Attribution_e2e_test.cpp",
323 "tests/e2e/ConfigTtl_e2e_test.cpp",
tsaichristined21aacf2019-10-07 14:47:38 -0700324 "tests/e2e/CountMetric_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700325 "tests/e2e/DurationMetric_e2e_test.cpp",
326 "tests/e2e/GaugeMetric_e2e_pull_test.cpp",
327 "tests/e2e/GaugeMetric_e2e_push_test.cpp",
328 "tests/e2e/MetricActivation_e2e_test.cpp",
329 "tests/e2e/MetricConditionLink_e2e_test.cpp",
330 "tests/e2e/PartialBucket_e2e_test.cpp",
331 "tests/e2e/ValueMetric_pull_e2e_test.cpp",
332 "tests/e2e/WakelockDuration_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700333 "tests/external/puller_util_test.cpp",
Tej Singh89817632019-12-09 16:58:08 -0800334 "tests/external/StatsCallbackPuller_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700335 "tests/external/StatsPuller_test.cpp",
Tej Singh3be093b2020-03-04 20:08:38 -0800336 "tests/external/StatsPullerManager_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700337 "tests/FieldValue_test.cpp",
338 "tests/guardrail/StatsdStats_test.cpp",
339 "tests/indexed_priority_queue_test.cpp",
340 "tests/log_event/LogEventQueue_test.cpp",
341 "tests/LogEntryMatcher_test.cpp",
342 "tests/LogEvent_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700343 "tests/metrics/CountMetricProducer_test.cpp",
344 "tests/metrics/DurationMetricProducer_test.cpp",
345 "tests/metrics/EventMetricProducer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700346 "tests/metrics/GaugeMetricProducer_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700347 "tests/metrics/MaxDurationTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700348 "tests/metrics/metrics_test_helper.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700349 "tests/metrics/OringDurationTracker_test.cpp",
350 "tests/metrics/ValueMetricProducer_test.cpp",
351 "tests/MetricsManager_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700352 "tests/shell/ShellSubscriber_test.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700353 "tests/state/StateTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700354 "tests/statsd_test_util.cpp",
355 "tests/StatsLogProcessor_test.cpp",
356 "tests/StatsService_test.cpp",
357 "tests/storage/StorageManager_test.cpp",
358 "tests/UidMap_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700359 ],
360
361 static_libs: [
362 "libgmock",
363 "libplatformprotos",
Jeffrey Huang3eb84d42020-03-17 10:31:22 -0700364 "libstatslog_statsdtest",
Tej Singheb7d8f42020-01-29 15:59:35 -0800365 "libstatssocket_private",
Colin Crossbc2dc312018-10-26 22:34:06 -0700366 ],
367
368 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700369 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700370 include_dirs: ["external/protobuf/src"],
371 },
372
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800373 shared_libs: [
374 "libprotobuf-cpp-lite",
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800375 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700376
377}
378
379//#############################
380// statsd micro benchmark
381//#############################
382
tsaichristine63143252020-03-20 17:03:49 -0700383cc_benchmark {
384 name: "statsd_benchmark",
385 defaults: ["statsd_defaults"],
386
387 srcs: [
388 // atom_field_options.proto needs field_options.proto, but that is
389 // not included in libprotobuf-cpp-lite, so compile it here.
390 ":libprotobuf-internal-protos",
391
392 "benchmark/duration_metric_benchmark.cpp",
393 "benchmark/filter_value_benchmark.cpp",
394 "benchmark/get_dimensions_for_condition_benchmark.cpp",
395 "benchmark/hello_world_benchmark.cpp",
396 "benchmark/log_event_benchmark.cpp",
397 "benchmark/main.cpp",
398 "benchmark/metric_util.cpp",
399 "benchmark/stats_write_benchmark.cpp",
400 "src/atom_field_options.proto",
401 "src/atoms.proto",
402 "src/stats_log.proto",
403 ],
404
405 proto: {
406 type: "lite",
407 include_dirs: ["external/protobuf/src"],
408 },
409
410 cflags: [
411 "-Wall",
412 "-Werror",
413 "-Wno-unused-parameter",
414 "-Wno-unused-variable",
415 "-Wno-unused-function",
416
417 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
418 "-Wno-varargs",
419 ],
420
421 static_libs: [
422 "libplatformprotos",
423 "libstatssocket_private",
424 ],
425
426 shared_libs: [
427 "libgtest_prod",
428 "libprotobuf-cpp-lite",
429 "libstatslog",
430 ],
431}
Joe Onorato62c220b2017-11-18 20:32:56 -0800432
gopinatha9864fd2018-08-22 16:45:57 -0700433// ==== java proto device library (for test only) ==============================
434java_library {
435 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000436 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700437 proto: {
438 type: "lite",
439 include_dirs: ["external/protobuf/src"],
440 },
441
442 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700443 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800444 "src/shell/shell_config.proto",
445 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700446 "src/stats_log.proto",
447 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700448 ],
449
450 static_libs: [
451 "platformprotoslite",
452 ],
453 // Protos have lots of MissingOverride and similar.
454 errorprone: {
455 javacflags: ["-XepDisableAllChecks"],
456 },
457}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800458
459// Filegroup for statsd config proto definition.
460filegroup {
461 name: "statsd-config-proto-def",
462 srcs: ["src/statsd_config.proto"],
463}