blob: 73a8f666b78eb3698e2180e645c1d45fb845a7e2 [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
108 local_include_dirs: [
109 "src",
110 ],
111
112 static_libs: [
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700113 "libbase",
Colin Crossbc2dc312018-10-26 22:34:06 -0700114 "libcutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800115 "libprotoutil",
116 "libstatslog",
Howard Roe5edf8c2020-02-05 18:12:14 -0800117 "libstatsmetadata",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800118 "libsysutils",
Howard Ro47807e22020-02-06 23:17:33 -0800119 "libutils",
Jonathan Nguyen8896f8d2019-12-20 15:10:13 -0800120 ],
121 shared_libs: [
Ruchir Rastogie449b0c2020-02-10 17:40:09 -0800122 "libbinder_ndk",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700123 "libincident",
Howard Roe5edf8c2020-02-05 18:12:14 -0800124 "liblog",
Wonsik Kimd3f06c52020-02-14 11:13:10 -0800125 "libstatssocket",
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 ],
168 shared_libs: [
169 "libcutils",
170 "libstatslog",
171 ],
Jeffrey Huang52e90022020-02-14 10:13:44 -0800172 apex_available: [
173 //TODO(b/149782403): Remove this once statsd no longer links against libstatsmetadata
174 "com.android.os.statsd",
175 "test_com.android.os.statsd",
176 ],
Muhammad Qureshic8e22662019-11-20 17:18:03 -0800177}
178
179
Colin Crossbc2dc312018-10-26 22:34:06 -0700180// =========
181// statsd
182// =========
183
184cc_binary {
185 name: "statsd",
186 defaults: ["statsd_defaults"],
187
188 srcs: ["src/main.cpp"],
189
190 cflags: [
191 "-Wall",
192 "-Wextra",
193 "-Werror",
194 "-Wno-unused-parameter",
195 // optimize for size (protobuf glop can get big)
196 "-Os",
197 // "-g",
198 // "-O0",
199 ],
200
201 product_variables: {
202 eng: {
203 // Enable sanitizer ONLY on eng builds
204 //sanitize: {
205 // address: true,
206 //},
207 },
208 debuggable: {
209 // Add a flag to enable stats log printing from statsd on debug builds.
210 cflags: ["-DVERY_VERBOSE_PRINTING"],
211 },
212 },
213
214 proto: {
215 type: "lite",
216 },
217
218 shared_libs: ["libgtest_prod"],
219
Howard Roadc510f2020-02-20 04:57:00 +0000220 apex_available: [
221 "com.android.os.statsd",
222 "test_com.android.os.statsd",
223 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700224}
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",
Muhammad Qureshi7b31ff82020-02-18 16:45:06 -0800305
306 // TODO(b/149842105): Make libstatssocket shared and remove libcutils once statsd_test is
307 // moved to the apex.
308 "libstatssocket",
309 "libcutils",
Colin Crossbc2dc312018-10-26 22:34:06 -0700310 ],
311
312 proto: {
Colin Cross3f51ab52018-10-26 23:28:02 -0700313 type: "lite",
Colin Crossbc2dc312018-10-26 22:34:06 -0700314 include_dirs: ["external/protobuf/src"],
315 },
316
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800317 shared_libs: [
318 "libprotobuf-cpp-lite",
Ruchir Rastogi1fb525e2019-11-07 14:08:24 -0800319 ],
Colin Crossbc2dc312018-10-26 22:34:06 -0700320
321}
322
323//#############################
324// statsd micro benchmark
325//#############################
326
Jeffrey Huang1e4368a2020-02-18 12:28:52 -0800327//cc_benchmark {
328// name: "statsd_benchmark",
329// defaults: ["statsd_defaults"],
330//
331// srcs: [
332// // atom_field_options.proto needs field_options.proto, but that is
333// // not included in libprotobuf-cpp-lite, so compile it here.
334// ":libprotobuf-internal-protos",
335//
336// "benchmark/duration_metric_benchmark.cpp",
337// "benchmark/filter_value_benchmark.cpp",
338// "benchmark/get_dimensions_for_condition_benchmark.cpp",
339// "benchmark/hello_world_benchmark.cpp",
340// "benchmark/log_event_benchmark.cpp",
341// "benchmark/main.cpp",
342// "benchmark/metric_util.cpp",
343// "benchmark/stats_write_benchmark.cpp",
344// "src/atom_field_options.proto",
345// "src/atoms.proto",
346// "src/stats_log.proto",
347// ],
348//
349// proto: {
350// type: "lite",
351// include_dirs: ["external/protobuf/src"],
352// },
353//
354// cflags: [
355// "-Wall",
356// "-Werror",
357// "-Wno-unused-parameter",
358// "-Wno-unused-variable",
359// "-Wno-unused-function",
360//
361// // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374
362// "-Wno-varargs",
363// ],
364//
365// static_libs: [
366// "libplatformprotos",
367// ],
368//
369// shared_libs: [
370// "libgtest_prod",
371// "libprotobuf-cpp-lite",
372// "libstatslog",
373// "libstatssocket",
374// ],
375//}
Joe Onorato62c220b2017-11-18 20:32:56 -0800376
gopinatha9864fd2018-08-22 16:45:57 -0700377// ==== java proto device library (for test only) ==============================
378java_library {
379 name: "statsdprotolite",
Anton Hansson791551a2019-12-19 10:17:46 +0000380 sdk_version: "core_current",
gopinatha9864fd2018-08-22 16:45:57 -0700381 proto: {
382 type: "lite",
383 include_dirs: ["external/protobuf/src"],
384 },
385
386 srcs: [
gopinatha9864fd2018-08-22 16:45:57 -0700387 "src/atoms.proto",
Yao Chen35cb8d62019-01-03 16:49:14 -0800388 "src/shell/shell_config.proto",
389 "src/shell/shell_data.proto",
Ruchir Rastogi23d60f92019-09-16 15:23:56 -0700390 "src/stats_log.proto",
391 "src/statsd_config.proto",
gopinatha9864fd2018-08-22 16:45:57 -0700392 ],
393
394 static_libs: [
395 "platformprotoslite",
396 ],
397 // Protos have lots of MissingOverride and similar.
398 errorprone: {
399 javacflags: ["-XepDisableAllChecks"],
400 },
401}
Harry Zhangfe16c8f2019-02-26 10:47:04 -0800402
403// Filegroup for statsd config proto definition.
404filegroup {
405 name: "statsd-config-proto-def",
406 srcs: ["src/statsd_config.proto"],
407}