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 17package { 18 default_applicable_licenses: ["Android-Apache-2.0"], 19} 20 21cc_defaults { 22 name: "libsnapshot_defaults", 23 defaults: ["fs_mgr_defaults"], 24 cflags: [ 25 "-D_FILE_OFFSET_BITS=64", 26 "-Wall", 27 "-Werror", 28 ], 29 shared_libs: [ 30 "libbase", 31 "libchrome", 32 "libcutils", 33 "liblog", 34 ], 35 static_libs: [ 36 "libbrotli", 37 "libdm", 38 "libfstab", 39 "update_metadata-protos", 40 ], 41 whole_static_libs: [ 42 "libbrotli", 43 "libcutils", 44 "libext2_uuid", 45 "libext4_utils", 46 "libfstab", 47 "libsnapshot_cow", 48 "libsnapshot_snapuserd", 49 "libz", 50 ], 51 header_libs: [ 52 "libfiemap_headers", 53 "libstorage_literals_headers", 54 "libupdate_engine_headers", 55 ], 56 export_static_lib_headers: [ 57 "update_metadata-protos", 58 ], 59 export_header_lib_headers: [ 60 "libfiemap_headers", 61 ], 62 export_include_dirs: ["include"], 63 proto: { 64 type: "lite", 65 export_proto_headers: true, 66 canonical_path_from_root: false, 67 }, 68} 69 70cc_defaults { 71 name: "libsnapshot_hal_deps", 72 cflags: [ 73 "-DLIBSNAPSHOT_USE_HAL", 74 ], 75 shared_libs: [ 76 "android.hardware.boot@1.0", 77 "android.hardware.boot@1.1", 78 ], 79} 80 81filegroup { 82 name: "libsnapshot_sources", 83 srcs: [ 84 "android/snapshot/snapshot.proto", 85 "device_info.cpp", 86 "snapshot.cpp", 87 "snapshot_reader.cpp", 88 "snapshot_stats.cpp", 89 "snapshot_stub.cpp", 90 "snapshot_metadata_updater.cpp", 91 "snapshot_writer.cpp", 92 "partition_cow_creator.cpp", 93 "return.cpp", 94 "utility.cpp", 95 ], 96} 97 98cc_library_headers { 99 name: "libsnapshot_headers", 100 recovery_available: true, 101 defaults: ["libsnapshot_defaults"], 102} 103 104cc_library_static { 105 name: "libsnapshot", 106 defaults: [ 107 "libsnapshot_defaults", 108 "libsnapshot_hal_deps", 109 ], 110 srcs: [":libsnapshot_sources"], 111 static_libs: [ 112 "libfs_mgr_binder" 113 ], 114} 115 116cc_library_static { 117 name: "libsnapshot_init", 118 native_coverage : true, 119 defaults: ["libsnapshot_defaults"], 120 srcs: [":libsnapshot_sources"], 121 ramdisk_available: true, 122 recovery_available: true, 123 cflags: [ 124 "-DLIBSNAPSHOT_NO_COW_WRITE", 125 ], 126 static_libs: [ 127 "libfs_mgr", 128 ], 129} 130 131cc_library_static { 132 name: "libsnapshot_nobinder", 133 defaults: [ 134 "libsnapshot_defaults", 135 "libsnapshot_hal_deps", 136 ], 137 srcs: [":libsnapshot_sources"], 138 recovery_available: true, 139 cflags: [ 140 "-DLIBSNAPSHOT_NO_COW_WRITE", 141 ], 142 static_libs: [ 143 "libfs_mgr", 144 ], 145} 146 147cc_defaults { 148 name: "libsnapshot_cow_defaults", 149 defaults: [ 150 "fs_mgr_defaults", 151 ], 152 cflags: [ 153 "-D_FILE_OFFSET_BITS=64", 154 "-Wall", 155 "-Werror", 156 ], 157 export_include_dirs: ["include"], 158 srcs: [ 159 "cow_decompress.cpp", 160 "cow_reader.cpp", 161 "cow_writer.cpp", 162 "cow_format.cpp", 163 ], 164} 165 166cc_library_static { 167 name: "libsnapshot_cow", 168 defaults: [ 169 "libsnapshot_cow_defaults", 170 ], 171 host_supported: true, 172 recovery_available: true, 173 shared_libs: [ 174 "libbase", 175 "liblog", 176 ], 177 static_libs: [ 178 "libbrotli", 179 "libz", 180 ], 181 ramdisk_available: true, 182 vendor_ramdisk_available: true, 183} 184 185cc_library_static { 186 name: "libsnapshot_test_helpers", 187 defaults: ["libsnapshot_defaults"], 188 export_include_dirs: [ 189 "include_test", 190 ], 191 srcs: [ 192 "android/snapshot/snapshot.proto", 193 "test_helpers.cpp", 194 ], 195 shared_libs: [ 196 "android.hardware.boot@1.1", 197 "libcrypto", 198 ], 199 export_shared_lib_headers: [ 200 "android.hardware.boot@1.1", 201 ], 202 header_libs: [ 203 "libstorage_literals_headers", 204 ], 205 export_header_lib_headers: [ 206 "libstorage_literals_headers", 207 ], 208 static_libs: [ 209 "libfs_mgr", 210 "libgmock", 211 "libgtest", 212 ], 213} 214 215cc_defaults { 216 name: "libsnapshot_test_defaults", 217 defaults: ["libsnapshot_defaults"], 218 srcs: [ 219 "partition_cow_creator_test.cpp", 220 "snapshot_metadata_updater_test.cpp", 221 "snapshot_reader_test.cpp", 222 "snapshot_test.cpp", 223 "snapshot_writer_test.cpp", 224 ], 225 shared_libs: [ 226 "libbinder", 227 "libcrypto", 228 "libhidlbase", 229 "libprotobuf-cpp-lite", 230 "libutils", 231 "libz", 232 ], 233 static_libs: [ 234 "android.hardware.boot@1.0", 235 "android.hardware.boot@1.1", 236 "libbrotli", 237 "libc++fs", 238 "libfs_mgr_binder", 239 "libgflags", 240 "libgsi", 241 "libgmock", 242 "liblp", 243 "libsnapshot", 244 "libsnapshot_cow", 245 "libsnapshot_test_helpers", 246 "libsparse", 247 ], 248 header_libs: [ 249 "libstorage_literals_headers", 250 ], 251 test_suites: [ 252 "vts", 253 "device-tests" 254 ], 255 test_options: { 256 min_shipping_api_level: 29, 257 }, 258 auto_gen_config: true, 259 require_root: true, 260 compile_multilib: "first", 261} 262 263cc_test { 264 name: "vts_libsnapshot_test", 265 defaults: ["libsnapshot_test_defaults"], 266} 267 268sh_test { 269 name: "run_snapshot_tests", 270 src: "run_snapshot_tests.sh", 271 test_suites: [ 272 "device-tests", 273 ], 274 required: [ 275 "vts_libsnapshot_test", 276 ], 277} 278 279cc_test { 280 name: "vts_ota_config_test", 281 srcs: [ 282 "vts_ota_config_test.cpp", 283 ], 284 shared_libs: [ 285 "libbase", 286 ], 287 test_suites: [ 288 "vts", 289 ], 290 test_options: { 291 min_shipping_api_level: 33, 292 }, 293 auto_gen_config: true, 294 require_root: true, 295} 296 297cc_binary { 298 name: "snapshotctl", 299 srcs: [ 300 "snapshotctl.cpp", 301 ], 302 static_libs: [ 303 "libbrotli", 304 "libc++fs", 305 "libfstab", 306 "libsnapshot", 307 "libsnapshot_cow", 308 "libz", 309 "update_metadata-protos", 310 ], 311 shared_libs: [ 312 "android.hardware.boot@1.0", 313 "android.hardware.boot@1.1", 314 "libbase", 315 "libext2_uuid", 316 "libext4_utils", 317 "libfs_mgr_binder", 318 "libhidlbase", 319 "liblog", 320 "liblp", 321 "libprotobuf-cpp-lite", 322 "libstatslog", 323 "libutils", 324 ], 325} 326 327cc_test { 328 name: "snapshot_power_test", 329 srcs: [ 330 "power_test.cpp", 331 ], 332 static_libs: [ 333 "libc++fs", 334 "libsnapshot", 335 "update_metadata-protos", 336 ], 337 shared_libs: [ 338 "libbase", 339 "libfs_mgr_binder", 340 "liblog", 341 ], 342 gtest: false, 343} 344 345cc_defaults { 346 name: "libsnapshot_fuzzer_defaults", 347 native_coverage : true, 348 srcs: [ 349 // Compile the protobuf definition again with type full. 350 "android/snapshot/snapshot_fuzz.proto", 351 "update_engine/update_metadata.proto", 352 "fuzz_utils.cpp", 353 "snapshot_fuzz.cpp", 354 "snapshot_fuzz_utils.cpp", 355 356 // Compile libsnapshot sources directly to avoid dependency 357 // to update_metadata-protos 358 ":libsnapshot_sources", 359 ], 360 static_libs: [ 361 "libbase", 362 "libbrotli", 363 "libc++fs", 364 "libchrome", 365 "libcrypto_static", 366 "libcutils", 367 "libext2_uuid", 368 "libext4_utils", 369 "libfstab", 370 "libfs_mgr", 371 "libgtest", // from libsnapshot_test_helpers 372 "libgmock", // from libsnapshot_test_helpers 373 "liblog", 374 "liblp", 375 "libsnapshot_cow", 376 "libsnapshot_test_helpers", 377 "libprotobuf-mutator", 378 "libz", 379 ], 380 header_libs: [ 381 "libfiemap_headers", 382 "libstorage_literals_headers", 383 "libupdate_engine_headers", 384 ], 385 proto: { 386 type: "full", 387 canonical_path_from_root: false, 388 local_include_dirs: ["."], 389 }, 390} 391 392cc_fuzz { 393 name: "libsnapshot_fuzzer", 394 defaults: ["libsnapshot_fuzzer_defaults"], 395 corpus: ["corpus/*"], 396 fuzz_config: { 397 cc: ["android-virtual-ab+bugs@google.com"], 398 componentid: 30545, 399 hotlists: ["1646452"], 400 fuzz_on_haiku_host: false, 401 fuzz_on_haiku_device: true, 402 }, 403} 404 405cc_test { 406 name: "libsnapshot_fuzzer_test", 407 defaults: ["libsnapshot_fuzzer_defaults"], 408 data: ["corpus/*"], 409 test_suites: [ 410 "device-tests", 411 ], 412 auto_gen_config: true, 413 require_root: true, 414} 415 416cc_test { 417 name: "cow_api_test", 418 defaults: [ 419 "fs_mgr_defaults", 420 ], 421 srcs: [ 422 "cow_api_test.cpp", 423 ], 424 cflags: [ 425 "-D_FILE_OFFSET_BITS=64", 426 "-Wall", 427 "-Werror", 428 ], 429 shared_libs: [ 430 "libbase", 431 "libcrypto", 432 "liblog", 433 "libz", 434 ], 435 static_libs: [ 436 "libbrotli", 437 "libgtest", 438 "libsnapshot_cow", 439 ], 440 test_suites: [ 441 "device-tests" 442 ], 443 test_options: { 444 min_shipping_api_level: 30, 445 }, 446 auto_gen_config: true, 447 require_root: false, 448 host_supported: true, 449} 450 451cc_binary { 452 name: "make_cow_from_ab_ota", 453 host_supported: true, 454 device_supported: false, 455 cflags: [ 456 "-D_FILE_OFFSET_BITS=64", 457 "-Wall", 458 "-Werror", 459 ], 460 static_libs: [ 461 "libbase", 462 "libbspatch", 463 "libbrotli", 464 "libbz", 465 "libchrome", 466 "libcrypto", 467 "libgflags", 468 "liblog", 469 "libprotobuf-cpp-lite", 470 "libpuffpatch", 471 "libsnapshot_cow", 472 "libsparse", 473 "libxz", 474 "libz", 475 "libziparchive", 476 "update_metadata-protos", 477 ], 478 srcs: [ 479 "make_cow_from_ab_ota.cpp", 480 ], 481 target: { 482 darwin: { 483 enabled: false, 484 }, 485 }, 486} 487 488cc_binary { 489 name: "estimate_cow_from_nonab_ota", 490 host_supported: true, 491 device_supported: false, 492 cflags: [ 493 "-D_FILE_OFFSET_BITS=64", 494 "-Wall", 495 "-Werror", 496 ], 497 static_libs: [ 498 "libbase", 499 "libbrotli", 500 "libbz", 501 "libcrypto", 502 "libgflags", 503 "liblog", 504 "libsnapshot_cow", 505 "libsparse", 506 "libz", 507 "libziparchive", 508 ], 509 srcs: [ 510 "estimate_cow_from_nonab_ota.cpp", 511 ], 512 target: { 513 darwin: { 514 enabled: false, 515 }, 516 }, 517} 518 519cc_binary { 520 name: "inspect_cow", 521 host_supported: true, 522 device_supported: true, 523 cflags: [ 524 "-D_FILE_OFFSET_BITS=64", 525 "-Wall", 526 "-Werror", 527 ], 528 static_libs: [ 529 "libbase", 530 "libbrotli", 531 "libcrypto_static", 532 "liblog", 533 "libsnapshot_cow", 534 "libz", 535 ], 536 shared_libs: [ 537 ], 538 srcs: [ 539 "inspect_cow.cpp", 540 ], 541} 542 543python_library_host { 544 name: "snapshot_proto_python", 545 srcs: [ 546 "android/snapshot/snapshot.proto", 547 ], 548 proto: { 549 canonical_path_from_root: false, 550 }, 551} 552