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 host executable: stats-log-api-gen 19// ========================================================== 20package { 21 default_team: "trendy_team_android_telemetry_infra", 22 default_applicable_licenses: ["Android-Apache-2.0"], 23} 24 25cc_binary_host { 26 name: "stats-log-api-gen", 27 srcs: [ 28 "Collation.cpp", 29 "java_writer.cpp", 30 "java_writer_q.cpp", 31 "java_writer_vendor.cpp", 32 "main.cpp", 33 "native_writer.cpp", 34 "native_writer_vendor.cpp", 35 "rust_writer.cpp", 36 "utils.cpp", 37 ], 38 cflags: [ 39 "-Wall", 40 "-Werror", 41 "-Wno-deprecated-declarations", 42 "-DWITH_VENDOR", 43 ], 44 45 shared_libs: [ 46 "libstats_proto_host", 47 "libprotobuf-cpp-full", 48 "libbase", 49 ], 50 51 proto: { 52 type: "full", 53 }, 54 55 tidy: true, 56 57 tidy_checks: [ 58 "android-*", 59 "bugprone-*", 60 "cert-*", 61 "clang-analyzer-security*", 62 "google-*", 63 "misc-*", 64 "performance-*", 65 "-bugprone-narrowing-conversions", // lots of unsigned -> int conversions 66 "-cert-err34-c", 67 "-cert-msc30-c", // warning: rand() has limited randomness; use C++11 random library 68 "-cert-msc50-cpp", // warning: rand() has limited randomness; use C++11 random library 69 ], 70 71 tidy_checks_as_errors: [ 72 "android-*", 73 "bugprone-*", 74 "cert-*", 75 "clang-analyzer-security*", 76 "google-*", 77 "misc-*", 78 "performance-*", 79 ], 80} 81 82// ========================================================== 83// Build the host test executable: stats-log-api-gen-test 84// ========================================================== 85cc_test_host { 86 name: "stats-log-api-gen-test", 87 test_suites: [ 88 "general-tests", 89 ], 90 cflags: [ 91 "-Wall", 92 "-Wextra", 93 "-Werror", 94 "-g", 95 "-DUNIT_TEST", 96 "-Wno-deprecated-declarations", 97 ], 98 srcs: [ 99 "Collation.cpp", 100 "test_api_gen.cpp", 101 "test_api_gen_vendor.cpp", 102 "test_collation.cpp", 103 "test.proto", 104 "test_feature_atoms.proto", 105 "test_vendor_atoms.proto", 106 "utils.cpp", 107 ], 108 109 static_libs: [ 110 "libgmock_host", 111 "libtestvendoratoms", 112 ], 113 114 shared_libs: [ 115 "android.frameworks.stats-V2-ndk", 116 "libstats_proto_host", 117 "libprotobuf-cpp-full", 118 "libstatslog", 119 ], 120 121 proto: { 122 type: "full", 123 include_dirs: [ 124 "external/protobuf/src", 125 ], 126 }, 127 128 data: [ 129 ":libprotobuf-internal-protos", 130 ":libstats_internal_protos", 131 "test_external.proto", 132 ], 133} 134 135// Filegroup for stats-log-api-gen test proto. 136filegroup { 137 name: "stats_log_api_gen_test_protos", 138 srcs: [ 139 "test.proto", 140 "test_external.proto", 141 "test_feature_atoms.proto", 142 "test_vendor_atoms.proto", 143 ], 144} 145 146genrule { 147 name: "test_vendor_atoms.h", 148 tools: ["stats-log-api-gen"], 149 cmd: "$(location stats-log-api-gen) --header $(out)" + 150 " --module test" + 151 " --namespace android,VendorAtoms" + 152 " --vendor-proto frameworks/proto_logging/stats/stats_log_api_gen/test_vendor_atoms.proto", 153 out: [ 154 "test_vendor_atoms.h", 155 ], 156 srcs: [ 157 "test_vendor_atoms.proto", 158 ":libprotobuf-internal-descriptor-proto", 159 ":libstats_atom_options_protos", 160 ], 161} 162 163genrule { 164 name: "test_vendor_atoms.cpp", 165 tools: ["stats-log-api-gen"], 166 cmd: "$(location stats-log-api-gen) --cpp $(out)" + 167 " --module test" + 168 " --importHeader test_vendor_atoms.h" + 169 " --namespace android,VendorAtoms" + 170 " --vendor-proto frameworks/proto_logging/stats/stats_log_api_gen/test_vendor_atoms.proto", 171 out: [ 172 "test_vendor_atoms.cpp", 173 ], 174 srcs: [ 175 "test_vendor_atoms.proto", 176 ":libprotobuf-internal-descriptor-proto", 177 ":libstats_atom_options_protos", 178 ], 179} 180 181cc_library_static { 182 name: "libtestvendoratoms", 183 host_supported: true, 184 generated_headers: [ 185 "test_vendor_atoms.h", 186 ], 187 generated_sources: [ 188 "test_vendor_atoms.cpp", 189 ], 190 export_generated_headers: [ 191 "test_vendor_atoms.h", 192 ], 193 shared_libs: [ 194 "android.frameworks.stats-V2-ndk", 195 ], 196} 197 198// ========================================================== 199// Native library 200// ========================================================== 201genrule { 202 name: "statslog.h", 203 tools: ["stats-log-api-gen"], 204 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog.h", 205 out: [ 206 "statslog.h", 207 ], 208} 209 210genrule { 211 name: "statslog.cpp", 212 tools: ["stats-log-api-gen"], 213 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog.cpp", 214 out: [ 215 "statslog.cpp", 216 ], 217} 218 219cc_library { 220 name: "libstatslog", 221 host_supported: true, 222 generated_sources: [ 223 "statslog.cpp", 224 ], 225 generated_headers: [ 226 "statslog.h", 227 ], 228 cflags: [ 229 "-Wall", 230 "-Werror", 231 ], 232 export_generated_headers: [ 233 "statslog.h", 234 ], 235 shared_libs: [ 236 "liblog", 237 "libcutils", 238 "libstatssocket", 239 "libstatspull", 240 ], 241 export_shared_lib_headers: [ 242 "libstatssocket", 243 "libstatspull", 244 ], 245 target: { 246 host: { 247 static_libs: [ 248 "libbase", 249 "statsd-aidl-ndk", 250 ], 251 shared_libs: ["libbinder_ndk"], 252 }, 253 darwin: { 254 enabled: false, 255 }, 256 }, 257} 258 259// ========================================================== 260// Rust library 261// ========================================================== 262 263genrule { 264 name: "statslog_header.rs", 265 tools: ["stats-log-api-gen"], 266 cmd: "$(location stats-log-api-gen) --rustHeader $(genDir)/statslog_header.rs --rustHeaderCrate statslog_rust_header", 267 out: [ 268 "statslog_header.rs", 269 ], 270} 271 272rust_library { 273 name: "libstatslog_rust_header", 274 crate_name: "statslog_rust_header", 275 srcs: [ 276 "rust_header_wrapper.rs", 277 ":statslog_header.rs", 278 ], 279 rustlibs: [ 280 "libstatspull_bindgen", 281 "libthiserror", 282 ], 283 apex_available: [ 284 "com.android.resolv", 285 "com.android.virt", 286 ], 287 min_sdk_version: "29", 288} 289 290genrule { 291 name: "statslog.rs", 292 tools: ["stats-log-api-gen"], 293 cmd: "$(location stats-log-api-gen) --rust $(genDir)/statslog.rs --rustHeaderCrate statslog_rust_header", 294 out: [ 295 "statslog.rs", 296 ], 297} 298 299rust_library { 300 name: "libstatslog_rust", 301 crate_name: "statslog_rust", 302 srcs: [ 303 "rust_wrapper.rs", 304 ":statslog.rs", 305 ], 306 rustlibs: [ 307 "libstatslog_rust_header", 308 "libstatspull_bindgen", 309 ], 310 apex_available: [ 311 "com.android.resolv", 312 "com.android.virt", 313 ], 314 min_sdk_version: "29", 315} 316