// // Copyright (C) 2018 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. // // ========================================================================= // Native library to write stats log to statsd socket on Android R and later // ========================================================================= package { default_applicable_licenses: ["Android-Apache-2.0"], default_team: "trendy_team_android_telemetry_client_infra", } cc_defaults { name: "libstatssocket_defaults", srcs: [ "stats_buffer_writer.c", "stats_buffer_writer_queue.cpp", "stats_event.c", "stats_socket.c", "statsd_writer.cpp", "stats_socket_loss_reporter.cpp", "utils.cpp", ], local_include_dirs: [ "include", ], generated_sources: ["stats_statsdsocketlog.cpp"], generated_headers: ["stats_statsdsocketlog.h"], header_libs: [ "libcutils_headers", "liblog_headers", ], cflags: [ "-Wall", "-Werror", "-Wthread-safety", // for local testing & benchmarking with statsd_benchmark // "-DENABLE_BENCHMARK_SUPPORT", ], static_libs: [ "libbase", ], min_sdk_version: "30", } cc_library_shared { name: "libstatssocket", defaults: [ "libstatssocket_defaults", ], host_supported: true, stl: "libc++_static", export_include_dirs: ["include"], // enumerate stable entry points for APEX use target: { darwin: { enabled: false, }, }, version_script: "libstatssocket.map.txt", stubs: { symbol_file: "libstatssocket.map.txt", versions: [ "30", ], }, apex_available: [ "com.android.os.statsd", "test_com.android.os.statsd", ], } cc_library_headers { name: "libstatssocket_headers", export_include_dirs: ["include"], apex_available: [ "com.android.resolv", "//apex_available:platform", ], min_sdk_version: "29", } filegroup { name: "libstatssocket_test_default_map", srcs: ["libstatssocket_test_default.map"], } cc_library_headers { name: "libstatssocket_test_headers", export_include_dirs: ["tests/include"], min_sdk_version: "30", } cc_test { name: "libstatssocket_test", defaults: ["libstatssocket_defaults"], srcs: [ "tests/stats_event_test.cpp", "tests/stats_writer_test.cpp", "tests/stats_buffer_writer_queue_test.cpp", "tests/stats_socketlog_test.cpp", ], cflags: [ "-Wall", "-Werror", "-Wthread-safety", ], // These tests run on older platform versions, so many libraries (such as libbase and libc++) // need to be linked statically. The tests also need to be linked with a version script to // ensure that the statically-linked library isn't exported from the executable, where it // would override the shared libraries that the platform itself uses. // See http://b/333438055 for an example of what goes wrong when libc++ is partially exported // from an executable. version_script: ":libstatssocket_test_default_map", stl: "c++_static", static_libs: [ "libbase", "libgmock", ], shared_libs: [ "libutils", ], header_libs: [ "libstatssocket_test_headers", ], test_suites: [ "device-tests", "mts-statsd", ], test_config: "libstatssocket_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, } genrule { name: "stats_statsdsocketlog.h", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen) " + "--header $(genDir)/stats_statsdsocketlog.h " + "--module statsdsocket " + "--namespace android,os,statsdsocket", out: [ "stats_statsdsocketlog.h", ], } genrule { name: "stats_statsdsocketlog.cpp", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen) " + "--cpp $(genDir)/stats_statsdsocketlog.cpp " + "--module statsdsocket " + "--namespace android,os,statsdsocket " + "--importHeader stats_statsdsocketlog.h", out: [ "stats_statsdsocketlog.cpp", ], } cc_fuzz { name: "statsevent_fuzzer", defaults: [ "libstatssocket_defaults", ], srcs: [ "fuzzers/stats_event_fuzzer.cpp", ], host_supported: true, cflags: [ "-Wall", "-Wextra", "-Werror", "-Wno-unused-parameter", ], fuzz_config: { cc: [ "singhtejinder@google.com", "sharaienko@google.com", ], }, }