| // |
| // Copyright (C) 2017 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| // |
| |
| package { |
| default_applicable_licenses: ["Android-Apache-2.0"], |
| } |
| |
| cc_defaults { |
| name: "statsd_defaults", |
| |
| cflags: [ |
| "-Wno-deprecated-declarations", |
| "-Wthread-safety", |
| ], |
| tidy: true, |
| tidy_flags: [ |
| // Only check our headers |
| "-header-filter=^packages/modules/StatsD/statsd", |
| ], |
| |
| tidy_checks: [ |
| "android-*", |
| "bugprone-*", |
| "cert-*", |
| "clang-analyzer-security*", |
| "google-*", |
| "misc-*", |
| "performance-*", |
| "-bugprone-narrowing-conversions", // lots of unsigned -> int conversions |
| "-cert-err34-c", |
| "-cert-msc30-c", // warning: rand() has limited randomness; use C++11 random library |
| "-cert-msc50-cpp", // warning: rand() has limited randomness; use C++11 random library |
| ], |
| tidy_checks_as_errors: [ |
| "android-*", |
| "bugprone-*", |
| "cert-*", |
| "clang-analyzer-security*", |
| "google-*", |
| "misc-*", |
| "performance-*", |
| ], |
| srcs: [ |
| "src/active_config_list.proto", |
| "src/anomaly/AlarmMonitor.cpp", |
| "src/anomaly/AlarmTracker.cpp", |
| "src/anomaly/AnomalyTracker.cpp", |
| "src/anomaly/DurationAnomalyTracker.cpp", |
| "src/anomaly/subscriber_util.cpp", |
| "src/condition/CombinationConditionTracker.cpp", |
| "src/condition/condition_util.cpp", |
| "src/condition/ConditionWizard.cpp", |
| "src/condition/SimpleConditionTracker.cpp", |
| "src/config/ConfigKey.cpp", |
| "src/config/ConfigListener.cpp", |
| "src/config/ConfigManager.cpp", |
| "src/experiment_ids.proto", |
| "src/external/Perfetto.cpp", |
| "src/external/PullResultReceiver.cpp", |
| "src/external/puller_util.cpp", |
| "src/external/StatsCallbackPuller.cpp", |
| "src/external/StatsPuller.cpp", |
| "src/external/StatsPullerManager.cpp", |
| "src/external/TrainInfoPuller.cpp", |
| "src/external/Uprobestats.cpp", |
| "src/FieldValue.cpp", |
| "src/flags/FlagProvider.cpp", |
| "src/guardrail/StatsdStats.cpp", |
| "src/hash.cpp", |
| "src/HashableDimensionKey.cpp", |
| "src/logd/LogEvent.cpp", |
| "src/logd/LogEventQueue.cpp", |
| "src/logd/logevent_util.cpp", |
| "src/matchers/CombinationAtomMatchingTracker.cpp", |
| "src/matchers/EventMatcherWizard.cpp", |
| "src/matchers/matcher_util.cpp", |
| "src/matchers/SimpleAtomMatchingTracker.cpp", |
| "src/metadata_util.cpp", |
| "src/metrics/CountMetricProducer.cpp", |
| "src/metrics/duration_helper/MaxDurationTracker.cpp", |
| "src/metrics/duration_helper/OringDurationTracker.cpp", |
| "src/metrics/DurationMetricProducer.cpp", |
| "src/metrics/EventMetricProducer.cpp", |
| "src/metrics/RestrictedEventMetricProducer.cpp", |
| "src/metrics/GaugeMetricProducer.cpp", |
| "src/metrics/KllMetricProducer.cpp", |
| "src/metrics/MetricProducer.cpp", |
| "src/metrics/MetricsManager.cpp", |
| "src/metrics/ValueMetricProducer.cpp", |
| "src/metrics/parsing_utils/config_update_utils.cpp", |
| "src/metrics/parsing_utils/metrics_manager_util.cpp", |
| "src/metrics/NumericValueMetricProducer.cpp", |
| "src/packages/UidMap.cpp", |
| "src/shell/shell_config.proto", |
| "src/shell/ShellSubscriber.cpp", |
| "src/shell/ShellSubscriberClient.cpp", |
| "src/socket/StatsSocketListener.cpp", |
| "src/state/StateManager.cpp", |
| "src/state/StateTracker.cpp", |
| "src/stats_log_util.cpp", |
| "src/stats_policy_config.proto", |
| "src/statscompanion_util.cpp", |
| "src/statsd_config.proto", |
| "src/statsd_metadata.proto", |
| "src/guardrail/stats_log_enums.proto", |
| "src/StatsLogProcessor.cpp", |
| "src/StatsService.cpp", |
| "src/storage/StorageManager.cpp", |
| "src/subscriber/IncidentdReporter.cpp", |
| "src/subscriber/SubscriberReporter.cpp", |
| "src/uid_data.proto", |
| "src/utils/MultiConditionTrigger.cpp", |
| "src/utils/DbUtils.cpp", |
| "src/utils/Regex.cpp", |
| "src/utils/RestrictedPolicyManager.cpp", |
| "src/utils/ShardOffsetProvider.cpp", |
| ], |
| |
| local_include_dirs: [ |
| "src", |
| ], |
| |
| static_libs: [ |
| "libbase", |
| "libcutils", |
| "libkll", |
| "libmodules-utils-build", |
| "libprotoutil", |
| "libstatslog_statsd", |
| "libsysutils", |
| "libutils", |
| "server_configurable_flags", |
| "statsd-aidl-ndk", |
| "libsqlite_static_noicu", |
| ], |
| shared_libs: [ |
| "libbinder_ndk", |
| "libincident", |
| "liblog", |
| "libstatssocket", |
| ], |
| header_libs: [ |
| "libgtest_prod_headers", |
| ], |
| } |
| |
| genrule { |
| name: "statslog_statsd.h", |
| tools: ["stats-log-api-gen"], |
| cmd: "$(location stats-log-api-gen) " + |
| "--header $(genDir)/statslog_statsd.h " + |
| "--module statsd " + |
| "--namespace android,os,statsd,util", |
| out: [ |
| "statslog_statsd.h", |
| ], |
| } |
| |
| genrule { |
| name: "statslog_statsd.cpp", |
| tools: ["stats-log-api-gen"], |
| cmd: "$(location stats-log-api-gen) " + |
| "--cpp $(genDir)/statslog_statsd.cpp " + |
| "--module statsd " + |
| "--namespace android,os,statsd,util " + |
| "--importHeader statslog_statsd.h", |
| out: [ |
| "statslog_statsd.cpp", |
| ], |
| } |
| |
| genrule { |
| name: "statslog_statsdtest.h", |
| tools: ["stats-log-api-gen"], |
| cmd: "$(location stats-log-api-gen) " + |
| "--header $(genDir)/statslog_statsdtest.h " + |
| "--module statsdtest " + |
| "--namespace android,os,statsd,util", |
| out: [ |
| "statslog_statsdtest.h", |
| ], |
| } |
| |
| genrule { |
| name: "statslog_statsdtest.cpp", |
| tools: ["stats-log-api-gen"], |
| cmd: "$(location stats-log-api-gen) " + |
| "--cpp $(genDir)/statslog_statsdtest.cpp " + |
| "--module statsdtest " + |
| "--namespace android,os,statsd,util " + |
| "--importHeader statslog_statsdtest.h", |
| out: [ |
| "statslog_statsdtest.cpp", |
| ], |
| } |
| |
| cc_library_static { |
| name: "libstatslog_statsdtest", |
| generated_sources: ["statslog_statsdtest.cpp"], |
| generated_headers: ["statslog_statsdtest.h"], |
| export_generated_headers: ["statslog_statsdtest.h"], |
| shared_libs: [ |
| "libstatssocket", |
| "libstatspull", |
| ], |
| } |
| |
| cc_library_static { |
| name: "libstatslog_statsd", |
| generated_sources: ["statslog_statsd.cpp"], |
| generated_headers: ["statslog_statsd.h"], |
| export_generated_headers: ["statslog_statsd.h"], |
| apex_available: [ |
| "com.android.os.statsd", |
| "test_com.android.os.statsd", |
| ], |
| min_sdk_version: "30", |
| shared_libs: [ |
| "libstatssocket", |
| "libstatspull", |
| ], |
| export_shared_lib_headers: [ |
| "libstatspull", |
| ], |
| } |
| |
| // ========= |
| // statsd |
| // ========= |
| |
| cc_binary { |
| name: "statsd", |
| defaults: ["statsd_defaults"], |
| |
| srcs: ["src/main.cpp"], |
| |
| cflags: [ |
| "-Wall", |
| "-Wextra", |
| "-Werror", |
| "-Wno-unused-parameter", |
| // optimize for size (protobuf glop can get big) |
| "-Os", |
| // "-g", |
| // "-O0", |
| ], |
| |
| proto: { |
| type: "lite", |
| static: true, |
| }, |
| stl: "libc++_static", |
| |
| apex_available: [ |
| "com.android.os.statsd", |
| "test_com.android.os.statsd", |
| ], |
| min_sdk_version: "30", |
| } |
| |
| cc_defaults { |
| name: "statsd_test_defaults", |
| defaults: ["statsd_defaults"], |
| srcs: [ |
| // atom_field_options.proto needs field_options.proto, but that is |
| // not included in libprotobuf-cpp-lite, so compile it here. |
| ":libprotobuf-internal-protos", |
| ":libstats_internal_protos", |
| |
| "src/shell/shell_data.proto", |
| "src/stats_log.proto", |
| ], |
| cflags: [ |
| "-Wall", |
| "-Werror", |
| "-Wno-enum-compare", |
| "-Wno-missing-field-initializers", |
| "-Wno-unused-function", |
| "-Wno-unused-parameter", |
| "-Wno-unused-variable", |
| ], |
| static_libs: [ |
| "libgmock", |
| "libstatslog_statsdtest", |
| ], |
| proto: { |
| type: "lite", |
| include_dirs: [ |
| "external/protobuf/src", |
| "frameworks/proto_logging/stats", |
| ], |
| static: true, |
| }, |
| } |
| |
| cc_library_static { |
| name: "libstats_test_utils", |
| defaults: ["statsd_test_defaults"], |
| srcs: [ |
| "tests/statsd_test_util.cpp", |
| ], |
| tidy_timeout_srcs: [ |
| "tests/statsd_test_util.cpp", |
| ], |
| } |
| |
| // ============== |
| // statsd_test |
| // ============== |
| |
| cc_test { |
| name: "statsd_test", |
| defaults: ["statsd_test_defaults"], |
| test_suites: [ |
| "device-tests", |
| "mts-statsd", |
| ], |
| test_config: "statsd_test.xml", |
| |
| //TODO(b/153588990): Remove when the build system properly separates |
| //32bit and 64bit architectures. |
| compile_multilib: "both", |
| multilib: { |
| lib64: { |
| suffix: "64", |
| }, |
| lib32: { |
| suffix: "32", |
| }, |
| }, |
| |
| require_root: true, |
| |
| tidy_timeout_srcs: [ |
| "tests/condition/SimpleConditionTracker_test.cpp", |
| "tests/ConfigManager_test.cpp", |
| "tests/e2e/Anomaly_count_e2e_test.cpp", |
| "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", |
| "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", |
| "tests/e2e/ConfigUpdate_e2e_test.cpp", |
| "tests/e2e/CountMetric_e2e_test.cpp", |
| "tests/e2e/DurationMetric_e2e_test.cpp", |
| "tests/e2e/GaugeMetric_e2e_pull_test.cpp", |
| "tests/e2e/MetricActivation_e2e_test.cpp", |
| "tests/e2e/PartialBucket_e2e_test.cpp", |
| "tests/e2e/ValueMetric_pull_e2e_test.cpp", |
| "tests/e2e/WakelockDuration_e2e_test.cpp", |
| "tests/external/puller_util_test.cpp", |
| "tests/external/StatsPuller_test.cpp", |
| "tests/FieldValue_test.cpp", |
| "tests/guardrail/StatsdStats_test.cpp", |
| "tests/LogEvent_test.cpp", |
| "tests/metrics/CountMetricProducer_test.cpp", |
| "tests/metrics/DurationMetricProducer_test.cpp", |
| "tests/metrics/EventMetricProducer_test.cpp", |
| "tests/metrics/GaugeMetricProducer_test.cpp", |
| "tests/metrics/KllMetricProducer_test.cpp", |
| "tests/metrics/MaxDurationTracker_test.cpp", |
| "tests/metrics/NumericValueMetricProducer_test.cpp", |
| "tests/metrics/OringDurationTracker_test.cpp", |
| "tests/metrics/RestrictedEventMetricProducer_test.cpp", |
| "tests/MetricsManager_test.cpp", |
| "tests/metrics/parsing_utils/config_update_utils_test.cpp", |
| "tests/metrics/parsing_utils/metrics_manager_util_test.cpp", |
| "tests/state/StateTracker_test.cpp", |
| "tests/StatsLogProcessor_test.cpp", |
| "tests/UidMap_test.cpp", |
| ], |
| |
| srcs: [ |
| "tests/AlarmMonitor_test.cpp", |
| "tests/anomaly/AlarmTracker_test.cpp", |
| "tests/anomaly/AnomalyTracker_test.cpp", |
| "tests/condition/CombinationConditionTracker_test.cpp", |
| "tests/condition/ConditionTimer_test.cpp", |
| "tests/condition/SimpleConditionTracker_test.cpp", |
| "tests/ConfigManager_test.cpp", |
| "tests/e2e/Alarm_e2e_test.cpp", |
| "tests/e2e/Anomaly_count_e2e_test.cpp", |
| "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", |
| "tests/e2e/Attribution_e2e_test.cpp", |
| "tests/e2e/ConfigTtl_e2e_test.cpp", |
| "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", |
| "tests/e2e/ConfigUpdate_e2e_test.cpp", |
| "tests/e2e/CountMetric_e2e_test.cpp", |
| "tests/e2e/DurationMetric_e2e_test.cpp", |
| "tests/e2e/EventMetric_e2e_test.cpp", |
| "tests/e2e/GaugeMetric_e2e_pull_test.cpp", |
| "tests/e2e/GaugeMetric_e2e_push_test.cpp", |
| "tests/e2e/KllMetric_e2e_test.cpp", |
| "tests/e2e/MetricActivation_e2e_test.cpp", |
| "tests/e2e/MetricConditionLink_e2e_test.cpp", |
| "tests/e2e/PartialBucket_e2e_test.cpp", |
| "tests/e2e/RestrictedConfig_e2e_test.cpp", |
| "tests/e2e/RestrictedEventMetric_e2e_test.cpp", |
| "tests/e2e/StringReplace_e2e_test.cpp", |
| "tests/e2e/ValueMetric_pull_e2e_test.cpp", |
| "tests/e2e/WakelockDuration_e2e_test.cpp", |
| "tests/external/puller_util_test.cpp", |
| "tests/external/StatsCallbackPuller_test.cpp", |
| "tests/external/StatsPuller_test.cpp", |
| "tests/external/StatsPullerManager_test.cpp", |
| "tests/FieldValue_test.cpp", |
| "tests/flags/FlagProvider_test.cpp", |
| "tests/guardrail/StatsdStats_test.cpp", |
| "tests/HashableDimensionKey_test.cpp", |
| "tests/indexed_priority_queue_test.cpp", |
| "tests/log_event/LogEventQueue_test.cpp", |
| "tests/LogEntryMatcher_test.cpp", |
| "tests/LogEvent_test.cpp", |
| "tests/metadata_util_test.cpp", |
| "tests/metrics/CountMetricProducer_test.cpp", |
| "tests/metrics/DurationMetricProducer_test.cpp", |
| "tests/metrics/EventMetricProducer_test.cpp", |
| "tests/metrics/GaugeMetricProducer_test.cpp", |
| "tests/metrics/KllMetricProducer_test.cpp", |
| "tests/metrics/MaxDurationTracker_test.cpp", |
| "tests/metrics/metrics_test_helper.cpp", |
| "tests/metrics/OringDurationTracker_test.cpp", |
| "tests/metrics/NumericValueMetricProducer_test.cpp", |
| "tests/metrics/RestrictedEventMetricProducer_test.cpp", |
| "tests/metrics/parsing_utils/config_update_utils_test.cpp", |
| "tests/metrics/parsing_utils/metrics_manager_util_test.cpp", |
| "tests/subscriber/SubscriberReporter_test.cpp", |
| "tests/LogEventFilter_test.cpp", |
| "tests/MetricsManager_test.cpp", |
| "tests/shell/ShellSubscriber_test.cpp", |
| "tests/state/StateTracker_test.cpp", |
| "tests/statsd_test_util_test.cpp", |
| "tests/SocketListener_test.cpp", |
| "tests/StatsLogProcessor_test.cpp", |
| "tests/StatsService_test.cpp", |
| "tests/storage/StorageManager_test.cpp", |
| "tests/UidMap_test.cpp", |
| "tests/utils/MultiConditionTrigger_test.cpp", |
| "tests/utils/DbUtils_test.cpp", |
| ], |
| |
| static_libs: [ |
| "libstatsgtestmatchers", |
| "libstats_test_utils", |
| ], |
| |
| min_sdk_version: "30", |
| test_for: ["com.android.os.statsd"], |
| } |
| |
| //############################# |
| // statsd micro benchmark |
| //############################# |
| |
| cc_benchmark { |
| name: "statsd_benchmark", |
| defaults: ["statsd_test_defaults"], |
| |
| srcs: [ |
| "benchmark/data_structures_benchmark.cpp", |
| "benchmark/db_benchmark.cpp", |
| "benchmark/duration_metric_benchmark.cpp", |
| "benchmark/filter_value_benchmark.cpp", |
| "benchmark/get_dimensions_for_condition_benchmark.cpp", |
| "benchmark/hello_world_benchmark.cpp", |
| "benchmark/log_event_benchmark.cpp", |
| "benchmark/log_event_filter_benchmark.cpp", |
| "benchmark/main.cpp", |
| "benchmark/on_log_event_benchmark.cpp", |
| "benchmark/stats_write_benchmark.cpp", |
| "benchmark/loss_info_container_benchmark.cpp", |
| "benchmark/string_transform_benchmark.cpp", |
| ], |
| |
| cflags: [ |
| // Bug: http://b/29823425 Disable -Wvarargs for Clang update to r271374 |
| "-Wno-varargs", |
| ], |
| |
| static_libs: [ |
| "libgtest", |
| "libstats_test_utils", |
| ], |
| |
| test_for: ["com.android.os.statsd"], |
| } |
| |
| // ==== java proto device library (for test only) ============================== |
| java_library { |
| name: "statsdprotolite", |
| sdk_version: "core_current", |
| proto: { |
| type: "lite", |
| include_dirs: [ |
| "external/protobuf/src", |
| "frameworks/proto_logging/stats", |
| ], |
| }, |
| |
| srcs: [ |
| ":libstats_atoms_proto", |
| "src/shell/shell_config.proto", |
| "src/shell/shell_data.proto", |
| "src/stats_log.proto", |
| "src/statsd_config.proto", |
| "src/guardrail/stats_log_enums.proto", |
| ], |
| |
| static_libs: [ |
| "platformprotoslite", |
| ], |
| // Protos have lots of MissingOverride and similar. |
| errorprone: { |
| javacflags: ["-XepDisableAllChecks"], |
| }, |
| } |
| |
| java_library { |
| name: "statsdprotonano", |
| sdk_version: "9", |
| proto: { |
| type: "nano", |
| output_params: ["store_unknown_fields=true"], |
| include_dirs: [ |
| "external/protobuf/src", |
| "frameworks/proto_logging/stats", |
| ], |
| }, |
| srcs: [ |
| ":libstats_atoms_proto", |
| "src/shell/shell_config.proto", |
| "src/shell/shell_data.proto", |
| "src/stats_log.proto", |
| "src/statsd_config.proto", |
| "src/guardrail/stats_log_enums.proto", |
| ], |
| static_libs: [ |
| "platformprotosnano", |
| ], |
| // Protos have lots of MissingOverride and similar. |
| errorprone: { |
| javacflags: ["-XepDisableAllChecks"], |
| }, |
| } |
| |
| // Filegroup for statsd config proto definition. |
| filegroup { |
| name: "libstats_config_protos", |
| srcs: ["src/statsd_config.proto"], |
| } |
| |
| // Filegroup for statsd report protos. |
| filegroup { |
| name: "libstats_log_protos", |
| srcs: [ |
| "src/stats_log.proto", |
| "src/guardrail/stats_log_enums.proto", |
| ], |
| } |
| |
| // Filegroup for all statsd protos |
| filegroup { |
| name: "statsd_internal_protos", |
| srcs: [ |
| "src/active_config_list.proto", |
| "src/experiment_ids.proto", |
| "src/shell/shell_config.proto", |
| "src/shell/shell_data.proto", |
| "src/statsd_config.proto", |
| "src/statsd_metadata.proto", |
| "src/stats_log.proto", |
| "src/uid_data.proto", |
| "src/guardrail/stats_log_enums.proto", |
| ], |
| } |
| |
| cc_fuzz { |
| name: "statsd_service_fuzzer", |
| defaults: [ |
| "statsd_defaults", |
| "service_fuzzer_defaults", |
| ], |
| srcs: [ |
| "fuzzers/statsd_service_fuzzer.cpp", |
| ], |
| shared_libs: [ |
| "libstatssocket", |
| "libvndksupport", |
| ], |
| cflags: [ |
| "-Wall", |
| "-Wextra", |
| "-Werror", |
| "-Wno-unused-parameter", |
| ], |
| fuzz_config: { |
| triage_assignee: "[email protected]", |
| cc: [ |
| "[email protected]", |
| "[email protected]", |
| ], |
| }, |
| proto: { |
| type: "lite", |
| static: true, |
| }, |
| } |
| |
| cc_fuzz { |
| name: "statsd_fuzzer", |
| defaults: [ |
| "statsd_defaults", |
| ], |
| srcs: [ |
| "fuzzers/statsd_socket_data_fuzzer.cpp", |
| ], |
| shared_libs: [ |
| "libstatssocket", |
| ], |
| cflags: [ |
| "-Wall", |
| "-Wextra", |
| "-Werror", |
| "-Wno-unused-parameter", |
| ], |
| fuzz_config: { |
| cc: [ |
| "[email protected]", |
| "[email protected]", |
| ], |
| }, |
| proto: { |
| type: "lite", |
| static: true, |
| }, |
| } |
| |
| // Filegroup for subscription protos. |
| filegroup { |
| name: "libstats_subscription_protos", |
| srcs: [ |
| ":libstats_internal_protos", |
| ":libstats_config_protos", |
| "src/shell/shell_config.proto", |
| "src/shell/shell_data.proto", |
| ], |
| } |