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_team: "trendy_team_android_kernel", 19 default_applicable_licenses: ["Android-Apache-2.0"], 20} 21 22cc_defaults { 23 name: "libsnapshot_defaults", 24 defaults: ["fs_mgr_defaults"], 25 cflags: [ 26 "-D_FILE_OFFSET_BITS=64", 27 "-Wall", 28 "-Werror", 29 ], 30 shared_libs: [ 31 "libbase", 32 "libchrome", 33 "libcutils", 34 "liblog", 35 ], 36 static_libs: [ 37 "libbrotli", 38 "libdm", 39 "libfstab", 40 "update_metadata-protos", 41 ], 42 whole_static_libs: [ 43 "libbrotli", 44 "libcutils", 45 "libext2_uuid", 46 "libext4_utils", 47 "libfstab", 48 "libsnapuserd_client", 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 "[email protected]", 77 "[email protected]", 78 "android.hardware.boot-V1-ndk", 79 "libboot_control_client", 80 ], 81} 82 83filegroup { 84 name: "libsnapshot_sources", 85 srcs: [ 86 "android/snapshot/snapshot.proto", 87 "device_info.cpp", 88 "snapshot.cpp", 89 "snapshot_stats.cpp", 90 "snapshot_stub.cpp", 91 "snapshot_metadata_updater.cpp", 92 "partition_cow_creator.cpp", 93 "return.cpp", 94 "utility.cpp", 95 "scratch_super.cpp", 96 ], 97} 98 99cc_library_headers { 100 name: "libsnapshot_headers", 101 recovery_available: true, 102 defaults: ["libsnapshot_defaults"], 103} 104 105cc_library_static { 106 name: "libsnapshot_static", 107 defaults: [ 108 "libsnapshot_defaults", 109 "libsnapshot_hal_deps", 110 ], 111 srcs: [":libsnapshot_sources"], 112 static_libs: [ 113 "libfs_mgr_binder", 114 ], 115 whole_static_libs: [ 116 "libselinux", 117 ], 118} 119 120cc_library { 121 name: "libsnapshot", 122 defaults: [ 123 "libsnapshot_defaults", 124 "libsnapshot_cow_defaults", 125 "libsnapshot_hal_deps", 126 ], 127 srcs: [":libsnapshot_sources"], 128 shared_libs: [ 129 "libfs_mgr_binder", 130 "liblp", 131 "libprotobuf-cpp-lite", 132 ], 133 static_libs: [ 134 "libsnapshot_cow", 135 ], 136 whole_static_libs: [ 137 "libselinux", 138 ], 139} 140 141cc_library_static { 142 name: "libsnapshot_init", 143 native_coverage: true, 144 defaults: ["libsnapshot_defaults"], 145 srcs: [":libsnapshot_sources"], 146 ramdisk_available: true, 147 recovery_available: true, 148 cflags: [ 149 "-DLIBSNAPSHOT_NO_COW_WRITE", 150 ], 151 static_libs: [ 152 "libfs_mgr", 153 "libselinux", 154 ], 155} 156 157cc_library_static { 158 name: "libsnapshot_nobinder", 159 defaults: [ 160 "libsnapshot_defaults", 161 "libsnapshot_hal_deps", 162 ], 163 srcs: [":libsnapshot_sources"], 164 recovery_available: true, 165 cflags: [ 166 "-DLIBSNAPSHOT_NO_COW_WRITE", 167 ], 168 static_libs: [ 169 "libfs_mgr", 170 ], 171 whole_static_libs: [ 172 "libselinux", 173 ], 174} 175 176cc_defaults { 177 name: "libsnapshot_cow_defaults", 178 defaults: [ 179 "fs_mgr_defaults", 180 ], 181 cflags: [ 182 "-D_FILE_OFFSET_BITS=64", 183 "-Wall", 184 "-Werror", 185 ], 186 shared_libs: [ 187 "libbase", 188 "liblog", 189 ], 190 static_libs: [ 191 "libbrotli", 192 "libz", 193 "liblz4", 194 "libzstd", 195 ], 196 header_libs: [ 197 "libupdate_engine_headers", 198 ], 199} 200 201cc_library_static { 202 name: "libsnapshot_cow", 203 defaults: [ 204 "libsnapshot_cow_defaults", 205 ], 206 srcs: [ 207 "libsnapshot_cow/cow_compress.cpp", 208 "libsnapshot_cow/cow_decompress.cpp", 209 "libsnapshot_cow/cow_format.cpp", 210 "libsnapshot_cow/cow_reader.cpp", 211 "libsnapshot_cow/parser_v2.cpp", 212 "libsnapshot_cow/parser_v3.cpp", 213 "libsnapshot_cow/snapshot_reader.cpp", 214 "libsnapshot_cow/writer_base.cpp", 215 "libsnapshot_cow/writer_v2.cpp", 216 "libsnapshot_cow/writer_v3.cpp", 217 ], 218 219 header_libs: [ 220 "libstorage_literals_headers", 221 ], 222 export_include_dirs: ["include"], 223 host_supported: true, 224 recovery_available: true, 225 ramdisk_available: true, 226 vendor_ramdisk_available: true, 227} 228 229cc_library_static { 230 name: "libsnapshot_test_helpers", 231 defaults: ["libsnapshot_defaults"], 232 export_include_dirs: [ 233 "include_test", 234 ], 235 srcs: [ 236 "android/snapshot/snapshot.proto", 237 "test_helpers.cpp", 238 ], 239 shared_libs: [ 240 "[email protected]", 241 "libcrypto", 242 ], 243 export_shared_lib_headers: [ 244 "[email protected]", 245 ], 246 header_libs: [ 247 "libstorage_literals_headers", 248 ], 249 export_header_lib_headers: [ 250 "libstorage_literals_headers", 251 ], 252 static_libs: [ 253 "libfs_mgr", 254 "libgmock", 255 "libgtest", 256 "libselinux", 257 ], 258} 259 260cc_defaults { 261 name: "libsnapshot_test_defaults", 262 defaults: [ 263 "libsnapshot_defaults", 264 "libsnapshot_cow_defaults", 265 ], 266 srcs: [ 267 "partition_cow_creator_test.cpp", 268 "snapshot_metadata_updater_test.cpp", 269 "snapshot_test.cpp", 270 ], 271 shared_libs: [ 272 "libbinder", 273 "libcrypto", 274 "libhidlbase", 275 "libprotobuf-cpp-lite", 276 "libutils", 277 "libz", 278 ], 279 static_libs: [ 280 "[email protected]", 281 "[email protected]", 282 "android.hardware.boot-V1-ndk", 283 "libbrotli", 284 "libfs_mgr_binder", 285 "libgflags", 286 "libgsi", 287 "libgmock", 288 "liblp", 289 "libsnapshot_static", 290 "libsnapshot_cow", 291 "libsnapshot_test_helpers", 292 "libsparse", 293 ], 294 header_libs: [ 295 "libstorage_literals_headers", 296 ], 297 auto_gen_config: true, 298 require_root: true, 299} 300 301cc_test { 302 name: "vts_libsnapshot_test", 303 defaults: [ 304 "libsnapshot_test_defaults", 305 "libsnapshot_hal_deps", 306 ], 307 test_suites: [ 308 "vts", 309 "general-tests", 310 ], 311 compile_multilib: "both", 312 multilib: { 313 lib32: { 314 suffix: "32", 315 }, 316 lib64: { 317 suffix: "64", 318 }, 319 }, 320 test_options: { 321 min_shipping_api_level: 30, 322 }, 323} 324 325cc_test { 326 name: "vab_legacy_tests", 327 defaults: [ 328 "libsnapshot_test_defaults", 329 "libsnapshot_hal_deps", 330 ], 331 cppflags: [ 332 "-DLIBSNAPSHOT_TEST_VAB_LEGACY", 333 ], 334 test_suites: [ 335 "general-tests", 336 ], 337 compile_multilib: "64", 338 test_options: { 339 // Legacy VAB launched in Android R. 340 min_shipping_api_level: 30, 341 test_runner_options: [ 342 { 343 name: "force-no-test-error", 344 value: "false", 345 }, 346 ], 347 }, 348} 349 350cc_test { 351 name: "vts_ota_config_test", 352 srcs: [ 353 "vts_ota_config_test.cpp", 354 ], 355 shared_libs: [ 356 "libbase", 357 ], 358 test_suites: [ 359 "vts", 360 ], 361 test_options: { 362 min_shipping_api_level: 33, 363 }, 364 auto_gen_config: true, 365 require_root: true, 366} 367 368cc_binary { 369 name: "snapshotctl", 370 defaults: [ 371 "libsnapshot_cow_defaults", 372 "libsnapshot_hal_deps", 373 ], 374 srcs: [ 375 "snapshotctl.cpp", 376 "scratch_super.cpp", 377 ], 378 static_libs: [ 379 "libbrotli", 380 "libfstab", 381 "libz", 382 "update_metadata-protos", 383 ], 384 shared_libs: [ 385 "libbase", 386 "libext2_uuid", 387 "libext4_utils", 388 "libfs_mgr_binder", 389 "libhidlbase", 390 "liblog", 391 "liblp", 392 "libprotobuf-cpp-lite", 393 "libsnapshot", 394 "libstatslog", 395 "libutils", 396 ], 397 header_libs: [ 398 "libstorage_literals_headers", 399 ], 400 product_variables: { 401 debuggable: { 402 cppflags: [ 403 "-DSNAPSHOTCTL_USERDEBUG_OR_ENG", 404 ], 405 shared_libs: [ 406 "[email protected]", 407 "[email protected]", 408 "android.hardware.boot-V1-ndk", 409 "libboot_control_client", 410 ], 411 }, 412 }, 413} 414 415cc_test { 416 name: "cow_api_test", 417 defaults: [ 418 "fs_mgr_defaults", 419 "libsnapshot_cow_defaults", 420 ], 421 srcs: [ 422 "libsnapshot_cow/snapshot_reader_test.cpp", 423 "libsnapshot_cow/test_v2.cpp", 424 "libsnapshot_cow/test_v3.cpp", 425 ], 426 cflags: [ 427 "-D_FILE_OFFSET_BITS=64", 428 "-Wall", 429 "-Werror", 430 ], 431 shared_libs: [ 432 "libbase", 433 "libcrypto", 434 "liblog", 435 "libz", 436 ], 437 static_libs: [ 438 "libbrotli", 439 "libgtest", 440 "libsnapshot_cow", 441 ], 442 header_libs: [ 443 "libstorage_literals_headers", 444 ], 445 test_suites: [ 446 "general-tests", 447 ], 448 test_options: { 449 min_shipping_api_level: 30, 450 }, 451 data: [ 452 "tools/testdata/cow_v2", 453 "tools/testdata/incompressible_block", 454 ], 455 auto_gen_config: true, 456 require_root: false, 457 host_supported: true, 458} 459 460cc_binary { 461 name: "inspect_cow", 462 host_supported: true, 463 device_supported: true, 464 defaults: ["libsnapshot_cow_defaults"], 465 cflags: [ 466 "-D_FILE_OFFSET_BITS=64", 467 "-Wall", 468 "-Werror", 469 ], 470 static_libs: [ 471 "libbase", 472 "libbrotli", 473 "libcrypto_static", 474 "liblog", 475 "libgflags", 476 "libsnapshot_cow", 477 "libz", 478 ], 479 shared_libs: [ 480 ], 481 srcs: [ 482 "libsnapshot_cow/inspect_cow.cpp", 483 ], 484} 485 486cc_binary { 487 name: "create_snapshot", 488 host_supported: true, 489 device_supported: false, 490 491 srcs: ["libsnapshot_cow/create_cow.cpp"], 492 493 cflags: [ 494 "-Wall", 495 "-Werror", 496 ], 497 498 static_libs: [ 499 "liblog", 500 "libbase", 501 "libext4_utils", 502 "libsnapshot_cow", 503 "libcrypto", 504 "libbrotli", 505 "libz", 506 "liblz4", 507 "libzstd", 508 "libgflags", 509 ], 510 shared_libs: [ 511 ], 512 513 header_libs: [ 514 "libstorage_literals_headers", 515 ], 516 517 dist: { 518 targets: [ 519 "sdk", 520 "sdk-repo-platform-tools", 521 "sdk_repo", 522 ], 523 }, 524 target: { 525 darwin: { 526 enabled: false, 527 }, 528 windows: { 529 enabled: false, 530 }, 531 }, 532 stl: "libc++_static", 533 static_executable: true, 534} 535 536python_library_host { 537 name: "snapshot_proto_python", 538 srcs: [ 539 "android/snapshot/snapshot.proto", 540 ], 541 proto: { 542 canonical_path_from_root: false, 543 }, 544} 545