blob: 70f309add5dfd201df533c0bbe8b850c2979678f [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",
Colin Crossbc2dc312018-10-26 22:34:06 -070068 "src/external/Perfetto.cpp",
Tej Singh6a5c9432019-10-11 11:07:06 -070069 "src/external/PullResultReceiver.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070070 "src/external/puller_util.cpp",
Tej Singha0c89dd2019-01-25 16:39:18 -080071 "src/external/StatsCallbackPuller.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070072 "src/external/StatsPuller.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070073 "src/external/StatsPullerManager.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070074 "src/external/TrainInfoPuller.cpp",
75 "src/FieldValue.cpp",
76 "src/guardrail/StatsdStats.cpp",
77 "src/hash.cpp",
78 "src/HashableDimensionKey.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070079 "src/logd/LogEvent.cpp",
Yao Chen0f861862019-03-27 11:51:15 -070080 "src/logd/LogEventQueue.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070081 "src/matchers/CombinationLogMatchingTracker.cpp",
82 "src/matchers/EventMatcherWizard.cpp",
83 "src/matchers/matcher_util.cpp",
84 "src/matchers/SimpleLogMatchingTracker.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070085 "src/metrics/CountMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070086 "src/metrics/duration_helper/MaxDurationTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070087 "src/metrics/duration_helper/OringDurationTracker.cpp",
88 "src/metrics/DurationMetricProducer.cpp",
89 "src/metrics/EventMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070090 "src/metrics/GaugeMetricProducer.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070091 "src/metrics/MetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070092 "src/metrics/metrics_manager_util.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070093 "src/metrics/MetricsManager.cpp",
94 "src/metrics/ValueMetricProducer.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -070095 "src/packages/UidMap.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -070096 "src/shell/shell_config.proto",
97 "src/shell/ShellSubscriber.cpp",
98 "src/socket/StatsSocketListener.cpp",
tsaichristine10978642019-09-10 14:12:49 -070099 "src/state/StateManager.cpp",
100 "src/state/StateTracker.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700101 "src/stats_log_util.cpp",
102 "src/statscompanion_util.cpp",
103 "src/statsd_config.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700104 "src/StatsLogProcessor.cpp",
105 "src/StatsService.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700106 "src/storage/StorageManager.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700107 "src/subscriber/IncidentdReporter.cpp",
108 "src/subscriber/SubscriberReporter.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700109 "src/uid_data.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700110 ],
111
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800112 cflags: [
Muhammad Qureshideebbd92020-02-05 17:17:46 -0800113 "-DNEW_ENCODING_SCHEME",
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800114 ],
115
Colin Crossbc2dc312018-10-26 22:34:06 -0700116 local_include_dirs: [
117 "src",
118 ],
119
120 static_libs: [
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700121 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700122 "libcutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800123 "libprotoutil",
124 "libstatslog",
Howard Roe5edf8c2020-02-05 18:12:14 -0800125 "libstatsmetadata",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800126 "libsysutils",
Howard Ro47807e22020-02-06 23:17:33 -0800127 "libutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800128 ],
129 shared_libs: [
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800130 "libbinder",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700131 "libincident",
Howard Roe5edf8c2020-02-05 18:12:14 -0800132 "liblog",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700133 "libservices",
Howard Roe5575c22020-02-05 22:47:55 -0800134 "libstatssocket",
Colin Crossbc2dc312018-10-26 22:34:06 -0700135 ],
136}
137
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800138// ================
139// libstatsmetadata
140// ================
141
142genrule {
143 name: "atoms_info.h",
144 tools: ["stats-log-api-gen"],
145 cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h",
146 out: [
147 "atoms_info.h",
148 ],
149}
150
151genrule {
152 name: "atoms_info.cpp",
153 tools: ["stats-log-api-gen"],
154 cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp",
155 out: [
156 "atoms_info.cpp",
157 ],
158}
159
Howard Roe5edf8c2020-02-05 18:12:14 -0800160cc_library_static {
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800161 name: "libstatsmetadata",
162 host_supported: true,
163 generated_sources: [
164 "atoms_info.cpp",
165 ],
166 generated_headers: [
167 "atoms_info.h",
168 ],
169 cflags: [
170 "-Wall",
171 "-Werror",
172 ],
173 export_generated_headers: [
174 "atoms_info.h",
175 ],
176 shared_libs: [
177 "libcutils",
178 "libstatslog",
179 ],
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800180}
181
182
Colin Crossbc2dc312018-10-26 22:34:06 -0700183// =========
184// statsd
185// =========
186
187cc_binary {
188 name: "statsd",
189 defaults: ["statsd_defaults"],
190
191 srcs: ["src/main.cpp"],
192
193 cflags: [
194 "-Wall",
195 "-Wextra",
196 "-Werror",
197 "-Wno-unused-parameter",
198 // optimize for size (protobuf glop can get big)
199 "-Os",
200 // "-g",
201 // "-O0",
202 ],
203
204 product_variables: {
205 eng: {
206 // Enable sanitizer ONLY on eng builds
207 //sanitize: {
208 // address: true,
209 //},
210 },
211 debuggable: {
212 // Add a flag to enable stats log printing from statsd on debug builds.
213 cflags: ["-DVERY_VERBOSE_PRINTING"],
214 },
215 },
216
217 proto: {
218 type: "lite",
219 },
220
221 shared_libs: ["libgtest_prod"],
222
223 init_rc: ["statsd.rc"],
224}
225
226// ==============
227// statsd_test
228// ==============
229
230cc_test {
231 name: "statsd_test",
232 defaults: ["statsd_defaults"],
233 test_suites: ["device-tests"],
234
235 cflags: [
236 "-Wall",
237 "-Werror",
238 "-Wno-missing-field-initializers",
239 "-Wno-unused-variable",
240 "-Wno-unused-function",
241 "-Wno-unused-parameter",
242 ],
243
244 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700245 // atom_field_options.proto needs field_options.proto, but that is
246 // not included in libprotobuf-cpp-lite, so compile it here.
247 ":libprotobuf-internal-protos",
248
Colin Crossbc2dc312018-10-26 22:34:06 -0700249 "src/atom_field_options.proto",
250 "src/atoms.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700251 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700252 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700253 "tests/AlarmMonitor_test.cpp",
254 "tests/anomaly/AlarmTracker_test.cpp",
255 "tests/anomaly/AnomalyTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700256 "tests/condition/CombinationConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700257 "tests/condition/ConditionTimer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700258 "tests/condition/SimpleConditionTracker_test.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -0700259 "tests/condition/StateConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700260 "tests/ConfigManager_test.cpp",
261 "tests/e2e/Alarm_e2e_test.cpp",
262 "tests/e2e/Anomaly_count_e2e_test.cpp",
263 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp",
264 "tests/e2e/Attribution_e2e_test.cpp",
265 "tests/e2e/ConfigTtl_e2e_test.cpp",
tsaichristined21aacf2019-10-07 14:47:38 -0700266 "tests/e2e/CountMetric_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700267 "tests/e2e/DurationMetric_e2e_test.cpp",
268 "tests/e2e/GaugeMetric_e2e_pull_test.cpp",
269 "tests/e2e/GaugeMetric_e2e_push_test.cpp",
270 "tests/e2e/MetricActivation_e2e_test.cpp",
271 "tests/e2e/MetricConditionLink_e2e_test.cpp",
272 "tests/e2e/PartialBucket_e2e_test.cpp",
273 "tests/e2e/ValueMetric_pull_e2e_test.cpp",
274 "tests/e2e/WakelockDuration_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700275 "tests/external/puller_util_test.cpp",
Tej Singh89817632019-12-09 16:58:08 -0800276 "tests/external/StatsCallbackPuller_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700277 "tests/external/StatsPuller_test.cpp",
278 "tests/FieldValue_test.cpp",
279 "tests/guardrail/StatsdStats_test.cpp",
280 "tests/indexed_priority_queue_test.cpp",
281 "tests/log_event/LogEventQueue_test.cpp",
282 "tests/LogEntryMatcher_test.cpp",
283 "tests/LogEvent_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700284 "tests/metrics/CountMetricProducer_test.cpp",
285 "tests/metrics/DurationMetricProducer_test.cpp",
286 "tests/metrics/EventMetricProducer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700287 "tests/metrics/GaugeMetricProducer_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700288 "tests/metrics/MaxDurationTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700289 "tests/metrics/metrics_test_helper.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700290 "tests/metrics/OringDurationTracker_test.cpp",
291 "tests/metrics/ValueMetricProducer_test.cpp",
292 "tests/MetricsManager_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700293 "tests/shell/ShellSubscriber_test.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700294 "tests/state/StateTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700295 "tests/statsd_test_util.cpp",
296 "tests/StatsLogProcessor_test.cpp",
297 "tests/StatsService_test.cpp",
298 "tests/storage/StorageManager_test.cpp",
299 "tests/UidMap_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700300 ],
301
302 static_libs: [
303 "libgmock",
304 "libplatformprotos",
305 ],
306
307 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700308 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700309 include_dirs: ["external/protobuf/src"],
310 },
311
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800312 shared_libs: [
313 "libprotobuf-cpp-lite",
314 "libstatssocket"
315 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700316
317}
318
319//#############################
320// statsd micro benchmark
321//#############################
322
323cc_benchmark {
324 name: "statsd_benchmark",
325 defaults: ["statsd_defaults"],
326
327 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700328 // atom_field_options.proto needs field_options.proto, but that is
329 // not included in libprotobuf-cpp-lite, so compile it here.
330 ":libprotobuf-internal-protos",
331
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700332 "benchmark/duration_metric_benchmark.cpp",
333 "benchmark/filter_value_benchmark.cpp",
334 "benchmark/get_dimensions_for_condition_benchmark.cpp",
335 "benchmark/hello_world_benchmark.cpp",
336 "benchmark/log_event_benchmark.cpp",
337 "benchmark/main.cpp",
338 "benchmark/metric_util.cpp",
339 "benchmark/stats_write_benchmark.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700340 "src/atom_field_options.proto",
341 "src/atoms.proto",
342 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700343 ],
344
345 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700346 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700347 include_dirs: ["external/protobuf/src"],
348 },
349
350 cflags: [
351 "-Wall",
352 "-Werror",
353 "-Wno-unused-parameter",
354 "-Wno-unused-variable",
355 "-Wno-unused-function",
356
357 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800358 "-Wno-varargs",
Colin Crossbc2dc312018-10-26 22:34:06 -0700359 ],
360
361 static_libs: [
362 "libplatformprotos",
363 ],
364
365 shared_libs: [
366 "libgtest_prod",
Colin Cross3f51ab52018-10-26 23:28:02 -0700367 "libprotobuf-cpp-lite",
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800368 "libstatslog",
369 "libstatssocket",
Colin Crossbc2dc312018-10-26 22:34:06 -0700370 ],
371}
Joe Onorato62c220b2017-11-18 20:32:56 -0800372
gopinatha9864fd2018-08-22 16:45:57 -0700373// ==== java proto device library (for test only) ==============================
374java_library {
375 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000376 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700377 proto: {
378 type: "lite",
379 include_dirs: ["external/protobuf/src"],
380 },
381
382 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700383 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800384 "src/shell/shell_config.proto",
385 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700386 "src/stats_log.proto",
387 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700388 ],
389
390 static_libs: [
391 "platformprotoslite",
392 ],
393 // Protos have lots of MissingOverride and similar.
394 errorprone: {
395 javacflags: ["-XepDisableAllChecks"],
396 },
397}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800398
399// Filegroup for statsd config proto definition.
400filegroup {
401 name: "statsd-config-proto-def",
402 srcs: ["src/statsd_config.proto"],
403}