blob: 956fd29205cbefdee8e84fe28a16447de712c959 [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",
Colin Crossbc2dc312018-10-26 22:34:06 -0700100 "src/StatsLogProcessor.cpp",
101 "src/StatsService.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700102 "src/storage/StorageManager.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700103 "src/subscriber/IncidentdReporter.cpp",
104 "src/subscriber/SubscriberReporter.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700105 "src/uid_data.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700106 ],
107
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800108 cflags: [
Muhammad Qureshideebbd92020-02-05 17:17:46 -0800109 "-DNEW_ENCODING_SCHEME",
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800110 ],
111
Colin Crossbc2dc312018-10-26 22:34:06 -0700112 local_include_dirs: [
113 "src",
114 ],
115
116 static_libs: [
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700117 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700118 "libcutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800119 "libprotoutil",
120 "libstatslog",
Howard Roe5edf8c2020-02-05 18:12:14 -0800121 "libstatsmetadata",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800122 "libsysutils",
Howard Ro47807e22020-02-06 23:17:33 -0800123 "libutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800124 ],
125 shared_libs: [
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800126 "libbinder",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700127 "libincident",
Howard Roe5edf8c2020-02-05 18:12:14 -0800128 "liblog",
Howard Roe5575c22020-02-05 22:47:55 -0800129 "libstatssocket",
Ruchir Rastogi86379b12020-01-31 12:29:32 -0800130 "statsd-aidl-cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700131 ],
132}
133
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800134// ================
135// libstatsmetadata
136// ================
137
138genrule {
139 name: "atoms_info.h",
140 tools: ["stats-log-api-gen"],
141 cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h",
142 out: [
143 "atoms_info.h",
144 ],
145}
146
147genrule {
148 name: "atoms_info.cpp",
149 tools: ["stats-log-api-gen"],
150 cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp",
151 out: [
152 "atoms_info.cpp",
153 ],
154}
155
Howard Roe5edf8c2020-02-05 18:12:14 -0800156cc_library_static {
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800157 name: "libstatsmetadata",
158 host_supported: true,
159 generated_sources: [
160 "atoms_info.cpp",
161 ],
162 generated_headers: [
163 "atoms_info.h",
164 ],
165 cflags: [
166 "-Wall",
167 "-Werror",
168 ],
169 export_generated_headers: [
170 "atoms_info.h",
171 ],
172 shared_libs: [
173 "libcutils",
174 "libstatslog",
175 ],
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800176}
177
178
Colin Crossbc2dc312018-10-26 22:34:06 -0700179// =========
180// statsd
181// =========
182
183cc_binary {
184 name: "statsd",
185 defaults: ["statsd_defaults"],
186
187 srcs: ["src/main.cpp"],
188
189 cflags: [
190 "-Wall",
191 "-Wextra",
192 "-Werror",
193 "-Wno-unused-parameter",
194 // optimize for size (protobuf glop can get big)
195 "-Os",
196 // "-g",
197 // "-O0",
198 ],
199
200 product_variables: {
201 eng: {
202 // Enable sanitizer ONLY on eng builds
203 //sanitize: {
204 // address: true,
205 //},
206 },
207 debuggable: {
208 // Add a flag to enable stats log printing from statsd on debug builds.
209 cflags: ["-DVERY_VERBOSE_PRINTING"],
210 },
211 },
212
213 proto: {
214 type: "lite",
215 },
216
217 shared_libs: ["libgtest_prod"],
218
219 init_rc: ["statsd.rc"],
220}
221
222// ==============
223// statsd_test
224// ==============
225
226cc_test {
227 name: "statsd_test",
228 defaults: ["statsd_defaults"],
229 test_suites: ["device-tests"],
230
231 cflags: [
232 "-Wall",
233 "-Werror",
234 "-Wno-missing-field-initializers",
235 "-Wno-unused-variable",
236 "-Wno-unused-function",
237 "-Wno-unused-parameter",
238 ],
239
240 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700241 // atom_field_options.proto needs field_options.proto, but that is
242 // not included in libprotobuf-cpp-lite, so compile it here.
243 ":libprotobuf-internal-protos",
244
Colin Crossbc2dc312018-10-26 22:34:06 -0700245 "src/atom_field_options.proto",
246 "src/atoms.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700247 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700248 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700249 "tests/AlarmMonitor_test.cpp",
250 "tests/anomaly/AlarmTracker_test.cpp",
251 "tests/anomaly/AnomalyTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700252 "tests/condition/CombinationConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700253 "tests/condition/ConditionTimer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700254 "tests/condition/SimpleConditionTracker_test.cpp",
tsaichristinec46fbf92019-09-04 15:47:57 -0700255 "tests/condition/StateConditionTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700256 "tests/ConfigManager_test.cpp",
257 "tests/e2e/Alarm_e2e_test.cpp",
258 "tests/e2e/Anomaly_count_e2e_test.cpp",
259 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp",
260 "tests/e2e/Attribution_e2e_test.cpp",
261 "tests/e2e/ConfigTtl_e2e_test.cpp",
tsaichristined21aacf2019-10-07 14:47:38 -0700262 "tests/e2e/CountMetric_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700263 "tests/e2e/DurationMetric_e2e_test.cpp",
264 "tests/e2e/GaugeMetric_e2e_pull_test.cpp",
265 "tests/e2e/GaugeMetric_e2e_push_test.cpp",
266 "tests/e2e/MetricActivation_e2e_test.cpp",
267 "tests/e2e/MetricConditionLink_e2e_test.cpp",
268 "tests/e2e/PartialBucket_e2e_test.cpp",
269 "tests/e2e/ValueMetric_pull_e2e_test.cpp",
270 "tests/e2e/WakelockDuration_e2e_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700271 "tests/external/puller_util_test.cpp",
Tej Singh89817632019-12-09 16:58:08 -0800272 "tests/external/StatsCallbackPuller_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700273 "tests/external/StatsPuller_test.cpp",
274 "tests/FieldValue_test.cpp",
275 "tests/guardrail/StatsdStats_test.cpp",
276 "tests/indexed_priority_queue_test.cpp",
277 "tests/log_event/LogEventQueue_test.cpp",
278 "tests/LogEntryMatcher_test.cpp",
279 "tests/LogEvent_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700280 "tests/metrics/CountMetricProducer_test.cpp",
281 "tests/metrics/DurationMetricProducer_test.cpp",
282 "tests/metrics/EventMetricProducer_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700283 "tests/metrics/GaugeMetricProducer_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700284 "tests/metrics/MaxDurationTracker_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700285 "tests/metrics/metrics_test_helper.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700286 "tests/metrics/OringDurationTracker_test.cpp",
287 "tests/metrics/ValueMetricProducer_test.cpp",
288 "tests/MetricsManager_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700289 "tests/shell/ShellSubscriber_test.cpp",
tsaichristine10978642019-09-10 14:12:49 -0700290 "tests/state/StateTracker_test.cpp",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700291 "tests/statsd_test_util.cpp",
292 "tests/StatsLogProcessor_test.cpp",
293 "tests/StatsService_test.cpp",
294 "tests/storage/StorageManager_test.cpp",
295 "tests/UidMap_test.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700296 ],
297
298 static_libs: [
299 "libgmock",
300 "libplatformprotos",
301 ],
302
303 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700304 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700305 include_dirs: ["external/protobuf/src"],
306 },
307
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800308 shared_libs: [
309 "libprotobuf-cpp-lite",
310 "libstatssocket"
311 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700312
313}
314
315//#############################
316// statsd micro benchmark
317//#############################
318
319cc_benchmark {
320 name: "statsd_benchmark",
321 defaults: ["statsd_defaults"],
322
323 srcs: [
Colin Cross3f51ab52018-10-26 23:28:02 -0700324 // atom_field_options.proto needs field_options.proto, but that is
325 // not included in libprotobuf-cpp-lite, so compile it here.
326 ":libprotobuf-internal-protos",
327
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700328 "benchmark/duration_metric_benchmark.cpp",
329 "benchmark/filter_value_benchmark.cpp",
330 "benchmark/get_dimensions_for_condition_benchmark.cpp",
331 "benchmark/hello_world_benchmark.cpp",
332 "benchmark/log_event_benchmark.cpp",
333 "benchmark/main.cpp",
334 "benchmark/metric_util.cpp",
335 "benchmark/stats_write_benchmark.cpp",
Colin Crossbc2dc312018-10-26 22:34:06 -0700336 "src/atom_field_options.proto",
337 "src/atoms.proto",
338 "src/stats_log.proto",
Colin Crossbc2dc312018-10-26 22:34:06 -0700339 ],
340
341 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700342 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700343 include_dirs: ["external/protobuf/src"],
344 },
345
346 cflags: [
347 "-Wall",
348 "-Werror",
349 "-Wno-unused-parameter",
350 "-Wno-unused-variable",
351 "-Wno-unused-function",
352
353 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800354 "-Wno-varargs",
Colin Crossbc2dc312018-10-26 22:34:06 -0700355 ],
356
357 static_libs: [
358 "libplatformprotos",
359 ],
360
361 shared_libs: [
362 "libgtest_prod",
Colin Cross3f51ab52018-10-26 23:28:02 -0700363 "libprotobuf-cpp-lite",
Ruchir Rastogi1736ba42019-11-04 14:37:13 -0800364 "libstatslog",
365 "libstatssocket",
Colin Crossbc2dc312018-10-26 22:34:06 -0700366 ],
367}
Joe Onorato62c220b2017-11-18 20:32:56 -0800368
gopinatha9864fd2018-08-22 16:45:57 -0700369// ==== java proto device library (for test only) ==============================
370java_library {
371 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000372 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700373 proto: {
374 type: "lite",
375 include_dirs: ["external/protobuf/src"],
376 },
377
378 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700379 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800380 "src/shell/shell_config.proto",
381 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700382 "src/stats_log.proto",
383 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700384 ],
385
386 static_libs: [
387 "platformprotoslite",
388 ],
389 // Protos have lots of MissingOverride and similar.
390 errorprone: {
391 javacflags: ["-XepDisableAllChecks"],
392 },
393}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800394
395// Filegroup for statsd config proto definition.
396filegroup {
397 name: "statsd-config-proto-def",
398 srcs: ["src/statsd_config.proto"],
399}