• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2018 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// Native library to write stats log to statsd socket on Android R and later
19// =========================================================================
20package {
21    default_applicable_licenses: ["Android-Apache-2.0"],
22}
23
24cc_defaults {
25    name: "libstatssocket_defaults",
26    srcs: [
27        "stats_buffer_writer.c",
28        "stats_buffer_writer_queue.cpp",
29        "stats_event.c",
30        "stats_socket.c",
31        "statsd_writer.cpp",
32        "stats_socket_loss_reporter.cpp",
33        "utils.cpp",
34    ],
35    generated_sources: ["stats_statsdsocketlog.cpp"],
36    generated_headers: ["stats_statsdsocketlog.h"],
37    export_include_dirs: ["include"],
38    header_libs: [
39        "libcutils_headers",
40        "liblog_headers",
41    ],
42    cflags: [
43        "-Wall",
44        "-Werror",
45        "-Wthread-safety",
46
47        // for local testing & benchmarking with statsd_benchmark
48        // "-DENABLE_BENCHMARK_SUPPORT",
49    ],
50    static_libs: [
51        "libbase",
52    ],
53}
54
55cc_library_shared {
56    name: "libstatssocket",
57    defaults: [
58        "libstatssocket_defaults",
59    ],
60    host_supported: true,
61    stl: "libc++_static",
62
63    // enumerate stable entry points for APEX use
64    stubs: {
65        symbol_file: "libstatssocket.map.txt",
66        versions: [
67            "30",
68        ],
69    },
70    apex_available: [
71        "com.android.os.statsd",
72        "test_com.android.os.statsd",
73    ],
74    min_sdk_version: "30",
75}
76
77cc_library_headers {
78    name: "libstatssocket_headers",
79    export_include_dirs: ["include"],
80    apex_available: [
81        "com.android.resolv",
82        "//apex_available:platform",
83    ],
84    min_sdk_version: "29",
85}
86
87cc_test {
88    name: "libstatssocket_test",
89    srcs: [
90        "tests/stats_event_test.cpp",
91        "tests/stats_writer_test.cpp",
92        "tests/stats_buffer_writer_queue_test.cpp",
93        "tests/stats_socketlog_test.cpp",
94    ],
95    generated_sources: ["stats_statsdsocketlog.cpp"],
96    generated_headers: ["stats_statsdsocketlog.h"],
97    cflags: [
98        "-Wall",
99        "-Werror",
100        "-Wthread-safety",
101    ],
102    static_libs: [
103        "libbase",
104        "libgmock",
105    ],
106    shared_libs: [
107        "libutils",
108        "libstatssocket",
109    ],
110    test_suites: [
111        "device-tests",
112        "mts-statsd",
113    ],
114    test_config: "libstatssocket_test.xml",
115    //TODO(b/153588990): Remove when the build system properly separates.
116    //32bit and 64bit architectures.
117    compile_multilib: "both",
118    multilib: {
119        lib64: {
120            suffix: "64",
121        },
122        lib32: {
123            suffix: "32",
124        },
125    },
126    require_root: true,
127    min_sdk_version: "30",
128    test_for: ["com.android.os.statsd"],
129}
130
131genrule {
132    name: "stats_statsdsocketlog.h",
133    tools: ["stats-log-api-gen"],
134    cmd: "$(location stats-log-api-gen) " +
135        "--header $(genDir)/stats_statsdsocketlog.h " +
136        "--module statsdsocket " +
137        "--namespace android,os,statsdsocket",
138    out: [
139        "stats_statsdsocketlog.h",
140    ],
141}
142
143genrule {
144    name: "stats_statsdsocketlog.cpp",
145    tools: ["stats-log-api-gen"],
146    cmd: "$(location stats-log-api-gen) " +
147        "--cpp $(genDir)/stats_statsdsocketlog.cpp " +
148        "--module statsdsocket " +
149        "--namespace android,os,statsdsocket " +
150        "--importHeader stats_statsdsocketlog.h",
151    out: [
152        "stats_statsdsocketlog.cpp",
153    ],
154}
155
156cc_fuzz {
157    name: "statsevent_fuzzer",
158    defaults: [
159        "libstatssocket_defaults",
160    ],
161    srcs: [
162        "fuzzers/stats_event_fuzzer.cpp",
163    ],
164    local_include_dirs: [
165        "include",
166    ],
167    host_supported: true,
168    cflags: [
169        "-Wall",
170        "-Wextra",
171        "-Werror",
172        "-Wno-unused-parameter",
173    ],
174    fuzz_config: {
175        cc: [
176            "singhtejinder@google.com",
177            "sharaienko@google.com",
178        ],
179    },
180}
181