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 recovery_available: true, 122 cflags: [ 123 "-DLIBSNAPSHOT_NO_COW_WRITE", 124 ], 125 static_libs: [ 126 "libfs_mgr", 127 ], 128} 129 130cc_library_static { 131 name: "libsnapshot_nobinder", 132 defaults: [ 133 "libsnapshot_defaults", 134 "libsnapshot_hal_deps", 135 ], 136 srcs: [":libsnapshot_sources"], 137 recovery_available: true, 138 cflags: [ 139 "-DLIBSNAPSHOT_NO_COW_WRITE", 140 ], 141 static_libs: [ 142 "libfs_mgr", 143 ], 144} 145 146cc_defaults { 147 name: "libsnapshot_cow_defaults", 148 defaults: [ 149 "fs_mgr_defaults", 150 ], 151 cflags: [ 152 "-D_FILE_OFFSET_BITS=64", 153 "-Wall", 154 "-Werror", 155 ], 156 export_include_dirs: ["include"], 157 srcs: [ 158 "cow_decompress.cpp", 159 "cow_reader.cpp", 160 "cow_writer.cpp", 161 "cow_format.cpp", 162 ], 163} 164 165cc_library_static { 166 name: "libsnapshot_cow", 167 defaults: [ 168 "libsnapshot_cow_defaults", 169 ], 170 host_supported: true, 171 recovery_available: true, 172 shared_libs: [ 173 "libbase", 174 "liblog", 175 ], 176 static_libs: [ 177 "libbrotli", 178 "libz", 179 ], 180 ramdisk_available: true, 181 vendor_ramdisk_available: true, 182} 183 184cc_defaults { 185 name: "libsnapshot_snapuserd_defaults", 186 defaults: [ 187 "fs_mgr_defaults", 188 ], 189 cflags: [ 190 "-D_FILE_OFFSET_BITS=64", 191 "-Wall", 192 "-Werror", 193 ], 194 export_include_dirs: ["include"], 195 srcs: [ 196 "snapuserd_client.cpp", 197 ], 198} 199 200cc_library_static { 201 name: "libsnapshot_snapuserd", 202 defaults: [ 203 "libsnapshot_snapuserd_defaults", 204 ], 205 recovery_available: true, 206 static_libs: [ 207 "libcutils_sockets", 208 ], 209 shared_libs: [ 210 "libbase", 211 "liblog", 212 ], 213 ramdisk_available: true, 214} 215 216cc_library_static { 217 name: "libsnapshot_test_helpers", 218 defaults: ["libsnapshot_defaults"], 219 export_include_dirs: [ 220 "include_test", 221 ], 222 srcs: [ 223 "android/snapshot/snapshot.proto", 224 "test_helpers.cpp", 225 ], 226 shared_libs: [ 227 "android.hardware.boot@1.1", 228 "libcrypto", 229 ], 230 export_shared_lib_headers: [ 231 "android.hardware.boot@1.1", 232 ], 233 header_libs: [ 234 "libstorage_literals_headers", 235 ], 236 export_header_lib_headers: [ 237 "libstorage_literals_headers", 238 ], 239 static_libs: [ 240 "libfs_mgr", 241 "libgmock", 242 "libgtest", 243 ], 244} 245 246cc_defaults { 247 name: "libsnapshot_test_defaults", 248 defaults: ["libsnapshot_defaults"], 249 srcs: [ 250 "partition_cow_creator_test.cpp", 251 "snapshot_metadata_updater_test.cpp", 252 "snapshot_reader_test.cpp", 253 "snapshot_test.cpp", 254 "snapshot_writer_test.cpp", 255 ], 256 shared_libs: [ 257 "libbinder", 258 "libcrypto", 259 "libhidlbase", 260 "libprotobuf-cpp-lite", 261 "libutils", 262 "libz", 263 ], 264 static_libs: [ 265 "android.hardware.boot@1.0", 266 "android.hardware.boot@1.1", 267 "libbrotli", 268 "libc++fs", 269 "libfs_mgr_binder", 270 "libgsi", 271 "libgmock", 272 "liblp", 273 "libsnapshot", 274 "libsnapshot_cow", 275 "libsnapshot_test_helpers", 276 "libsparse", 277 ], 278 header_libs: [ 279 "libstorage_literals_headers", 280 ], 281 test_suites: [ 282 "vts", 283 "device-tests" 284 ], 285 test_min_api_level: 29, 286 auto_gen_config: true, 287 require_root: true, 288} 289 290cc_test { 291 name: "vts_libsnapshot_test", 292 defaults: ["libsnapshot_test_defaults"], 293} 294 295cc_binary { 296 name: "snapshotctl", 297 srcs: [ 298 "snapshotctl.cpp", 299 ], 300 static_libs: [ 301 "libbrotli", 302 "libc++fs", 303 "libfstab", 304 "libsnapshot", 305 "libsnapshot_cow", 306 "libz", 307 "update_metadata-protos", 308 ], 309 shared_libs: [ 310 "android.hardware.boot@1.0", 311 "android.hardware.boot@1.1", 312 "libbase", 313 "libbinder", 314 "libext2_uuid", 315 "libext4_utils", 316 "libfs_mgr_binder", 317 "libhidlbase", 318 "liblog", 319 "liblp", 320 "libprotobuf-cpp-lite", 321 "libstatslog", 322 "libutils", 323 ], 324} 325 326cc_test { 327 name: "snapshot_power_test", 328 srcs: [ 329 "power_test.cpp", 330 ], 331 static_libs: [ 332 "libc++fs", 333 "libsnapshot", 334 "update_metadata-protos", 335 ], 336 shared_libs: [ 337 "libbase", 338 "libfs_mgr_binder", 339 "liblog", 340 ], 341 gtest: false, 342} 343 344cc_defaults { 345 name: "libsnapshot_fuzzer_defaults", 346 native_coverage : true, 347 srcs: [ 348 // Compile the protobuf definition again with type full. 349 "android/snapshot/snapshot_fuzz.proto", 350 "update_engine/update_metadata.proto", 351 "fuzz_utils.cpp", 352 "snapshot_fuzz.cpp", 353 "snapshot_fuzz_utils.cpp", 354 355 // Compile libsnapshot sources directly to avoid dependency 356 // to update_metadata-protos 357 ":libsnapshot_sources", 358 ], 359 static_libs: [ 360 "libbase", 361 "libbrotli", 362 "libc++fs", 363 "libchrome", 364 "libcrypto_static", 365 "libcutils", 366 "libext2_uuid", 367 "libext4_utils", 368 "libfstab", 369 "libfs_mgr", 370 "libgtest", // from libsnapshot_test_helpers 371 "libgmock", // from libsnapshot_test_helpers 372 "liblog", 373 "liblp", 374 "libsnapshot_cow", 375 "libsnapshot_test_helpers", 376 "libprotobuf-mutator", 377 "libz", 378 ], 379 header_libs: [ 380 "libfiemap_headers", 381 "libstorage_literals_headers", 382 "libupdate_engine_headers", 383 ], 384 proto: { 385 type: "full", 386 canonical_path_from_root: false, 387 local_include_dirs: ["."], 388 }, 389} 390 391cc_fuzz { 392 name: "libsnapshot_fuzzer", 393 defaults: ["libsnapshot_fuzzer_defaults"], 394 corpus: ["corpus/*"], 395 fuzz_config: { 396 cc: ["android-virtual-ab+bugs@google.com"], 397 componentid: 30545, 398 hotlists: ["1646452"], 399 fuzz_on_haiku_host: false, 400 fuzz_on_haiku_device: true, 401 }, 402} 403 404cc_test { 405 name: "libsnapshot_fuzzer_test", 406 defaults: ["libsnapshot_fuzzer_defaults"], 407 data: ["corpus/*"], 408 test_suites: [ 409 "device-tests", 410 ], 411 auto_gen_config: true, 412 require_root: true, 413} 414 415cc_defaults { 416 name: "snapuserd_defaults", 417 defaults: [ 418 "fs_mgr_defaults", 419 ], 420 srcs: [ 421 "snapuserd_server.cpp", 422 "snapuserd.cpp", 423 "snapuserd_daemon.cpp", 424 "snapuserd_worker.cpp", 425 "snapuserd_readahead.cpp", 426 ], 427 428 cflags: [ 429 "-Wall", 430 "-Werror" 431 ], 432 433 static_libs: [ 434 "libbase", 435 "libbrotli", 436 "libcutils_sockets", 437 "libdm", 438 "libgflags", 439 "liblog", 440 "libsnapshot_cow", 441 "libz", 442 ], 443} 444 445cc_binary { 446 name: "snapuserd", 447 defaults: ["snapuserd_defaults"], 448 init_rc: [ 449 "snapuserd.rc", 450 ], 451 static_executable: true, 452 system_shared_libs: [], 453 ramdisk_available: true, 454 vendor_ramdisk_available: true, 455 recovery_available: true, 456} 457 458cc_test { 459 name: "cow_api_test", 460 defaults: [ 461 "fs_mgr_defaults", 462 ], 463 srcs: [ 464 "cow_api_test.cpp", 465 ], 466 cflags: [ 467 "-D_FILE_OFFSET_BITS=64", 468 "-Wall", 469 "-Werror", 470 ], 471 shared_libs: [ 472 "libbase", 473 "libcrypto", 474 "liblog", 475 "libz", 476 ], 477 static_libs: [ 478 "libbrotli", 479 "libgtest", 480 "libsnapshot_cow", 481 ], 482 test_suites: [ 483 "device-tests" 484 ], 485 test_min_api_level: 30, 486 auto_gen_config: true, 487 require_root: false, 488 host_supported: true, 489} 490 491cc_binary { 492 name: "make_cow_from_ab_ota", 493 host_supported: true, 494 device_supported: false, 495 cflags: [ 496 "-D_FILE_OFFSET_BITS=64", 497 "-Wall", 498 "-Werror", 499 ], 500 static_libs: [ 501 "libbase", 502 "libbspatch", 503 "libbrotli", 504 "libbz", 505 "libchrome", 506 "libcrypto", 507 "libgflags", 508 "liblog", 509 "libprotobuf-cpp-lite", 510 "libpuffpatch", 511 "libsnapshot_cow", 512 "libsparse", 513 "libxz", 514 "libz", 515 "libziparchive", 516 "update_metadata-protos", 517 ], 518 srcs: [ 519 "make_cow_from_ab_ota.cpp", 520 ], 521 target: { 522 darwin: { 523 enabled: false, 524 }, 525 }, 526} 527 528cc_binary { 529 name: "estimate_cow_from_nonab_ota", 530 host_supported: true, 531 device_supported: false, 532 cflags: [ 533 "-D_FILE_OFFSET_BITS=64", 534 "-Wall", 535 "-Werror", 536 ], 537 static_libs: [ 538 "libbase", 539 "libbrotli", 540 "libbz", 541 "libcrypto", 542 "libgflags", 543 "liblog", 544 "libsnapshot_cow", 545 "libsparse", 546 "libz", 547 "libziparchive", 548 ], 549 srcs: [ 550 "estimate_cow_from_nonab_ota.cpp", 551 ], 552 target: { 553 darwin: { 554 enabled: false, 555 }, 556 }, 557} 558 559cc_test { 560 name: "cow_snapuserd_test", 561 defaults: [ 562 "fs_mgr_defaults", 563 ], 564 srcs: [ 565 "cow_snapuserd_test.cpp", 566 "snapuserd.cpp", 567 "snapuserd_worker.cpp", 568 ], 569 cflags: [ 570 "-Wall", 571 "-Werror", 572 ], 573 shared_libs: [ 574 "libbase", 575 "liblog", 576 ], 577 static_libs: [ 578 "libbrotli", 579 "libgtest", 580 "libsnapshot_cow", 581 "libsnapshot_snapuserd", 582 "libcutils_sockets", 583 "libz", 584 "libfs_mgr", 585 "libdm", 586 ], 587 header_libs: [ 588 "libstorage_literals_headers", 589 "libfiemap_headers", 590 ], 591 test_min_api_level: 30, 592 auto_gen_config: true, 593 require_root: false, 594} 595 596cc_binary { 597 name: "inspect_cow", 598 host_supported: true, 599 device_supported: true, 600 cflags: [ 601 "-D_FILE_OFFSET_BITS=64", 602 "-Wall", 603 "-Werror", 604 ], 605 static_libs: [ 606 "libbase", 607 "libbrotli", 608 "libcrypto_static", 609 "liblog", 610 "libsnapshot_cow", 611 "libz", 612 ], 613 shared_libs: [ 614 ], 615 srcs: [ 616 "inspect_cow.cpp", 617 ], 618} 619