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