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 17package { 18 default_applicable_licenses: ["Android-Apache-2.0"], 19} 20 21cc_defaults { 22 name: "statsd_defaults", 23 24 cflags: [ 25 "-Wno-deprecated-declarations", 26 ], 27 28 srcs: [ 29 "src/active_config_list.proto", 30 "src/anomaly/AlarmMonitor.cpp", 31 "src/anomaly/AlarmTracker.cpp", 32 "src/anomaly/AnomalyTracker.cpp", 33 "src/anomaly/DurationAnomalyTracker.cpp", 34 "src/anomaly/subscriber_util.cpp", 35 "src/condition/CombinationConditionTracker.cpp", 36 "src/condition/condition_util.cpp", 37 "src/condition/ConditionWizard.cpp", 38 "src/condition/SimpleConditionTracker.cpp", 39 "src/config/ConfigKey.cpp", 40 "src/config/ConfigListener.cpp", 41 "src/config/ConfigManager.cpp", 42 "src/experiment_ids.proto", 43 "src/external/Perfetto.cpp", 44 "src/external/PullResultReceiver.cpp", 45 "src/external/puller_util.cpp", 46 "src/external/StatsCallbackPuller.cpp", 47 "src/external/StatsPuller.cpp", 48 "src/external/StatsPullerManager.cpp", 49 "src/external/TrainInfoPuller.cpp", 50 "src/FieldValue.cpp", 51 "src/flags/FlagProvider.cpp", 52 "src/guardrail/StatsdStats.cpp", 53 "src/hash.cpp", 54 "src/HashableDimensionKey.cpp", 55 "src/logd/LogEvent.cpp", 56 "src/logd/LogEventQueue.cpp", 57 "src/matchers/CombinationAtomMatchingTracker.cpp", 58 "src/matchers/EventMatcherWizard.cpp", 59 "src/matchers/matcher_util.cpp", 60 "src/matchers/SimpleAtomMatchingTracker.cpp", 61 "src/metadata_util.cpp", 62 "src/metrics/CountMetricProducer.cpp", 63 "src/metrics/duration_helper/MaxDurationTracker.cpp", 64 "src/metrics/duration_helper/OringDurationTracker.cpp", 65 "src/metrics/DurationMetricProducer.cpp", 66 "src/metrics/EventMetricProducer.cpp", 67 "src/metrics/RestrictedEventMetricProducer.cpp", 68 "src/metrics/GaugeMetricProducer.cpp", 69 "src/metrics/KllMetricProducer.cpp", 70 "src/metrics/MetricProducer.cpp", 71 "src/metrics/MetricsManager.cpp", 72 "src/metrics/ValueMetricProducer.cpp", 73 "src/metrics/parsing_utils/config_update_utils.cpp", 74 "src/metrics/parsing_utils/metrics_manager_util.cpp", 75 "src/metrics/NumericValueMetricProducer.cpp", 76 "src/packages/UidMap.cpp", 77 "src/shell/shell_config.proto", 78 "src/shell/ShellSubscriber.cpp", 79 "src/shell/ShellSubscriberClient.cpp", 80 "src/socket/StatsSocketListener.cpp", 81 "src/state/StateManager.cpp", 82 "src/state/StateTracker.cpp", 83 "src/stats_log_util.cpp", 84 "src/stats_policy_config.proto", 85 "src/statscompanion_util.cpp", 86 "src/statsd_config.proto", 87 "src/statsd_metadata.proto", 88 "src/guardrail/invalid_config_reason_enum.proto", 89 "src/StatsLogProcessor.cpp", 90 "src/StatsService.cpp", 91 "src/storage/StorageManager.cpp", 92 "src/subscriber/IncidentdReporter.cpp", 93 "src/subscriber/SubscriberReporter.cpp", 94 "src/uid_data.proto", 95 "src/utils/MultiConditionTrigger.cpp", 96 "src/utils/DbUtils.cpp", 97 "src/utils/RestrictedPolicyManager.cpp", 98 "src/utils/ShardOffsetProvider.cpp", 99 ], 100 101 local_include_dirs: [ 102 "src", 103 ], 104 105 static_libs: [ 106 "libbase", 107 "libcutils", 108 "libkll", 109 "libmodules-utils-build", 110 "libprotoutil", 111 "libstatslog_statsd", 112 "libsysutils", 113 "libutils", 114 "server_configurable_flags", 115 "statsd-aidl-ndk", 116 "libsqlite_static_noicu", 117 ], 118 shared_libs: [ 119 "libbinder_ndk", 120 "libincident", 121 "liblog", 122 ], 123 header_libs: [ 124 "libgtest_prod_headers", 125 ], 126} 127 128genrule { 129 name: "statslog_statsd.h", 130 tools: ["stats-log-api-gen"], 131 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsd.h --module statsd --namespace android,os,statsd,util", 132 out: [ 133 "statslog_statsd.h", 134 ], 135} 136 137genrule { 138 name: "statslog_statsd.cpp", 139 tools: ["stats-log-api-gen"], 140 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsd.cpp --module statsd --namespace android,os,statsd,util --importHeader statslog_statsd.h", 141 out: [ 142 "statslog_statsd.cpp", 143 ], 144} 145 146genrule { 147 name: "statslog_statsdtest.h", 148 tools: ["stats-log-api-gen"], 149 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_statsdtest.h --module statsdtest --namespace android,os,statsd,util", 150 out: [ 151 "statslog_statsdtest.h", 152 ], 153} 154 155genrule { 156 name: "statslog_statsdtest.cpp", 157 tools: ["stats-log-api-gen"], 158 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_statsdtest.cpp --module statsdtest --namespace android,os,statsd,util --importHeader statslog_statsdtest.h", 159 out: [ 160 "statslog_statsdtest.cpp", 161 ], 162} 163 164cc_library_static { 165 name: "libstatslog_statsdtest", 166 generated_sources: ["statslog_statsdtest.cpp"], 167 generated_headers: ["statslog_statsdtest.h"], 168 export_generated_headers: ["statslog_statsdtest.h"], 169 shared_libs: [ 170 "libstatssocket", 171 "libstatspull", 172 ], 173} 174 175cc_library_static { 176 name: "libstatslog_statsd", 177 generated_sources: ["statslog_statsd.cpp"], 178 generated_headers: ["statslog_statsd.h"], 179 export_generated_headers: ["statslog_statsd.h"], 180 apex_available: [ 181 "com.android.os.statsd", 182 "test_com.android.os.statsd", 183 ], 184 min_sdk_version: "30", 185 shared_libs: [ 186 "libstatssocket", 187 "libstatspull", 188 ], 189 export_shared_lib_headers: [ 190 "libstatspull", 191 ], 192} 193 194// ========= 195// statsd 196// ========= 197 198cc_binary { 199 name: "statsd", 200 defaults: ["statsd_defaults"], 201 202 srcs: ["src/main.cpp"], 203 204 cflags: [ 205 "-Wall", 206 "-Wextra", 207 "-Werror", 208 "-Wno-unused-parameter", 209 // optimize for size (protobuf glop can get big) 210 "-Os", 211 // "-g", 212 // "-O0", 213 ], 214 215 product_variables: { 216 eng: { 217 // Enable sanitizer ONLY on eng builds 218 //sanitize: { 219 // address: true, 220 //}, 221 }, 222 }, 223 224 proto: { 225 type: "lite", 226 static: true, 227 }, 228 stl: "libc++_static", 229 230 shared_libs: [ 231 "libstatssocket", 232 ], 233 234 apex_available: [ 235 "com.android.os.statsd", 236 "test_com.android.os.statsd", 237 ], 238 min_sdk_version: "30", 239} 240 241// ============== 242// statsd_test 243// ============== 244 245cc_test { 246 name: "statsd_test", 247 defaults: ["statsd_defaults"], 248 test_suites: [ 249 "device-tests", 250 "mts-statsd", 251 ], 252 test_config: "statsd_test.xml", 253 254 //TODO(b/153588990): Remove when the build system properly separates 255 //32bit and 64bit architectures. 256 compile_multilib: "both", 257 multilib: { 258 lib64: { 259 suffix: "64", 260 }, 261 lib32: { 262 suffix: "32", 263 }, 264 }, 265 266 cflags: [ 267 "-Wall", 268 "-Werror", 269 "-Wno-enum-compare", 270 "-Wno-missing-field-initializers", 271 "-Wno-unused-function", 272 "-Wno-unused-parameter", 273 "-Wno-unused-variable", 274 ], 275 276 require_root: true, 277 278 tidy_timeout_srcs: [ 279 "tests/condition/SimpleConditionTracker_test.cpp", 280 "tests/ConfigManager_test.cpp", 281 "tests/e2e/Anomaly_count_e2e_test.cpp", 282 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", 283 "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", 284 "tests/e2e/ConfigUpdate_e2e_test.cpp", 285 "tests/e2e/CountMetric_e2e_test.cpp", 286 "tests/e2e/DurationMetric_e2e_test.cpp", 287 "tests/e2e/GaugeMetric_e2e_pull_test.cpp", 288 "tests/e2e/MetricActivation_e2e_test.cpp", 289 "tests/e2e/PartialBucket_e2e_test.cpp", 290 "tests/e2e/ValueMetric_pull_e2e_test.cpp", 291 "tests/e2e/WakelockDuration_e2e_test.cpp", 292 "tests/external/puller_util_test.cpp", 293 "tests/external/StatsPuller_test.cpp", 294 "tests/FieldValue_test.cpp", 295 "tests/guardrail/StatsdStats_test.cpp", 296 "tests/LogEvent_test.cpp", 297 "tests/metrics/CountMetricProducer_test.cpp", 298 "tests/metrics/DurationMetricProducer_test.cpp", 299 "tests/metrics/EventMetricProducer_test.cpp", 300 "tests/metrics/GaugeMetricProducer_test.cpp", 301 "tests/metrics/KllMetricProducer_test.cpp", 302 "tests/metrics/MaxDurationTracker_test.cpp", 303 "tests/metrics/NumericValueMetricProducer_test.cpp", 304 "tests/metrics/OringDurationTracker_test.cpp", 305 "tests/metrics/RestrictedEventMetricProducer_test.cpp", 306 "tests/MetricsManager_test.cpp", 307 "tests/metrics/parsing_utils/config_update_utils_test.cpp", 308 "tests/metrics/parsing_utils/metrics_manager_util_test.cpp", 309 "tests/state/StateTracker_test.cpp", 310 "tests/statsd_test_util.cpp", 311 "tests/StatsLogProcessor_test.cpp", 312 "tests/UidMap_test.cpp", 313 ], 314 315 srcs: [ 316 // atom_field_options.proto needs field_options.proto, but that is 317 // not included in libprotobuf-cpp-lite, so compile it here. 318 ":libprotobuf-internal-protos", 319 ":libstats_internal_protos", 320 321 "src/shell/shell_data.proto", 322 "src/stats_log.proto", 323 "tests/AlarmMonitor_test.cpp", 324 "tests/anomaly/AlarmTracker_test.cpp", 325 "tests/anomaly/AnomalyTracker_test.cpp", 326 "tests/condition/CombinationConditionTracker_test.cpp", 327 "tests/condition/ConditionTimer_test.cpp", 328 "tests/condition/SimpleConditionTracker_test.cpp", 329 "tests/ConfigManager_test.cpp", 330 "tests/e2e/Alarm_e2e_test.cpp", 331 "tests/e2e/Anomaly_count_e2e_test.cpp", 332 "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", 333 "tests/e2e/Attribution_e2e_test.cpp", 334 "tests/e2e/ConfigTtl_e2e_test.cpp", 335 "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", 336 "tests/e2e/ConfigUpdate_e2e_test.cpp", 337 "tests/e2e/CountMetric_e2e_test.cpp", 338 "tests/e2e/DurationMetric_e2e_test.cpp", 339 "tests/e2e/EventMetric_e2e_test.cpp", 340 "tests/e2e/GaugeMetric_e2e_pull_test.cpp", 341 "tests/e2e/GaugeMetric_e2e_push_test.cpp", 342 "tests/e2e/KllMetric_e2e_test.cpp", 343 "tests/e2e/MetricActivation_e2e_test.cpp", 344 "tests/e2e/MetricConditionLink_e2e_test.cpp", 345 "tests/e2e/PartialBucket_e2e_test.cpp", 346 "tests/e2e/RestrictedConfig_e2e_test.cpp", 347 "tests/e2e/ValueMetric_pull_e2e_test.cpp", 348 "tests/e2e/WakelockDuration_e2e_test.cpp", 349 "tests/e2e/RestrictedEventMetric_e2e_test.cpp", 350 "tests/external/puller_util_test.cpp", 351 "tests/external/StatsCallbackPuller_test.cpp", 352 "tests/external/StatsPuller_test.cpp", 353 "tests/external/StatsPullerManager_test.cpp", 354 "tests/FieldValue_test.cpp", 355 "tests/flags/FlagProvider_test.cpp", 356 "tests/guardrail/StatsdStats_test.cpp", 357 "tests/HashableDimensionKey_test.cpp", 358 "tests/indexed_priority_queue_test.cpp", 359 "tests/log_event/LogEventQueue_test.cpp", 360 "tests/LogEntryMatcher_test.cpp", 361 "tests/LogEvent_test.cpp", 362 "tests/metadata_util_test.cpp", 363 "tests/metrics/CountMetricProducer_test.cpp", 364 "tests/metrics/DurationMetricProducer_test.cpp", 365 "tests/metrics/EventMetricProducer_test.cpp", 366 "tests/metrics/GaugeMetricProducer_test.cpp", 367 "tests/metrics/KllMetricProducer_test.cpp", 368 "tests/metrics/MaxDurationTracker_test.cpp", 369 "tests/metrics/metrics_test_helper.cpp", 370 "tests/metrics/OringDurationTracker_test.cpp", 371 "tests/metrics/NumericValueMetricProducer_test.cpp", 372 "tests/metrics/RestrictedEventMetricProducer_test.cpp", 373 "tests/metrics/parsing_utils/config_update_utils_test.cpp", 374 "tests/metrics/parsing_utils/metrics_manager_util_test.cpp", 375 "tests/subscriber/SubscriberReporter_test.cpp", 376 "tests/LogEventFilter_test.cpp", 377 "tests/MetricsManager_test.cpp", 378 "tests/shell/ShellSubscriber_test.cpp", 379 "tests/state/StateTracker_test.cpp", 380 "tests/statsd_test_util.cpp", 381 "tests/statsd_test_util_test.cpp", 382 "tests/SocketListener_test.cpp", 383 "tests/StatsLogProcessor_test.cpp", 384 "tests/StatsService_test.cpp", 385 "tests/storage/StorageManager_test.cpp", 386 "tests/UidMap_test.cpp", 387 "tests/utils/MultiConditionTrigger_test.cpp", 388 "tests/utils/DbUtils_test.cpp", 389 ], 390 391 static_libs: [ 392 "libgmock", 393 "libstatsgtestmatchers", 394 "libstatslog_statsdtest", 395 "libstatssocket_private", 396 ], 397 398 proto: { 399 type: "lite", 400 include_dirs: [ 401 "external/protobuf/src", 402 "frameworks/proto_logging/stats", 403 ], 404 static: true, 405 }, 406 min_sdk_version: "30", 407 408} 409 410//############################# 411// statsd micro benchmark 412//############################# 413 414cc_benchmark { 415 name: "statsd_benchmark", 416 defaults: ["statsd_defaults"], 417 418 srcs: [ 419 // atom_field_options.proto needs field_options.proto, but that is 420 // not included in libprotobuf-cpp-lite, so compile it here. 421 ":libprotobuf-internal-protos", 422 ":libstats_internal_protos", 423 424 "benchmark/db_benchmark.cpp", 425 "benchmark/duration_metric_benchmark.cpp", 426 "benchmark/filter_value_benchmark.cpp", 427 "benchmark/get_dimensions_for_condition_benchmark.cpp", 428 "benchmark/hello_world_benchmark.cpp", 429 "benchmark/log_event_benchmark.cpp", 430 "benchmark/log_event_filter_benchmark.cpp", 431 "benchmark/main.cpp", 432 "benchmark/metric_util.cpp", 433 "benchmark/stats_write_benchmark.cpp", 434 "src/stats_log.proto", 435 ], 436 437 proto: { 438 type: "lite", 439 include_dirs: [ 440 "external/protobuf/src", 441 "frameworks/proto_logging/stats", 442 ], 443 }, 444 445 cflags: [ 446 "-Wall", 447 "-Werror", 448 "-Wno-unused-parameter", 449 "-Wno-unused-variable", 450 "-Wno-unused-function", 451 452 // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374 453 "-Wno-varargs", 454 ], 455 456 static_libs: [ 457 "libplatformprotos", 458 "libstatssocket_private", 459 ], 460 461 shared_libs: [ 462 "libprotobuf-cpp-lite", 463 "libstatslog", 464 ], 465 466 header_libs: [ 467 "libgtest_prod_headers", 468 ], 469} 470 471// ==== java proto device library (for test only) ============================== 472java_library { 473 name: "statsdprotolite", 474 sdk_version: "core_current", 475 proto: { 476 type: "lite", 477 include_dirs: [ 478 "external/protobuf/src", 479 "frameworks/proto_logging/stats", 480 ], 481 }, 482 483 srcs: [ 484 ":libstats_atoms_proto", 485 "src/shell/shell_config.proto", 486 "src/shell/shell_data.proto", 487 "src/stats_log.proto", 488 "src/statsd_config.proto", 489 "src/guardrail/invalid_config_reason_enum.proto", 490 ], 491 492 static_libs: [ 493 "platformprotoslite", 494 ], 495 // Protos have lots of MissingOverride and similar. 496 errorprone: { 497 javacflags: ["-XepDisableAllChecks"], 498 }, 499} 500 501java_library { 502 name: "statsdprotonano", 503 sdk_version: "9", 504 proto: { 505 type: "nano", 506 output_params: ["store_unknown_fields=true"], 507 include_dirs: [ 508 "external/protobuf/src", 509 "frameworks/proto_logging/stats", 510 ], 511 }, 512 srcs: [ 513 ":libstats_atoms_proto", 514 "src/shell/shell_config.proto", 515 "src/shell/shell_data.proto", 516 "src/stats_log.proto", 517 "src/statsd_config.proto", 518 "src/guardrail/invalid_config_reason_enum.proto", 519 ], 520 static_libs: [ 521 "platformprotosnano", 522 ], 523 // Protos have lots of MissingOverride and similar. 524 errorprone: { 525 javacflags: ["-XepDisableAllChecks"], 526 }, 527} 528 529// Filegroup for statsd config proto definition. 530filegroup { 531 name: "libstats_config_protos", 532 srcs: ["src/statsd_config.proto"], 533} 534 535// Filegroup for statsd report protos. 536filegroup { 537 name: "libstats_log_protos", 538 srcs: [ 539 "src/stats_log.proto", 540 "src/guardrail/invalid_config_reason_enum.proto", 541 ], 542} 543 544// Filegroup for all statsd protos 545filegroup { 546 name: "statsd_internal_protos", 547 srcs: [ 548 "src/active_config_list.proto", 549 "src/experiment_ids.proto", 550 "src/shell/shell_config.proto", 551 "src/shell/shell_data.proto", 552 "src/statsd_config.proto", 553 "src/statsd_metadata.proto", 554 "src/stats_log.proto", 555 "src/uid_data.proto", 556 "src/guardrail/invalid_config_reason_enum.proto", 557 ], 558} 559 560// Filegroup for subscription protos. 561filegroup { 562 name: "libstats_subscription_protos", 563 srcs: [ 564 ":libstats_internal_protos", 565 ":libstats_config_protos", 566 "src/shell/shell_config.proto", 567 "src/shell/shell_data.proto", 568 ], 569} 570 571