1// 2// Copyright (C) 2017 The Android Open Source Project 3// 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: [ 23 "src/atoms.proto", 24 "src/atom_field_options.proto", 25 ], 26 27 shared_libs: [ 28 "libplatformprotos", 29 ], 30 31 proto: { 32 type: "full", 33 export_proto_headers: true, 34 include_dirs: [ 35 "external/protobuf/src", 36 ], 37 }, 38 39 export_shared_lib_headers: [ 40 "libplatformprotos", 41 ] 42 43} 44 45cc_defaults { 46 name: "statsd_defaults", 47 aidl: { 48 include_dirs: ["frameworks/base/core/java"], 49 }, 50 51 srcs: [ 52 ":statsd_aidl", 53 ":ICarStatsService.aidl", 54 "src/active_config_list.proto", 55 "src/statsd_config.proto", 56 "src/uid_data.proto", 57 "src/FieldValue.cpp", 58 "src/hash.cpp", 59 "src/stats_log_util.cpp", 60 "src/anomaly/AlarmMonitor.cpp", 61 "src/anomaly/AlarmTracker.cpp", 62 "src/anomaly/AnomalyTracker.cpp", 63 "src/anomaly/DurationAnomalyTracker.cpp", 64 "src/anomaly/subscriber_util.cpp", 65 "src/condition/CombinationConditionTracker.cpp", 66 "src/condition/condition_util.cpp", 67 "src/condition/SimpleConditionTracker.cpp", 68 "src/condition/ConditionWizard.cpp", 69 "src/condition/StateTracker.cpp", 70 "src/config/ConfigKey.cpp", 71 "src/config/ConfigListener.cpp", 72 "src/config/ConfigManager.cpp", 73 "src/external/CarStatsPuller.cpp", 74 "src/external/GpuStatsPuller.cpp", 75 "src/external/Perfetto.cpp", 76 "src/external/StatsPuller.cpp", 77 "src/external/StatsCallbackPuller.cpp", 78 "src/external/StatsCompanionServicePuller.cpp", 79 "src/external/SubsystemSleepStatePuller.cpp", 80 "src/external/PowerStatsPuller.cpp", 81 "src/external/ResourceHealthManagerPuller.cpp", 82 "src/external/TrainInfoPuller.cpp", 83 "src/external/StatsPullerManager.cpp", 84 "src/external/puller_util.cpp", 85 "src/logd/LogEvent.cpp", 86 "src/logd/LogEventQueue.cpp", 87 "src/matchers/CombinationLogMatchingTracker.cpp", 88 "src/matchers/EventMatcherWizard.cpp", 89 "src/matchers/matcher_util.cpp", 90 "src/matchers/SimpleLogMatchingTracker.cpp", 91 "src/metrics/MetricProducer.cpp", 92 "src/metrics/EventMetricProducer.cpp", 93 "src/metrics/CountMetricProducer.cpp", 94 "src/metrics/DurationMetricProducer.cpp", 95 "src/metrics/duration_helper/OringDurationTracker.cpp", 96 "src/metrics/duration_helper/MaxDurationTracker.cpp", 97 "src/metrics/ValueMetricProducer.cpp", 98 "src/metrics/GaugeMetricProducer.cpp", 99 "src/metrics/MetricsManager.cpp", 100 "src/metrics/metrics_manager_util.cpp", 101 "src/packages/UidMap.cpp", 102 "src/storage/StorageManager.cpp", 103 "src/StatsLogProcessor.cpp", 104 "src/StatsService.cpp", 105 "src/statscompanion_util.cpp", 106 "src/subscriber/IncidentdReporter.cpp", 107 "src/subscriber/SubscriberReporter.cpp", 108 "src/HashableDimensionKey.cpp", 109 "src/guardrail/StatsdStats.cpp", 110 "src/socket/StatsSocketListener.cpp", 111 "src/shell/ShellSubscriber.cpp", 112 "src/shell/shell_config.proto", 113 ], 114 115 local_include_dirs: [ 116 "src", 117 ], 118 119 static_libs: [ 120 "libhealthhalutils", 121 ], 122 123 shared_libs: [ 124 "libbase", 125 "libbinder", 126 "libgraphicsenv", 127 "libincident", 128 "liblog", 129 "libutils", 130 "libservices", 131 "libprotoutil", 132 "libstatslog", 133 "libhardware", 134 "libhardware_legacy", 135 "libhidlbase", 136 "android.frameworks.stats@1.0", 137 "android.hardware.health@2.0", 138 "android.hardware.power@1.0", 139 "android.hardware.power@1.1", 140 "android.hardware.power.stats@1.0", 141 "libpackagelistparser", 142 "libstatsmetadata", 143 "libsysutils", 144 "libcutils", 145 ], 146} 147 148// ================ 149// libstatsmetadata 150// ================ 151 152genrule { 153 name: "atoms_info.h", 154 tools: ["stats-log-api-gen"], 155 cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h", 156 out: [ 157 "atoms_info.h", 158 ], 159} 160 161genrule { 162 name: "atoms_info.cpp", 163 tools: ["stats-log-api-gen"], 164 cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp", 165 out: [ 166 "atoms_info.cpp", 167 ], 168} 169 170cc_library_shared { 171 name: "libstatsmetadata", 172 host_supported: true, 173 generated_sources: [ 174 "atoms_info.cpp", 175 ], 176 generated_headers: [ 177 "atoms_info.h", 178 ], 179 cflags: [ 180 "-Wall", 181 "-Werror", 182 ], 183 export_generated_headers: [ 184 "atoms_info.h", 185 ], 186 shared_libs: [ 187 "libcutils", 188 "libstatslog", 189 ], 190} 191 192 193// ========= 194// statsd 195// ========= 196 197cc_binary { 198 name: "statsd", 199 defaults: ["statsd_defaults"], 200 201 srcs: ["src/main.cpp"], 202 203 cflags: [ 204 "-Wall", 205 "-Wextra", 206 "-Werror", 207 "-Wno-unused-parameter", 208 // optimize for size (protobuf glop can get big) 209 "-Os", 210 // "-g", 211 // "-O0", 212 ], 213 214 product_variables: { 215 eng: { 216 // Enable sanitizer ONLY on eng builds 217 //sanitize: { 218 // address: true, 219 //}, 220 }, 221 debuggable: { 222 // Add a flag to enable stats log printing from statsd on debug builds. 223 cflags: ["-DVERY_VERBOSE_PRINTING"], 224 }, 225 }, 226 227 proto: { 228 type: "lite", 229 }, 230 231 shared_libs: ["libgtest_prod"], 232 233 init_rc: ["statsd.rc"], 234} 235 236// ============== 237// statsd_test 238// ============== 239 240cc_test { 241 name: "statsd_test", 242 defaults: ["statsd_defaults"], 243 test_suites: ["device-tests"], 244 245 cflags: [ 246 "-Wall", 247 "-Werror", 248 "-Wno-missing-field-initializers", 249 "-Wno-unused-variable", 250 "-Wno-unused-function", 251 "-Wno-unused-parameter", 252 ], 253 254 srcs: [ 255 // atom_field_options.proto needs field_options.proto, but that is 256 // not included in libprotobuf-cpp-lite, so compile it here. 257 ":libprotobuf-internal-protos", 258 259 "src/atom_field_options.proto", 260 "src/atoms.proto", 261 "src/stats_log.proto", 262 "src/shell/shell_data.proto", 263 "tests/AlarmMonitor_test.cpp", 264 "tests/anomaly/AlarmTracker_test.cpp", 265 "tests/anomaly/AnomalyTracker_test.cpp", 266 "tests/ConfigManager_test.cpp", 267 "tests/external/puller_util_test.cpp", 268 "tests/external/GpuStatsPuller_test.cpp", 269 "tests/external/IncidentReportArgs_test.cpp", 270 "tests/external/StatsPuller_test.cpp", 271 "tests/indexed_priority_queue_test.cpp", 272 "tests/LogEntryMatcher_test.cpp", 273 "tests/LogEvent_test.cpp", 274 "tests/log_event/LogEventQueue_test.cpp", 275 "tests/MetricsManager_test.cpp", 276 "tests/StatsLogProcessor_test.cpp", 277 "tests/StatsService_test.cpp", 278 "tests/UidMap_test.cpp", 279 "tests/FieldValue_test.cpp", 280 "tests/condition/CombinationConditionTracker_test.cpp", 281 "tests/condition/SimpleConditionTracker_test.cpp", 282 "tests/condition/StateTracker_test.cpp", 283 "tests/condition/ConditionTimer_test.cpp", 284 "tests/metrics/OringDurationTracker_test.cpp", 285 "tests/metrics/MaxDurationTracker_test.cpp", 286 "tests/metrics/CountMetricProducer_test.cpp", 287 "tests/metrics/DurationMetricProducer_test.cpp", 288 "tests/metrics/EventMetricProducer_test.cpp", 289 "tests/metrics/ValueMetricProducer_test.cpp", 290 "tests/metrics/GaugeMetricProducer_test.cpp", 291 "tests/guardrail/StatsdStats_test.cpp", 292 "tests/metrics/metrics_test_helper.cpp", 293 "tests/statsd_test_util.cpp", 294 "tests/storage/StorageManager_test.cpp", 295 "tests/e2e/WakelockDuration_e2e_test.cpp", 296 "tests/e2e/MetricActivation_e2e_test.cpp", 297 "tests/e2e/MetricConditionLink_e2e_test.cpp", 298 "tests/e2e/Alarm_e2e_test.cpp", 299 "tests/e2e/Attribution_e2e_test.cpp", 300 "tests/e2e/GaugeMetric_e2e_push_test.cpp", 301 "tests/e2e/GaugeMetric_e2e_pull_test.cpp", 302 "tests/e2e/ValueMetric_pull_e2e_test.cpp", 303 "tests/e2e/DimensionInCondition_e2e_combination_AND_cond_test.cpp", 304 "tests/e2e/DimensionInCondition_e2e_combination_OR_cond_test.cpp", 305 "tests/e2e/DimensionInCondition_e2e_simple_cond_test.cpp", 306 "tests/e2e/Anomaly_count_e2e_test.cpp", 307 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", 308 "tests/e2e/ConfigTtl_e2e_test.cpp", 309 "tests/e2e/PartialBucket_e2e_test.cpp", 310 "tests/e2e/DurationMetric_e2e_test.cpp", 311 "tests/shell/ShellSubscriber_test.cpp", 312 ], 313 314 static_libs: [ 315 "libgmock", 316 "libplatformprotos", 317 ], 318 319 proto: { 320 type: "lite", 321 include_dirs: ["external/protobuf/src"], 322 }, 323 324 shared_libs: ["libprotobuf-cpp-lite"], 325 326} 327 328//############################# 329// statsd micro benchmark 330//############################# 331 332cc_benchmark { 333 name: "statsd_benchmark", 334 defaults: ["statsd_defaults"], 335 336 srcs: [ 337 // atom_field_options.proto needs field_options.proto, but that is 338 // not included in libprotobuf-cpp-lite, so compile it here. 339 ":libprotobuf-internal-protos", 340 341 "src/atom_field_options.proto", 342 "src/atoms.proto", 343 "src/stats_log.proto", 344 "benchmark/main.cpp", 345 "benchmark/hello_world_benchmark.cpp", 346 "benchmark/log_event_benchmark.cpp", 347 "benchmark/stats_write_benchmark.cpp", 348 "benchmark/filter_value_benchmark.cpp", 349 "benchmark/get_dimensions_for_condition_benchmark.cpp", 350 "benchmark/metric_util.cpp", 351 "benchmark/duration_metric_benchmark.cpp", 352 ], 353 354 proto: { 355 type: "lite", 356 include_dirs: ["external/protobuf/src"], 357 }, 358 359 cflags: [ 360 "-Wall", 361 "-Werror", 362 "-Wno-unused-parameter", 363 "-Wno-unused-variable", 364 "-Wno-unused-function", 365 366 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374 367 "-Wno-varargs" 368 ], 369 370 static_libs: [ 371 "libplatformprotos", 372 ], 373 374 shared_libs: [ 375 "libgtest_prod", 376 "libstatslog", 377 "libprotobuf-cpp-lite", 378 ], 379} 380 381// ==== java proto device library (for test only) ============================== 382java_library { 383 name: "statsdprotolite", 384 sdk_version: "core_current", 385 proto: { 386 type: "lite", 387 include_dirs: ["external/protobuf/src"], 388 }, 389 390 srcs: [ 391 "src/stats_log.proto", 392 "src/statsd_config.proto", 393 "src/atoms.proto", 394 "src/shell/shell_config.proto", 395 "src/shell/shell_data.proto", 396 ], 397 398 static_libs: [ 399 "platformprotoslite", 400 ], 401 // Protos have lots of MissingOverride and similar. 402 errorprone: { 403 javacflags: ["-XepDisableAllChecks"], 404 }, 405} 406 407// Filegroup for statsd config proto definition. 408filegroup { 409 name: "statsd-config-proto-def", 410 srcs: ["src/statsd_config.proto"], 411} 412