blob: 1579715727acfea9aded16cb9c765539f24bb9c5 [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",
Colin Crossbc2dc312018-10-26 22:34:06 -070059 "src/config/ConfigKey.cpp",
60 "src/config/ConfigListener.cpp",
61 "src/config/ConfigManager.cpp",
Jonathan Nguyena0e6de12020-01-28 18:33:55 -080062 "src/experiment_ids.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -070063 "src/external/Perfetto.cpp",
Tej Singh6a5c9432019-10-11 11:07:06 -070064 "src/external/PullResultReceiver.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070065 "src/external/puller_util.cpp",
Tej Singha0c89dd2019-01-25 16:39:18 -080066 "src/external/StatsCallbackPuller.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070067 "src/external/StatsPuller.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070068 "src/external/StatsPullerManager.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070069 "src/external/TrainInfoPuller.cpp",
70 "src/FieldValue.cpp",
71 "src/guardrail/StatsdStats.cpp",
72 "src/hash.cpp",
73 "src/HashableDimensionKey.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070074 "src/logd/LogEvent.cpp",
Yao Chen0f861862019-03-27 11:51:15 -070075 "src/logd/LogEventQueue.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070076 "src/matchers/CombinationLogMatchingTracker.cpp",
77 "src/matchers/EventMatcherWizard.cpp",
78 "src/matchers/matcher_util.cpp",
79 "src/matchers/SimpleLogMatchingTracker.cpp",
Jeffrey Huangb8f54032020-03-23 13:42:42 -070080 "src/metadata_util.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",
Tej Singhe678cb72020-04-14 16:23:30 -0700107 "src/utils/MultiConditionTrigger.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700108 ],
109
110 local_include_dirs: [
111 "src",
112 ],
113
114 static_libs: [
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700115 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700116 "libcutils",
Tej Singh1d4b46532020-04-06 13:26:29 -0700117 "libgtest_prod",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800118 "libprotoutil",
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800119 "libstatslog_statsd",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800120 "libsysutils",
Howard Ro47807e22020-02-06 23:17:33 -0800121 "libutils",
Tej Singh1d4b46532020-04-06 13:26:29 -0700122 "statsd-aidl-ndk_platform",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800123 ],
124 shared_libs: [
Ruchir Rastogie449b0c2020-02-10 17:40:09 -0800125 "libbinder_ndk",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700126 "libincident",
Howard Roe5edf8c2020-02-05 18:12:14 -0800127 "liblog",
Colin Crossbc2dc312018-10-26 22:34:06 -0700128 ],
129}
130
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800131genrule {
132 name: "statslog_statsd.h",
133 tools: ["stats-log-api-gen"],
134 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsd.h --module statsd --namespace android,os,statsd,util",
135 out: [
136 "statslog_statsd.h",
137 ],
138}
139
140genrule {
141 name: "statslog_statsd.cpp",
142 tools: ["stats-log-api-gen"],
143 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsd.cpp --module statsd --namespace android,os,statsd,util --importHeader statslog_statsd.h",
144 out: [
145 "statslog_statsd.cpp",
146 ],
147}
148
Jeffrey Huang3eb84d42020-03-17 10:31:22 -0700149genrule {
150 name: "statslog_statsdtest.h",
151 tools: ["stats-log-api-gen"],
152 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsdtest.h --module statsdtest --namespace android,os,statsd,util",
153 out: [
154 "statslog_statsdtest.h",
155 ],
156}
157
158genrule {
159 name: "statslog_statsdtest.cpp",
160 tools: ["stats-log-api-gen"],
161 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsdtest.cpp --module statsdtest --namespace android,os,statsd,util --importHeader statslog_statsdtest.h",
162 out: [
163 "statslog_statsdtest.cpp",
164 ],
165}
166
167cc_library_static {
168 name: "libstatslog_statsdtest",
169 generated_sources: ["statslog_statsdtest.cpp"],
170 generated_headers: ["statslog_statsdtest.h"],
171 export_generated_headers: ["statslog_statsdtest.h"],
172 shared_libs: [
173 "libstatssocket",
Salud Lemus6d99ddc2020-07-08 20:07:00 +0000174 "libstatspull",
175 ],
Jeffrey Huang3eb84d42020-03-17 10:31:22 -0700176}
177
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800178cc_library_static {
179 name: "libstatslog_statsd",
180 generated_sources: ["statslog_statsd.cpp"],
181 generated_headers: ["statslog_statsd.h"],
182 export_generated_headers: ["statslog_statsd.h"],
183 apex_available: [
184 "com.android.os.statsd",
185 "test_com.android.os.statsd",
186 ],
187 shared_libs: [
188 "libstatssocket",
Salud Lemus6d99ddc2020-07-08 20:07:00 +0000189 "libstatspull",
190 ],
191 export_shared_lib_headers: [
192 "libstatspull",
193 ],
Jeffrey Huang74fc4352020-03-06 15:18:33 -0800194}
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800195
Colin Crossbc2dc312018-10-26 22:34:06 -0700196// =========
197// statsd
198// =========
199
200cc_binary {
201 name: "statsd",
202 defaults: ["statsd_defaults"],
203
204 srcs: ["src/main.cpp"],
205
206 cflags: [
207 "-Wall",
208 "-Wextra",
209 "-Werror",
210 "-Wno-unused-parameter",
211 // optimize for size (protobuf glop can get big)
212 "-Os",
213 // "-g",
214 // "-O0",
215 ],
216
217 product_variables: {
218 eng: {
219 // Enable sanitizer ONLY on eng builds
220 //sanitize: {
221 // address: true,
222 //},
223 },
Colin Crossbc2dc312018-10-26 22:34:06 -0700224 },
225
226 proto: {
227 type: "lite",
Tej Singh1d4b46532020-04-06 13:26:29 -0700228 static: true,
Colin Crossbc2dc312018-10-26 22:34:06 -0700229 },
Tej Singh1d4b46532020-04-06 13:26:29 -0700230 stl: "libc++_static",
Colin Crossbc2dc312018-10-26 22:34:06 -0700231
Tej Singhb3915ea2020-03-05 14:33:15 -0800232 shared_libs: [
Tej Singhb3915ea2020-03-05 14:33:15 -0800233 "libstatssocket",
234 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700235
Howard Roadc510f2020-02-20 04:57:00 +0000236 apex_available: [
237 "com.android.os.statsd",
238 "test_com.android.os.statsd",
239 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700240}
241
242// ==============
243// statsd_test
244// ==============
245
246cc_test {
247 name: "statsd_test",
248 defaults: ["statsd_defaults"],
Jeffrey Huangc6b28302020-04-15 11:16:20 -0700249 test_suites: ["device-tests", "mts"],
Chen Zhu253d4f32020-05-19 17:13:09 -0700250 test_config: "statsd_test.xml",
Jeffrey Huangc6b28302020-04-15 11:16:20 -0700251
Jeffrey Huang9c30a952020-04-17 15:33:32 -0700252 //TODO(b/153588990): Remove when the build system properly separates
Jeffrey Huangc6b28302020-04-15 11:16:20 -0700253 //32bit and 64bit architectures.
Jeffrey Huangfe283e182020-04-20 14:16:49 -0700254 compile_multilib: "both",
255 multilib: {
256 lib64: {
257 suffix: "64",
Chen Zhu253d4f32020-05-19 17:13:09 -0700258 },
259 lib32: {
260 suffix: "32",
261 },
Jeffrey Huangfe283e182020-04-20 14:16:49 -0700262 },
Colin Crossbc2dc312018-10-26 22:34:06 -0700263
264 cflags: [
265 "-Wall",
266 "-Werror",
267 "-Wno-missing-field-initializers",
268 "-Wno-unused-variable",
269 "-Wno-unused-function",
270 "-Wno-unused-parameter",
271 ],
272
Tej Singh5d823b32019-05-21 20:13:21 -0700273 require_root: true,
274
Colin Crossbc2dc312018-10-26 22:34:06 -0700275 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700276 // atom_field_options.proto needs field_options.proto, but that is
277 // not included in libprotobuf-cpp-lite, so compile it here.
278 ":libprotobuf-internal-protos",
279
Colin Crossbc2dc312018-10-26 22:34:06 -0700280 "src/atom_field_options.proto",
281 "src/atoms.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700282 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700283 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700284 "tests/AlarmMonitor_test.cpp",
285 "tests/anomaly/AlarmTracker_test.cpp",
286 "tests/anomaly/AnomalyTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700287 "tests/condition/CombinationConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700288 "tests/condition/ConditionTimer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700289 "tests/condition/SimpleConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700290 "tests/ConfigManager_test.cpp",
291 "tests/e2e/Alarm_e2e_test.cpp",
292 "tests/e2e/Anomaly_count_e2e_test.cpp",
293 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp",
294 "tests/e2e/Attribution_e2e_test.cpp",
295 "tests/e2e/ConfigTtl_e2e_test.cpp",
tsaichristined21aacf2019-10-07 14:47:38 -0700296 "tests/e2e/CountMetric_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700297 "tests/e2e/DurationMetric_e2e_test.cpp",
298 "tests/e2e/GaugeMetric_e2e_pull_test.cpp",
299 "tests/e2e/GaugeMetric_e2e_push_test.cpp",
300 "tests/e2e/MetricActivation_e2e_test.cpp",
301 "tests/e2e/MetricConditionLink_e2e_test.cpp",
302 "tests/e2e/PartialBucket_e2e_test.cpp",
303 "tests/e2e/ValueMetric_pull_e2e_test.cpp",
304 "tests/e2e/WakelockDuration_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700305 "tests/external/puller_util_test.cpp",
Tej Singh89817632019-12-09 16:58:08 -0800306 "tests/external/StatsCallbackPuller_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700307 "tests/external/StatsPuller_test.cpp",
Tej Singh3be093b2020-03-04 20:08:38 -0800308 "tests/external/StatsPullerManager_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700309 "tests/FieldValue_test.cpp",
310 "tests/guardrail/StatsdStats_test.cpp",
tsaichristine1449fa42020-01-02 12:12:05 -0800311 "tests/HashableDimensionKey_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700312 "tests/indexed_priority_queue_test.cpp",
313 "tests/log_event/LogEventQueue_test.cpp",
314 "tests/LogEntryMatcher_test.cpp",
315 "tests/LogEvent_test.cpp",
Jeffrey Huang475677e2020-03-30 19:52:07 -0700316 "tests/metadata_util_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700317 "tests/metrics/CountMetricProducer_test.cpp",
318 "tests/metrics/DurationMetricProducer_test.cpp",
319 "tests/metrics/EventMetricProducer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700320 "tests/metrics/GaugeMetricProducer_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700321 "tests/metrics/MaxDurationTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700322 "tests/metrics/metrics_test_helper.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700323 "tests/metrics/OringDurationTracker_test.cpp",
324 "tests/metrics/ValueMetricProducer_test.cpp",
325 "tests/MetricsManager_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700326 "tests/shell/ShellSubscriber_test.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700327 "tests/state/StateTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700328 "tests/statsd_test_util.cpp",
329 "tests/StatsLogProcessor_test.cpp",
330 "tests/StatsService_test.cpp",
331 "tests/storage/StorageManager_test.cpp",
332 "tests/UidMap_test.cpp",
Tej Singhe678cb72020-04-14 16:23:30 -0700333 "tests/utils/MultiConditionTrigger_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700334 ],
335
336 static_libs: [
337 "libgmock",
338 "libplatformprotos",
Jeffrey Huang3eb84d42020-03-17 10:31:22 -0700339 "libstatslog_statsdtest",
Tej Singheb7d8f42020-01-29 15:59:35 -0800340 "libstatssocket_private",
Colin Crossbc2dc312018-10-26 22:34:06 -0700341 ],
342
343 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700344 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700345 include_dirs: ["external/protobuf/src"],
346 },
347
Colin Crossbc2dc312018-10-26 22:34:06 -0700348}
349
350//#############################
351// statsd micro benchmark
352//#############################
353
tsaichristine63143252020-03-20 17:03:49 -0700354cc_benchmark {
355 name: "statsd_benchmark",
356 defaults: ["statsd_defaults"],
357
358 srcs: [
359 // atom_field_options.proto needs field_options.proto, but that is
360 // not included in libprotobuf-cpp-lite, so compile it here.
361 ":libprotobuf-internal-protos",
362
363 "benchmark/duration_metric_benchmark.cpp",
364 "benchmark/filter_value_benchmark.cpp",
365 "benchmark/get_dimensions_for_condition_benchmark.cpp",
366 "benchmark/hello_world_benchmark.cpp",
367 "benchmark/log_event_benchmark.cpp",
368 "benchmark/main.cpp",
369 "benchmark/metric_util.cpp",
370 "benchmark/stats_write_benchmark.cpp",
371 "src/atom_field_options.proto",
372 "src/atoms.proto",
373 "src/stats_log.proto",
374 ],
375
376 proto: {
377 type: "lite",
378 include_dirs: ["external/protobuf/src"],
379 },
380
381 cflags: [
382 "-Wall",
383 "-Werror",
384 "-Wno-unused-parameter",
385 "-Wno-unused-variable",
386 "-Wno-unused-function",
387
388 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
389 "-Wno-varargs",
390 ],
391
392 static_libs: [
393 "libplatformprotos",
394 "libstatssocket_private",
395 ],
396
397 shared_libs: [
398 "libgtest_prod",
399 "libprotobuf-cpp-lite",
400 "libstatslog",
401 ],
402}
Joe Onorato62c220b2017-11-18 20:32:56 -0800403
gopinatha9864fd2018-08-22 16:45:57 -0700404// ==== java proto device library (for test only) ==============================
405java_library {
406 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000407 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700408 proto: {
409 type: "lite",
410 include_dirs: ["external/protobuf/src"],
411 },
412
413 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700414 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800415 "src/shell/shell_config.proto",
416 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700417 "src/stats_log.proto",
418 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700419 ],
420
421 static_libs: [
422 "platformprotoslite",
423 ],
424 // Protos have lots of MissingOverride and similar.
425 errorprone: {
426 javacflags: ["-XepDisableAllChecks"],
427 },
428}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800429
430// Filegroup for statsd config proto definition.
431filegroup {
432 name: "statsd-config-proto-def",
433 srcs: ["src/statsd_config.proto"],
434}