1// Copyright (C) 2019 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package sdk 16 17import ( 18 "fmt" 19 "testing" 20 21 "android/soong/android" 22 "android/soong/cc" 23) 24 25var ccTestFs = android.MockFS{ 26 "Test.cpp": nil, 27 "myinclude/Test.h": nil, 28 "myinclude-android/AndroidTest.h": nil, 29 "myinclude-host/HostTest.h": nil, 30 "arm64/include/Arm64Test.h": nil, 31 "libfoo.so": nil, 32 "aidl/foo/bar/Test.aidl": nil, 33 "some/where/stubslib.map.txt": nil, 34} 35 36// Adds a native bridge target to the configured list of targets. 37var prepareForTestWithNativeBridgeTarget = android.FixtureModifyConfig(func(config android.Config) { 38 config.Targets[android.Android] = append(config.Targets[android.Android], android.Target{ 39 Os: android.Android, 40 Arch: android.Arch{ 41 ArchType: android.Arm64, 42 ArchVariant: "armv8-a", 43 CpuVariant: "cpu", 44 Abi: nil, 45 ArchFeatures: nil, 46 }, 47 NativeBridge: android.NativeBridgeEnabled, 48 NativeBridgeHostArchName: "x86_64", 49 NativeBridgeRelativePath: "native_bridge", 50 }) 51}) 52 53func testSdkWithCc(t *testing.T, bp string) *android.TestResult { 54 t.Helper() 55 return testSdkWithFs(t, bp, ccTestFs) 56} 57 58// Contains tests for SDK members provided by the cc package. 59 60func TestSingleDeviceOsAssumption(t *testing.T) { 61 // Mock a module with DeviceSupported() == true. 62 s := &sdk{} 63 android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon) 64 65 osTypes := s.getPossibleOsTypes() 66 if len(osTypes) != 1 { 67 // The snapshot generation assumes there is a single device OS. If more are 68 // added it might need to disable them by default, like it does for host 69 // OS'es. 70 t.Errorf("expected a single device OS, got %v", osTypes) 71 } 72} 73 74func TestSdkIsCompileMultilibBoth(t *testing.T) { 75 result := testSdkWithCc(t, ` 76 sdk { 77 name: "mysdk", 78 native_shared_libs: ["sdkmember"], 79 } 80 81 cc_library_shared { 82 name: "sdkmember", 83 srcs: ["Test.cpp"], 84 stl: "none", 85 } 86 `) 87 88 armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile() 89 arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile() 90 91 var inputs []string 92 buildParams := result.Module("mysdk", android.CommonOS.Name).BuildParamsForTests() 93 for _, bp := range buildParams { 94 if bp.Input != nil { 95 inputs = append(inputs, bp.Input.String()) 96 } 97 } 98 99 // ensure that both 32/64 outputs are inputs of the sdk snapshot 100 ensureListContains(t, inputs, armOutput.String()) 101 ensureListContains(t, inputs, arm64Output.String()) 102} 103 104func TestSdkCompileMultilibOverride(t *testing.T) { 105 result := testSdkWithCc(t, ` 106 sdk { 107 name: "mysdk", 108 host_supported: true, 109 native_shared_libs: ["sdkmember"], 110 compile_multilib: "64", 111 } 112 113 cc_library_shared { 114 name: "sdkmember", 115 host_supported: true, 116 srcs: ["Test.cpp"], 117 stl: "none", 118 compile_multilib: "64", 119 } 120 `) 121 122 CheckSnapshot(t, result, "mysdk", "", 123 checkAndroidBpContents(` 124// This is auto-generated. DO NOT EDIT. 125 126cc_prebuilt_library_shared { 127 name: "sdkmember", 128 prefer: false, 129 visibility: ["//visibility:public"], 130 apex_available: ["//apex_available:platform"], 131 host_supported: true, 132 stl: "none", 133 compile_multilib: "64", 134 target: { 135 host: { 136 enabled: false, 137 }, 138 android_arm64: { 139 srcs: ["android/arm64/lib/sdkmember.so"], 140 }, 141 linux_glibc_x86_64: { 142 enabled: true, 143 srcs: ["linux_glibc/x86_64/lib/sdkmember.so"], 144 }, 145 }, 146} 147`), 148 checkAllCopyRules(` 149.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so 150.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so 151`)) 152} 153 154// Make sure the sdk can use host specific cc libraries static/shared and both. 155func TestHostSdkWithCc(t *testing.T) { 156 testSdkWithCc(t, ` 157 sdk { 158 name: "mysdk", 159 device_supported: false, 160 host_supported: true, 161 native_shared_libs: ["sdkshared"], 162 native_static_libs: ["sdkstatic"], 163 } 164 165 cc_library_host_shared { 166 name: "sdkshared", 167 stl: "none", 168 } 169 170 cc_library_host_static { 171 name: "sdkstatic", 172 stl: "none", 173 } 174 `) 175} 176 177// Make sure the sdk can use cc libraries static/shared and both. 178func TestSdkWithCc(t *testing.T) { 179 testSdkWithCc(t, ` 180 sdk { 181 name: "mysdk", 182 native_shared_libs: ["sdkshared", "sdkboth1"], 183 native_static_libs: ["sdkstatic", "sdkboth2"], 184 } 185 186 cc_library_shared { 187 name: "sdkshared", 188 stl: "none", 189 } 190 191 cc_library_static { 192 name: "sdkstatic", 193 stl: "none", 194 } 195 196 cc_library { 197 name: "sdkboth1", 198 stl: "none", 199 } 200 201 cc_library { 202 name: "sdkboth2", 203 stl: "none", 204 } 205 `) 206} 207 208func TestSnapshotWithObject(t *testing.T) { 209 result := testSdkWithCc(t, ` 210 sdk { 211 name: "mysdk", 212 native_objects: ["crtobj"], 213 } 214 215 cc_object { 216 name: "crtobj", 217 stl: "none", 218 system_shared_libs: [], 219 sanitize: { 220 never: true, 221 }, 222 } 223 `) 224 225 CheckSnapshot(t, result, "mysdk", "", 226 checkAndroidBpContents(` 227// This is auto-generated. DO NOT EDIT. 228 229cc_prebuilt_object { 230 name: "crtobj", 231 prefer: false, 232 visibility: ["//visibility:public"], 233 apex_available: ["//apex_available:platform"], 234 stl: "none", 235 compile_multilib: "both", 236 system_shared_libs: [], 237 sanitize: { 238 never: true, 239 }, 240 arch: { 241 arm64: { 242 srcs: ["arm64/lib/crtobj.o"], 243 }, 244 arm: { 245 srcs: ["arm/lib/crtobj.o"], 246 }, 247 }, 248} 249`), 250 checkAllCopyRules(` 251.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o 252.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o 253`), 254 ) 255} 256 257func TestSnapshotWithCcDuplicateHeaders(t *testing.T) { 258 result := testSdkWithCc(t, ` 259 sdk { 260 name: "mysdk", 261 native_shared_libs: ["mynativelib1", "mynativelib2"], 262 } 263 264 cc_library_shared { 265 name: "mynativelib1", 266 srcs: [ 267 "Test.cpp", 268 ], 269 export_include_dirs: ["myinclude"], 270 stl: "none", 271 } 272 273 cc_library_shared { 274 name: "mynativelib2", 275 srcs: [ 276 "Test.cpp", 277 ], 278 export_include_dirs: ["myinclude"], 279 stl: "none", 280 } 281 `) 282 283 CheckSnapshot(t, result, "mysdk", "", 284 checkAllCopyRules(` 285myinclude/Test.h -> include/myinclude/Test.h 286.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so 287.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so 288.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so 289.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so 290`), 291 ) 292} 293 294func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) { 295 result := testSdkWithCc(t, ` 296 sdk { 297 name: "mysdk", 298 native_shared_libs: ["mynativelib"], 299 } 300 301 cc_library_shared { 302 name: "mynativelib", 303 srcs: [ 304 "Test.cpp", 305 ], 306 generated_headers: [ 307 "generated_foo", 308 ], 309 export_generated_headers: [ 310 "generated_foo", 311 ], 312 export_include_dirs: ["myinclude"], 313 stl: "none", 314 } 315 316 genrule { 317 name: "generated_foo", 318 cmd: "generate-foo", 319 out: [ 320 "generated_foo/protos/foo/bar.h", 321 ], 322 export_include_dirs: [ 323 ".", 324 "protos", 325 ], 326 } 327 `) 328 329 // TODO(b/183322862): Remove this and fix the issue. 330 errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`) 331 332 CheckSnapshot(t, result, "mysdk", "", 333 checkAndroidBpContents(` 334// This is auto-generated. DO NOT EDIT. 335 336cc_prebuilt_library_shared { 337 name: "mynativelib", 338 prefer: false, 339 visibility: ["//visibility:public"], 340 apex_available: ["//apex_available:platform"], 341 stl: "none", 342 compile_multilib: "both", 343 export_include_dirs: [ 344 "include/myinclude", 345 "include_gen/generated_foo/gen", 346 "include_gen/generated_foo/gen/protos", 347 ], 348 arch: { 349 arm64: { 350 srcs: ["arm64/lib/mynativelib.so"], 351 }, 352 arm: { 353 srcs: ["arm/lib/mynativelib.so"], 354 }, 355 }, 356} 357`), 358 checkAllCopyRules(` 359myinclude/Test.h -> include/myinclude/Test.h 360.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h 361.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so 362.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so 363`), 364 snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler), 365 snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler), 366 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler), 367 ) 368} 369 370// Verify that when the shared library has some common and some arch specific 371// properties that the generated snapshot is optimized properly. Substruct 372// handling is tested with the sanitize clauses (but note there's a lot of 373// built-in logic in sanitize.go that can affect those flags). 374func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) { 375 result := testSdkWithCc(t, ` 376 sdk { 377 name: "mysdk", 378 native_shared_libs: ["mynativelib"], 379 } 380 381 cc_library_shared { 382 name: "mynativelib", 383 srcs: [ 384 "Test.cpp", 385 "aidl/foo/bar/Test.aidl", 386 ], 387 export_include_dirs: ["myinclude"], 388 sanitize: { 389 fuzzer: false, 390 integer_overflow: true, 391 diag: { undefined: false }, 392 }, 393 arch: { 394 arm64: { 395 export_system_include_dirs: ["arm64/include"], 396 sanitize: { 397 integer_overflow: false, 398 }, 399 }, 400 }, 401 stl: "none", 402 } 403 `) 404 405 CheckSnapshot(t, result, "mysdk", "", 406 checkAndroidBpContents(` 407// This is auto-generated. DO NOT EDIT. 408 409cc_prebuilt_library_shared { 410 name: "mynativelib", 411 prefer: false, 412 visibility: ["//visibility:public"], 413 apex_available: ["//apex_available:platform"], 414 stl: "none", 415 compile_multilib: "both", 416 export_include_dirs: ["include/myinclude"], 417 sanitize: { 418 fuzzer: false, 419 diag: { 420 undefined: false, 421 }, 422 }, 423 arch: { 424 arm64: { 425 srcs: ["arm64/lib/mynativelib.so"], 426 export_system_include_dirs: ["arm64/include/arm64/include"], 427 sanitize: { 428 integer_overflow: false, 429 }, 430 }, 431 arm: { 432 srcs: ["arm/lib/mynativelib.so"], 433 sanitize: { 434 integer_overflow: true, 435 }, 436 }, 437 }, 438} 439`), 440 checkAllCopyRules(` 441myinclude/Test.h -> include/myinclude/Test.h 442.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so 443arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h 444.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`), 445 ) 446} 447 448func TestSnapshotWithCcBinary(t *testing.T) { 449 result := testSdkWithCc(t, ` 450 module_exports { 451 name: "mymodule_exports", 452 native_binaries: ["mynativebinary"], 453 } 454 455 cc_binary { 456 name: "mynativebinary", 457 srcs: [ 458 "Test.cpp", 459 ], 460 compile_multilib: "both", 461 } 462 `) 463 464 CheckSnapshot(t, result, "mymodule_exports", "", 465 checkAndroidBpContents(` 466// This is auto-generated. DO NOT EDIT. 467 468cc_prebuilt_binary { 469 name: "mynativebinary", 470 prefer: false, 471 visibility: ["//visibility:public"], 472 apex_available: ["//apex_available:platform"], 473 compile_multilib: "both", 474 arch: { 475 arm64: { 476 srcs: ["arm64/bin/mynativebinary"], 477 }, 478 arm: { 479 srcs: ["arm/bin/mynativebinary"], 480 }, 481 }, 482} 483`), 484 checkAllCopyRules(` 485.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary 486.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary 487`), 488 ) 489} 490 491func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) { 492 result := testSdkWithCc(t, ` 493 module_exports { 494 name: "myexports", 495 device_supported: false, 496 host_supported: true, 497 native_binaries: ["mynativebinary"], 498 target: { 499 windows: { 500 enabled: true, 501 }, 502 }, 503 } 504 505 cc_binary { 506 name: "mynativebinary", 507 device_supported: false, 508 host_supported: true, 509 srcs: [ 510 "Test.cpp", 511 ], 512 compile_multilib: "both", 513 stl: "none", 514 target: { 515 windows: { 516 enabled: true, 517 }, 518 }, 519 } 520 `) 521 522 CheckSnapshot(t, result, "myexports", "", 523 checkAndroidBpContents(` 524// This is auto-generated. DO NOT EDIT. 525 526cc_prebuilt_binary { 527 name: "mynativebinary", 528 prefer: false, 529 visibility: ["//visibility:public"], 530 apex_available: ["//apex_available:platform"], 531 device_supported: false, 532 host_supported: true, 533 stl: "none", 534 target: { 535 host: { 536 enabled: false, 537 }, 538 linux_glibc: { 539 compile_multilib: "both", 540 }, 541 linux_glibc_x86_64: { 542 enabled: true, 543 srcs: ["linux_glibc/x86_64/bin/mynativebinary"], 544 }, 545 linux_glibc_x86: { 546 enabled: true, 547 srcs: ["linux_glibc/x86/bin/mynativebinary"], 548 }, 549 windows: { 550 compile_multilib: "64", 551 }, 552 windows_x86_64: { 553 enabled: true, 554 srcs: ["windows/x86_64/bin/mynativebinary.exe"], 555 }, 556 }, 557} 558`), 559 checkAllCopyRules(` 560.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary 561.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary 562.intermediates/mynativebinary/windows_x86_64/mynativebinary.exe -> windows/x86_64/bin/mynativebinary.exe 563`), 564 ) 565} 566 567func TestSnapshotWithSingleHostOsType(t *testing.T) { 568 result := android.GroupFixturePreparers( 569 prepareForSdkTest, 570 ccTestFs.AddToFixture(), 571 cc.PrepareForTestOnLinuxBionic, 572 android.FixtureModifyConfig(func(config android.Config) { 573 config.Targets[android.LinuxBionic] = []android.Target{ 574 {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false}, 575 } 576 }), 577 ).RunTestWithBp(t, ` 578 cc_defaults { 579 name: "mydefaults", 580 device_supported: false, 581 host_supported: true, 582 compile_multilib: "64", 583 target: { 584 host: { 585 enabled: false, 586 }, 587 linux_bionic: { 588 enabled: true, 589 }, 590 }, 591 } 592 593 module_exports { 594 name: "myexports", 595 defaults: ["mydefaults"], 596 native_shared_libs: ["mynativelib"], 597 native_binaries: ["mynativebinary"], 598 compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults. 599 } 600 601 cc_library { 602 name: "mynativelib", 603 defaults: ["mydefaults"], 604 srcs: [ 605 "Test.cpp", 606 ], 607 stl: "none", 608 } 609 610 cc_binary { 611 name: "mynativebinary", 612 defaults: ["mydefaults"], 613 srcs: [ 614 "Test.cpp", 615 ], 616 stl: "none", 617 } 618 `) 619 620 CheckSnapshot(t, result, "myexports", "", 621 checkAndroidBpContents(` 622// This is auto-generated. DO NOT EDIT. 623 624cc_prebuilt_binary { 625 name: "mynativebinary", 626 prefer: false, 627 visibility: ["//visibility:public"], 628 apex_available: ["//apex_available:platform"], 629 device_supported: false, 630 host_supported: true, 631 stl: "none", 632 compile_multilib: "64", 633 target: { 634 host: { 635 enabled: false, 636 }, 637 linux_bionic_x86_64: { 638 enabled: true, 639 srcs: ["x86_64/bin/mynativebinary"], 640 }, 641 }, 642} 643 644cc_prebuilt_library_shared { 645 name: "mynativelib", 646 prefer: false, 647 visibility: ["//visibility:public"], 648 apex_available: ["//apex_available:platform"], 649 device_supported: false, 650 host_supported: true, 651 stl: "none", 652 compile_multilib: "64", 653 target: { 654 host: { 655 enabled: false, 656 }, 657 linux_bionic_x86_64: { 658 enabled: true, 659 srcs: ["x86_64/lib/mynativelib.so"], 660 }, 661 }, 662} 663`), 664 checkAllCopyRules(` 665.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary 666.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so 667`), 668 ) 669} 670 671// Test that we support the necessary flags for the linker binary, which is 672// special in several ways. 673func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) { 674 result := testSdkWithCc(t, ` 675 module_exports { 676 name: "mymodule_exports", 677 host_supported: true, 678 device_supported: false, 679 native_binaries: ["linker"], 680 } 681 682 cc_binary { 683 name: "linker", 684 host_supported: true, 685 static_executable: true, 686 nocrt: true, 687 stl: "none", 688 srcs: [ 689 "Test.cpp", 690 ], 691 compile_multilib: "both", 692 } 693 `) 694 695 CheckSnapshot(t, result, "mymodule_exports", "", 696 checkAndroidBpContents(` 697// This is auto-generated. DO NOT EDIT. 698 699cc_prebuilt_binary { 700 name: "linker", 701 prefer: false, 702 visibility: ["//visibility:public"], 703 apex_available: ["//apex_available:platform"], 704 device_supported: false, 705 host_supported: true, 706 stl: "none", 707 compile_multilib: "both", 708 static_executable: true, 709 nocrt: true, 710 target: { 711 host: { 712 enabled: false, 713 }, 714 linux_glibc_x86_64: { 715 enabled: true, 716 srcs: ["x86_64/bin/linker"], 717 }, 718 linux_glibc_x86: { 719 enabled: true, 720 srcs: ["x86/bin/linker"], 721 }, 722 }, 723} 724`), 725 checkAllCopyRules(` 726.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker 727.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker 728`), 729 ) 730} 731 732func TestSnapshotWithCcSharedLibrary(t *testing.T) { 733 result := testSdkWithCc(t, ` 734 sdk { 735 name: "mysdk", 736 native_shared_libs: ["mynativelib"], 737 } 738 739 cc_library_shared { 740 name: "mynativelib", 741 srcs: [ 742 "Test.cpp", 743 "aidl/foo/bar/Test.aidl", 744 ], 745 apex_available: ["apex1", "apex2"], 746 export_include_dirs: ["myinclude"], 747 aidl: { 748 export_aidl_headers: true, 749 }, 750 stl: "none", 751 } 752 `) 753 754 CheckSnapshot(t, result, "mysdk", "", 755 checkAndroidBpContents(` 756// This is auto-generated. DO NOT EDIT. 757 758cc_prebuilt_library_shared { 759 name: "mynativelib", 760 prefer: false, 761 visibility: ["//visibility:public"], 762 apex_available: [ 763 "apex1", 764 "apex2", 765 ], 766 stl: "none", 767 compile_multilib: "both", 768 export_include_dirs: ["include/myinclude"], 769 arch: { 770 arm64: { 771 srcs: ["arm64/lib/mynativelib.so"], 772 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"], 773 }, 774 arm: { 775 srcs: ["arm/lib/mynativelib.so"], 776 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"], 777 }, 778 }, 779} 780`), 781 checkAllCopyRules(` 782myinclude/Test.h -> include/myinclude/Test.h 783.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so 784.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h 785.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h 786.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h 787.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so 788.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h 789.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h 790.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h 791`), 792 ) 793} 794 795func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) { 796 result := testSdkWithCc(t, ` 797 sdk { 798 name: "mysdk", 799 native_shared_libs: [ 800 "mynativelib", 801 "myothernativelib", 802 "mysystemnativelib", 803 ], 804 } 805 806 cc_library { 807 name: "mysystemnativelib", 808 srcs: [ 809 "Test.cpp", 810 ], 811 stl: "none", 812 } 813 814 cc_library_shared { 815 name: "myothernativelib", 816 srcs: [ 817 "Test.cpp", 818 ], 819 system_shared_libs: [ 820 // A reference to a library that is not an sdk member. Uses libm as that 821 // is in the default set of modules available to this test and so is available 822 // both here and also when the generated Android.bp file is tested in 823 // CheckSnapshot(). This ensures that the system_shared_libs property correctly 824 // handles references to modules that are not sdk members. 825 "libm", 826 ], 827 stl: "none", 828 } 829 830 cc_library { 831 name: "mynativelib", 832 srcs: [ 833 "Test.cpp", 834 ], 835 shared_libs: [ 836 // A reference to another sdk member. 837 "myothernativelib", 838 ], 839 target: { 840 android: { 841 shared: { 842 shared_libs: [ 843 // A reference to a library that is not an sdk member. The libc library 844 // is used here to check that the shared_libs property is handled correctly 845 // in a similar way to how libm is used to check system_shared_libs above. 846 "libc", 847 ], 848 }, 849 }, 850 }, 851 stl: "none", 852 } 853 `) 854 855 CheckSnapshot(t, result, "mysdk", "", 856 checkAndroidBpContents(` 857// This is auto-generated. DO NOT EDIT. 858 859cc_prebuilt_library_shared { 860 name: "mynativelib", 861 prefer: false, 862 visibility: ["//visibility:public"], 863 apex_available: ["//apex_available:platform"], 864 stl: "none", 865 compile_multilib: "both", 866 shared_libs: [ 867 "myothernativelib", 868 "libc", 869 ], 870 arch: { 871 arm64: { 872 srcs: ["arm64/lib/mynativelib.so"], 873 }, 874 arm: { 875 srcs: ["arm/lib/mynativelib.so"], 876 }, 877 }, 878} 879 880cc_prebuilt_library_shared { 881 name: "myothernativelib", 882 prefer: false, 883 visibility: ["//visibility:public"], 884 apex_available: ["//apex_available:platform"], 885 stl: "none", 886 compile_multilib: "both", 887 system_shared_libs: ["libm"], 888 arch: { 889 arm64: { 890 srcs: ["arm64/lib/myothernativelib.so"], 891 }, 892 arm: { 893 srcs: ["arm/lib/myothernativelib.so"], 894 }, 895 }, 896} 897 898cc_prebuilt_library_shared { 899 name: "mysystemnativelib", 900 prefer: false, 901 visibility: ["//visibility:public"], 902 apex_available: ["//apex_available:platform"], 903 stl: "none", 904 compile_multilib: "both", 905 arch: { 906 arm64: { 907 srcs: ["arm64/lib/mysystemnativelib.so"], 908 }, 909 arm: { 910 srcs: ["arm/lib/mysystemnativelib.so"], 911 }, 912 }, 913} 914`), 915 checkAllCopyRules(` 916.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so 917.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so 918.intermediates/myothernativelib/android_arm64_armv8-a_shared/myothernativelib.so -> arm64/lib/myothernativelib.so 919.intermediates/myothernativelib/android_arm_armv7-a-neon_shared/myothernativelib.so -> arm/lib/myothernativelib.so 920.intermediates/mysystemnativelib/android_arm64_armv8-a_shared/mysystemnativelib.so -> arm64/lib/mysystemnativelib.so 921.intermediates/mysystemnativelib/android_arm_armv7-a-neon_shared/mysystemnativelib.so -> arm/lib/mysystemnativelib.so 922`), 923 ) 924} 925 926func TestHostSnapshotWithCcSharedLibrary(t *testing.T) { 927 result := testSdkWithCc(t, ` 928 sdk { 929 name: "mysdk", 930 device_supported: false, 931 host_supported: true, 932 native_shared_libs: ["mynativelib"], 933 } 934 935 cc_library_shared { 936 name: "mynativelib", 937 device_supported: false, 938 host_supported: true, 939 srcs: [ 940 "Test.cpp", 941 "aidl/foo/bar/Test.aidl", 942 ], 943 export_include_dirs: ["myinclude"], 944 aidl: { 945 export_aidl_headers: true, 946 }, 947 stl: "none", 948 sdk_version: "minimum", 949 } 950 `) 951 952 CheckSnapshot(t, result, "mysdk", "", 953 checkAndroidBpContents(` 954// This is auto-generated. DO NOT EDIT. 955 956cc_prebuilt_library_shared { 957 name: "mynativelib", 958 prefer: false, 959 visibility: ["//visibility:public"], 960 apex_available: ["//apex_available:platform"], 961 device_supported: false, 962 host_supported: true, 963 sdk_version: "minimum", 964 stl: "none", 965 compile_multilib: "both", 966 export_include_dirs: ["include/myinclude"], 967 target: { 968 host: { 969 enabled: false, 970 }, 971 linux_glibc_x86_64: { 972 enabled: true, 973 srcs: ["x86_64/lib/mynativelib.so"], 974 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"], 975 }, 976 linux_glibc_x86: { 977 enabled: true, 978 srcs: ["x86/lib/mynativelib.so"], 979 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"], 980 }, 981 }, 982} 983`), 984 checkAllCopyRules(` 985myinclude/Test.h -> include/myinclude/Test.h 986.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so 987.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h 988.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h 989.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h 990.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so 991.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h 992.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h 993.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h 994`), 995 ) 996} 997 998func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) { 999 result := testSdkWithCc(t, ` 1000 sdk { 1001 name: "mysdk", 1002 device_supported: false, 1003 host_supported: true, 1004 native_shared_libs: ["mynativelib"], 1005 target: { 1006 windows: { 1007 enabled: true, 1008 }, 1009 }, 1010 } 1011 1012 cc_library_shared { 1013 name: "mynativelib", 1014 device_supported: false, 1015 host_supported: true, 1016 srcs: [ 1017 "Test.cpp", 1018 ], 1019 stl: "none", 1020 target: { 1021 windows: { 1022 enabled: true, 1023 }, 1024 }, 1025 } 1026 `) 1027 1028 CheckSnapshot(t, result, "mysdk", "", 1029 checkAndroidBpContents(` 1030// This is auto-generated. DO NOT EDIT. 1031 1032cc_prebuilt_library_shared { 1033 name: "mynativelib", 1034 prefer: false, 1035 visibility: ["//visibility:public"], 1036 apex_available: ["//apex_available:platform"], 1037 device_supported: false, 1038 host_supported: true, 1039 stl: "none", 1040 target: { 1041 host: { 1042 enabled: false, 1043 }, 1044 linux_glibc: { 1045 compile_multilib: "both", 1046 }, 1047 linux_glibc_x86_64: { 1048 enabled: true, 1049 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], 1050 }, 1051 linux_glibc_x86: { 1052 enabled: true, 1053 srcs: ["linux_glibc/x86/lib/mynativelib.so"], 1054 }, 1055 windows: { 1056 compile_multilib: "64", 1057 }, 1058 windows_x86_64: { 1059 enabled: true, 1060 srcs: ["windows/x86_64/lib/mynativelib.dll"], 1061 }, 1062 }, 1063} 1064`), 1065 checkAllCopyRules(` 1066.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so 1067.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so 1068.intermediates/mynativelib/windows_x86_64_shared/mynativelib.dll -> windows/x86_64/lib/mynativelib.dll 1069`), 1070 ) 1071} 1072 1073func TestSnapshotWithCcStaticLibrary(t *testing.T) { 1074 result := testSdkWithCc(t, ` 1075 module_exports { 1076 name: "myexports", 1077 native_static_libs: ["mynativelib"], 1078 } 1079 1080 cc_library_static { 1081 name: "mynativelib", 1082 srcs: [ 1083 "Test.cpp", 1084 "aidl/foo/bar/Test.aidl", 1085 ], 1086 export_include_dirs: ["myinclude"], 1087 aidl: { 1088 export_aidl_headers: true, 1089 }, 1090 stl: "none", 1091 } 1092 `) 1093 1094 CheckSnapshot(t, result, "myexports", "", 1095 checkAndroidBpContents(` 1096// This is auto-generated. DO NOT EDIT. 1097 1098cc_prebuilt_library_static { 1099 name: "mynativelib", 1100 prefer: false, 1101 visibility: ["//visibility:public"], 1102 apex_available: ["//apex_available:platform"], 1103 stl: "none", 1104 compile_multilib: "both", 1105 export_include_dirs: ["include/myinclude"], 1106 arch: { 1107 arm64: { 1108 srcs: ["arm64/lib/mynativelib.a"], 1109 export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"], 1110 }, 1111 arm: { 1112 srcs: ["arm/lib/mynativelib.a"], 1113 export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"], 1114 }, 1115 }, 1116} 1117`), 1118 checkAllCopyRules(` 1119myinclude/Test.h -> include/myinclude/Test.h 1120.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a 1121.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h 1122.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h 1123.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h 1124.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a 1125.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h 1126.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h 1127.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h 1128`), 1129 ) 1130} 1131 1132func TestHostSnapshotWithCcStaticLibrary(t *testing.T) { 1133 result := testSdkWithCc(t, ` 1134 module_exports { 1135 name: "myexports", 1136 device_supported: false, 1137 host_supported: true, 1138 native_static_libs: ["mynativelib"], 1139 } 1140 1141 cc_library_static { 1142 name: "mynativelib", 1143 device_supported: false, 1144 host_supported: true, 1145 srcs: [ 1146 "Test.cpp", 1147 "aidl/foo/bar/Test.aidl", 1148 ], 1149 export_include_dirs: ["myinclude"], 1150 aidl: { 1151 export_aidl_headers: true, 1152 }, 1153 stl: "none", 1154 } 1155 `) 1156 1157 CheckSnapshot(t, result, "myexports", "", 1158 checkAndroidBpContents(` 1159// This is auto-generated. DO NOT EDIT. 1160 1161cc_prebuilt_library_static { 1162 name: "mynativelib", 1163 prefer: false, 1164 visibility: ["//visibility:public"], 1165 apex_available: ["//apex_available:platform"], 1166 device_supported: false, 1167 host_supported: true, 1168 stl: "none", 1169 compile_multilib: "both", 1170 export_include_dirs: ["include/myinclude"], 1171 target: { 1172 host: { 1173 enabled: false, 1174 }, 1175 linux_glibc_x86_64: { 1176 enabled: true, 1177 srcs: ["x86_64/lib/mynativelib.a"], 1178 export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"], 1179 }, 1180 linux_glibc_x86: { 1181 enabled: true, 1182 srcs: ["x86/lib/mynativelib.a"], 1183 export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"], 1184 }, 1185 }, 1186} 1187`), 1188 checkAllCopyRules(` 1189myinclude/Test.h -> include/myinclude/Test.h 1190.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a 1191.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h 1192.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h 1193.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h 1194.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a 1195.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h 1196.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h 1197.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h 1198`), 1199 ) 1200} 1201 1202func TestSnapshotWithCcLibrary(t *testing.T) { 1203 result := testSdkWithCc(t, ` 1204 module_exports { 1205 name: "myexports", 1206 native_libs: ["mynativelib"], 1207 } 1208 1209 cc_library { 1210 name: "mynativelib", 1211 srcs: [ 1212 "Test.cpp", 1213 ], 1214 export_include_dirs: ["myinclude"], 1215 stl: "none", 1216 recovery_available: true, 1217 vendor_available: true, 1218 } 1219 `) 1220 1221 CheckSnapshot(t, result, "myexports", "", 1222 checkAndroidBpContents(` 1223// This is auto-generated. DO NOT EDIT. 1224 1225cc_prebuilt_library { 1226 name: "mynativelib", 1227 prefer: false, 1228 visibility: ["//visibility:public"], 1229 apex_available: ["//apex_available:platform"], 1230 vendor_available: true, 1231 stl: "none", 1232 compile_multilib: "both", 1233 export_include_dirs: ["include/myinclude"], 1234 arch: { 1235 arm64: { 1236 static: { 1237 srcs: ["arm64/lib/mynativelib.a"], 1238 }, 1239 shared: { 1240 srcs: ["arm64/lib/mynativelib.so"], 1241 }, 1242 }, 1243 arm: { 1244 static: { 1245 srcs: ["arm/lib/mynativelib.a"], 1246 }, 1247 shared: { 1248 srcs: ["arm/lib/mynativelib.so"], 1249 }, 1250 }, 1251 }, 1252} 1253`), 1254 checkAllCopyRules(` 1255myinclude/Test.h -> include/myinclude/Test.h 1256.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a 1257.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so 1258.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a 1259.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so 1260`), 1261 // TODO(b/183315522): Remove this and fix the issue. 1262 snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)), 1263 ) 1264} 1265 1266func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) { 1267 result := testSdkWithCc(t, ` 1268 module_exports { 1269 host_supported: true, 1270 name: "myexports", 1271 target: { 1272 android: { 1273 native_shared_libs: [ 1274 "mynativelib", 1275 ], 1276 }, 1277 not_windows: { 1278 native_libs: [ 1279 "mynativelib", 1280 ], 1281 }, 1282 }, 1283 } 1284 1285 cc_library { 1286 name: "mynativelib", 1287 host_supported: true, 1288 srcs: [ 1289 "Test.cpp", 1290 ], 1291 stl: "none", 1292 recovery_available: true, 1293 vendor_available: true, 1294 } 1295 `) 1296 1297 CheckSnapshot(t, result, "myexports", "", 1298 checkAndroidBpContents(` 1299// This is auto-generated. DO NOT EDIT. 1300 1301cc_prebuilt_library { 1302 name: "mynativelib", 1303 prefer: false, 1304 visibility: ["//visibility:public"], 1305 apex_available: ["//apex_available:platform"], 1306 host_supported: true, 1307 vendor_available: true, 1308 stl: "none", 1309 compile_multilib: "both", 1310 target: { 1311 host: { 1312 enabled: false, 1313 }, 1314 android_arm64: { 1315 shared: { 1316 srcs: ["android/arm64/lib/mynativelib.so"], 1317 }, 1318 static: { 1319 enabled: false, 1320 }, 1321 }, 1322 android_arm: { 1323 shared: { 1324 srcs: ["android/arm/lib/mynativelib.so"], 1325 }, 1326 static: { 1327 enabled: false, 1328 }, 1329 }, 1330 linux_glibc_x86_64: { 1331 enabled: true, 1332 static: { 1333 srcs: ["linux_glibc/x86_64/lib/mynativelib.a"], 1334 }, 1335 shared: { 1336 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], 1337 }, 1338 }, 1339 linux_glibc_x86: { 1340 enabled: true, 1341 static: { 1342 srcs: ["linux_glibc/x86/lib/mynativelib.a"], 1343 }, 1344 shared: { 1345 srcs: ["linux_glibc/x86/lib/mynativelib.so"], 1346 }, 1347 }, 1348 }, 1349} 1350`), 1351 checkAllCopyRules(` 1352.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so 1353.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so 1354.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> linux_glibc/x86_64/lib/mynativelib.a 1355.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so 1356.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> linux_glibc/x86/lib/mynativelib.a 1357.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so 1358`), 1359 ) 1360} 1361 1362func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) { 1363 result := testSdkWithCc(t, ` 1364 module_exports { 1365 host_supported: true, 1366 name: "myexports", 1367 target: { 1368 android: { 1369 native_libs: [ 1370 "mynativelib", 1371 ], 1372 }, 1373 not_windows: { 1374 native_shared_libs: [ 1375 "mynativelib", 1376 ], 1377 }, 1378 }, 1379 } 1380 1381 cc_library { 1382 name: "mynativelib", 1383 host_supported: true, 1384 srcs: [ 1385 "Test.cpp", 1386 ], 1387 stl: "none", 1388 recovery_available: true, 1389 vendor_available: true, 1390 } 1391 `) 1392 1393 CheckSnapshot(t, result, "myexports", "", 1394 checkAndroidBpContents(` 1395// This is auto-generated. DO NOT EDIT. 1396 1397cc_prebuilt_library { 1398 name: "mynativelib", 1399 prefer: false, 1400 visibility: ["//visibility:public"], 1401 apex_available: ["//apex_available:platform"], 1402 host_supported: true, 1403 vendor_available: true, 1404 stl: "none", 1405 compile_multilib: "both", 1406 target: { 1407 host: { 1408 enabled: false, 1409 }, 1410 android_arm64: { 1411 static: { 1412 srcs: ["android/arm64/lib/mynativelib.a"], 1413 }, 1414 shared: { 1415 srcs: ["android/arm64/lib/mynativelib.so"], 1416 }, 1417 }, 1418 android_arm: { 1419 static: { 1420 srcs: ["android/arm/lib/mynativelib.a"], 1421 }, 1422 shared: { 1423 srcs: ["android/arm/lib/mynativelib.so"], 1424 }, 1425 }, 1426 linux_glibc_x86_64: { 1427 enabled: true, 1428 shared: { 1429 srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], 1430 }, 1431 static: { 1432 enabled: false, 1433 }, 1434 }, 1435 linux_glibc_x86: { 1436 enabled: true, 1437 shared: { 1438 srcs: ["linux_glibc/x86/lib/mynativelib.so"], 1439 }, 1440 static: { 1441 enabled: false, 1442 }, 1443 }, 1444 }, 1445} 1446`), 1447 checkAllCopyRules(` 1448.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> android/arm64/lib/mynativelib.a 1449.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so 1450.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> android/arm/lib/mynativelib.a 1451.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so 1452.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so 1453.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so 1454`), 1455 ) 1456} 1457 1458func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) { 1459 testSdkError(t, "Incompatible member types", ` 1460 module_exports { 1461 host_supported: true, 1462 name: "myexports", 1463 target: { 1464 android: { 1465 native_shared_libs: [ 1466 "mynativelib", 1467 ], 1468 }, 1469 not_windows: { 1470 native_static_libs: [ 1471 "mynativelib", 1472 ], 1473 }, 1474 }, 1475 } 1476 1477 cc_library { 1478 name: "mynativelib", 1479 host_supported: true, 1480 srcs: [ 1481 ], 1482 stl: "none", 1483 recovery_available: true, 1484 vendor_available: true, 1485 } 1486 `) 1487} 1488 1489func TestHostSnapshotWithMultiLib64(t *testing.T) { 1490 result := testSdkWithCc(t, ` 1491 module_exports { 1492 name: "myexports", 1493 device_supported: false, 1494 host_supported: true, 1495 target: { 1496 host: { 1497 compile_multilib: "64", 1498 }, 1499 }, 1500 native_static_libs: ["mynativelib"], 1501 } 1502 1503 cc_library_static { 1504 name: "mynativelib", 1505 device_supported: false, 1506 host_supported: true, 1507 srcs: [ 1508 "Test.cpp", 1509 "aidl/foo/bar/Test.aidl", 1510 ], 1511 export_include_dirs: ["myinclude"], 1512 aidl: { 1513 export_aidl_headers: true, 1514 }, 1515 stl: "none", 1516 } 1517 `) 1518 1519 CheckSnapshot(t, result, "myexports", "", 1520 checkAndroidBpContents(` 1521// This is auto-generated. DO NOT EDIT. 1522 1523cc_prebuilt_library_static { 1524 name: "mynativelib", 1525 prefer: false, 1526 visibility: ["//visibility:public"], 1527 apex_available: ["//apex_available:platform"], 1528 device_supported: false, 1529 host_supported: true, 1530 stl: "none", 1531 compile_multilib: "64", 1532 export_include_dirs: [ 1533 "include/myinclude", 1534 "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl", 1535 ], 1536 target: { 1537 host: { 1538 enabled: false, 1539 }, 1540 linux_glibc_x86_64: { 1541 enabled: true, 1542 srcs: ["x86_64/lib/mynativelib.a"], 1543 }, 1544 }, 1545} 1546`), 1547 checkAllCopyRules(` 1548myinclude/Test.h -> include/myinclude/Test.h 1549.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h 1550.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h 1551.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h 1552.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a 1553`), 1554 ) 1555} 1556 1557func TestSnapshotWithCcHeadersLibrary(t *testing.T) { 1558 result := testSdkWithCc(t, ` 1559 sdk { 1560 name: "mysdk", 1561 native_header_libs: ["mynativeheaders"], 1562 } 1563 1564 cc_library_headers { 1565 name: "mynativeheaders", 1566 export_include_dirs: ["myinclude"], 1567 stl: "none", 1568 } 1569 `) 1570 1571 CheckSnapshot(t, result, "mysdk", "", 1572 checkAndroidBpContents(` 1573// This is auto-generated. DO NOT EDIT. 1574 1575cc_prebuilt_library_headers { 1576 name: "mynativeheaders", 1577 prefer: false, 1578 visibility: ["//visibility:public"], 1579 apex_available: ["//apex_available:platform"], 1580 stl: "none", 1581 compile_multilib: "both", 1582 export_include_dirs: ["include/myinclude"], 1583} 1584`), 1585 checkAllCopyRules(` 1586myinclude/Test.h -> include/myinclude/Test.h 1587`), 1588 ) 1589} 1590 1591func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) { 1592 result := android.GroupFixturePreparers( 1593 cc.PrepareForTestWithCcDefaultModules, 1594 PrepareForTestWithSdkBuildComponents, 1595 ccTestFs.AddToFixture(), 1596 prepareForTestWithNativeBridgeTarget, 1597 ).RunTestWithBp(t, ` 1598 sdk { 1599 name: "mysdk", 1600 native_header_libs: ["mynativeheaders"], 1601 traits: { 1602 native_bridge_support: ["mynativeheaders"], 1603 }, 1604 } 1605 1606 cc_library_headers { 1607 name: "mynativeheaders", 1608 export_include_dirs: ["myinclude"], 1609 stl: "none", 1610 system_shared_libs: [], 1611 native_bridge_supported: true, 1612 } 1613 `) 1614 1615 CheckSnapshot(t, result, "mysdk", "", 1616 checkAndroidBpContents(` 1617// This is auto-generated. DO NOT EDIT. 1618 1619cc_prebuilt_library_headers { 1620 name: "mynativeheaders", 1621 prefer: false, 1622 visibility: ["//visibility:public"], 1623 apex_available: ["//apex_available:platform"], 1624 native_bridge_supported: true, 1625 stl: "none", 1626 compile_multilib: "both", 1627 system_shared_libs: [], 1628 export_include_dirs: ["include/myinclude"], 1629} 1630`), 1631 checkAllCopyRules(` 1632myinclude/Test.h -> include/myinclude/Test.h 1633`), 1634 ) 1635} 1636 1637// TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties verifies that when a 1638// module that has different output files for a native bridge target requests the native bridge 1639// variants are copied into the sdk snapshot that it reports an error. 1640func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) { 1641 android.GroupFixturePreparers( 1642 cc.PrepareForTestWithCcDefaultModules, 1643 PrepareForTestWithSdkBuildComponents, 1644 ccTestFs.AddToFixture(), 1645 prepareForTestWithNativeBridgeTarget, 1646 ).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( 1647 `\QArchitecture variant "arm64_native_bridge" of sdk member "mynativeheaders" has properties distinct from other variants; this is not yet supported. The properties are: 1648 export_include_dirs: [ 1649 "arm64_native_bridge/include/myinclude_nativebridge", 1650 "arm64_native_bridge/include/myinclude", 1651 ],\E`)). 1652 RunTestWithBp(t, ` 1653 sdk { 1654 name: "mysdk", 1655 native_header_libs: ["mynativeheaders"], 1656 traits: { 1657 native_bridge_support: ["mynativeheaders"], 1658 }, 1659 } 1660 1661 cc_library_headers { 1662 name: "mynativeheaders", 1663 export_include_dirs: ["myinclude"], 1664 stl: "none", 1665 system_shared_libs: [], 1666 native_bridge_supported: true, 1667 target: { 1668 native_bridge: { 1669 export_include_dirs: ["myinclude_nativebridge"], 1670 }, 1671 }, 1672 } 1673 `) 1674} 1675 1676func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) { 1677 testImageVariant := func(t *testing.T, property, trait string) { 1678 result := android.GroupFixturePreparers( 1679 cc.PrepareForTestWithCcDefaultModules, 1680 PrepareForTestWithSdkBuildComponents, 1681 ccTestFs.AddToFixture(), 1682 ).RunTestWithBp(t, fmt.Sprintf(` 1683 sdk { 1684 name: "mysdk", 1685 native_header_libs: ["mynativeheaders"], 1686 traits: { 1687 %s: ["mynativeheaders"], 1688 }, 1689 } 1690 1691 cc_library_headers { 1692 name: "mynativeheaders", 1693 export_include_dirs: ["myinclude"], 1694 stl: "none", 1695 system_shared_libs: [], 1696 %s: true, 1697 } 1698 `, trait, property)) 1699 1700 CheckSnapshot(t, result, "mysdk", "", 1701 checkAndroidBpContents(fmt.Sprintf(` 1702// This is auto-generated. DO NOT EDIT. 1703 1704cc_prebuilt_library_headers { 1705 name: "mynativeheaders", 1706 prefer: false, 1707 visibility: ["//visibility:public"], 1708 apex_available: ["//apex_available:platform"], 1709 %s: true, 1710 stl: "none", 1711 compile_multilib: "both", 1712 system_shared_libs: [], 1713 export_include_dirs: ["include/myinclude"], 1714} 1715`, property)), 1716 checkAllCopyRules(` 1717myinclude/Test.h -> include/myinclude/Test.h 1718`), 1719 ) 1720 } 1721 1722 t.Run("ramdisk", func(t *testing.T) { 1723 testImageVariant(t, "ramdisk_available", "ramdisk_image_required") 1724 }) 1725 1726 t.Run("recovery", func(t *testing.T) { 1727 testImageVariant(t, "recovery_available", "recovery_image_required") 1728 }) 1729} 1730 1731func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { 1732 result := testSdkWithCc(t, ` 1733 sdk { 1734 name: "mysdk", 1735 device_supported: false, 1736 host_supported: true, 1737 native_header_libs: ["mynativeheaders"], 1738 } 1739 1740 cc_library_headers { 1741 name: "mynativeheaders", 1742 device_supported: false, 1743 host_supported: true, 1744 export_include_dirs: ["myinclude"], 1745 stl: "none", 1746 } 1747 `) 1748 1749 CheckSnapshot(t, result, "mysdk", "", 1750 checkAndroidBpContents(` 1751// This is auto-generated. DO NOT EDIT. 1752 1753cc_prebuilt_library_headers { 1754 name: "mynativeheaders", 1755 prefer: false, 1756 visibility: ["//visibility:public"], 1757 apex_available: ["//apex_available:platform"], 1758 device_supported: false, 1759 host_supported: true, 1760 stl: "none", 1761 compile_multilib: "both", 1762 export_include_dirs: ["include/myinclude"], 1763 target: { 1764 host: { 1765 enabled: false, 1766 }, 1767 linux_glibc_x86_64: { 1768 enabled: true, 1769 }, 1770 linux_glibc_x86: { 1771 enabled: true, 1772 }, 1773 }, 1774} 1775`), 1776 checkAllCopyRules(` 1777myinclude/Test.h -> include/myinclude/Test.h 1778`), 1779 ) 1780} 1781 1782func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) { 1783 result := testSdkWithCc(t, ` 1784 sdk { 1785 name: "mysdk", 1786 host_supported: true, 1787 native_header_libs: ["mynativeheaders"], 1788 } 1789 1790 cc_library_headers { 1791 name: "mynativeheaders", 1792 host_supported: true, 1793 stl: "none", 1794 export_system_include_dirs: ["myinclude"], 1795 target: { 1796 android: { 1797 export_include_dirs: ["myinclude-android"], 1798 }, 1799 host: { 1800 export_include_dirs: ["myinclude-host"], 1801 }, 1802 }, 1803 } 1804 `) 1805 1806 CheckSnapshot(t, result, "mysdk", "", 1807 checkAndroidBpContents(` 1808// This is auto-generated. DO NOT EDIT. 1809 1810cc_prebuilt_library_headers { 1811 name: "mynativeheaders", 1812 prefer: false, 1813 visibility: ["//visibility:public"], 1814 apex_available: ["//apex_available:platform"], 1815 host_supported: true, 1816 stl: "none", 1817 compile_multilib: "both", 1818 export_system_include_dirs: ["common_os/include/myinclude"], 1819 target: { 1820 host: { 1821 enabled: false, 1822 }, 1823 android: { 1824 export_include_dirs: ["android/include/myinclude-android"], 1825 }, 1826 linux_glibc: { 1827 export_include_dirs: ["linux_glibc/include/myinclude-host"], 1828 }, 1829 linux_glibc_x86_64: { 1830 enabled: true, 1831 }, 1832 linux_glibc_x86: { 1833 enabled: true, 1834 }, 1835 }, 1836} 1837`), 1838 checkAllCopyRules(` 1839myinclude/Test.h -> common_os/include/myinclude/Test.h 1840myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h 1841myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h 1842`), 1843 ) 1844} 1845 1846func TestSystemSharedLibPropagation(t *testing.T) { 1847 result := testSdkWithCc(t, ` 1848 sdk { 1849 name: "mysdk", 1850 native_shared_libs: ["sslnil", "sslempty", "sslnonempty"], 1851 } 1852 1853 cc_library { 1854 name: "sslnil", 1855 host_supported: true, 1856 } 1857 1858 cc_library { 1859 name: "sslempty", 1860 system_shared_libs: [], 1861 } 1862 1863 cc_library { 1864 name: "sslnonempty", 1865 system_shared_libs: ["sslnil"], 1866 } 1867 `) 1868 1869 CheckSnapshot(t, result, "mysdk", "", 1870 checkAndroidBpContents(` 1871// This is auto-generated. DO NOT EDIT. 1872 1873cc_prebuilt_library_shared { 1874 name: "sslnil", 1875 prefer: false, 1876 visibility: ["//visibility:public"], 1877 apex_available: ["//apex_available:platform"], 1878 compile_multilib: "both", 1879 arch: { 1880 arm64: { 1881 srcs: ["arm64/lib/sslnil.so"], 1882 }, 1883 arm: { 1884 srcs: ["arm/lib/sslnil.so"], 1885 }, 1886 }, 1887} 1888 1889cc_prebuilt_library_shared { 1890 name: "sslempty", 1891 prefer: false, 1892 visibility: ["//visibility:public"], 1893 apex_available: ["//apex_available:platform"], 1894 compile_multilib: "both", 1895 system_shared_libs: [], 1896 arch: { 1897 arm64: { 1898 srcs: ["arm64/lib/sslempty.so"], 1899 }, 1900 arm: { 1901 srcs: ["arm/lib/sslempty.so"], 1902 }, 1903 }, 1904} 1905 1906cc_prebuilt_library_shared { 1907 name: "sslnonempty", 1908 prefer: false, 1909 visibility: ["//visibility:public"], 1910 apex_available: ["//apex_available:platform"], 1911 compile_multilib: "both", 1912 system_shared_libs: ["sslnil"], 1913 arch: { 1914 arm64: { 1915 srcs: ["arm64/lib/sslnonempty.so"], 1916 }, 1917 arm: { 1918 srcs: ["arm/lib/sslnonempty.so"], 1919 }, 1920 }, 1921} 1922`)) 1923 1924 result = testSdkWithCc(t, ` 1925 sdk { 1926 name: "mysdk", 1927 host_supported: true, 1928 native_shared_libs: ["sslvariants"], 1929 } 1930 1931 cc_library { 1932 name: "sslvariants", 1933 host_supported: true, 1934 target: { 1935 android: { 1936 system_shared_libs: [], 1937 }, 1938 }, 1939 } 1940 `) 1941 1942 CheckSnapshot(t, result, "mysdk", "", 1943 checkAndroidBpContents(` 1944// This is auto-generated. DO NOT EDIT. 1945 1946cc_prebuilt_library_shared { 1947 name: "sslvariants", 1948 prefer: false, 1949 visibility: ["//visibility:public"], 1950 apex_available: ["//apex_available:platform"], 1951 host_supported: true, 1952 compile_multilib: "both", 1953 target: { 1954 host: { 1955 enabled: false, 1956 }, 1957 android: { 1958 system_shared_libs: [], 1959 }, 1960 android_arm64: { 1961 srcs: ["android/arm64/lib/sslvariants.so"], 1962 }, 1963 android_arm: { 1964 srcs: ["android/arm/lib/sslvariants.so"], 1965 }, 1966 linux_glibc_x86_64: { 1967 enabled: true, 1968 srcs: ["linux_glibc/x86_64/lib/sslvariants.so"], 1969 }, 1970 linux_glibc_x86: { 1971 enabled: true, 1972 srcs: ["linux_glibc/x86/lib/sslvariants.so"], 1973 }, 1974 }, 1975} 1976`), 1977 ) 1978} 1979 1980func TestStubsLibrary(t *testing.T) { 1981 result := testSdkWithCc(t, ` 1982 sdk { 1983 name: "mysdk", 1984 native_shared_libs: ["stubslib"], 1985 } 1986 1987 cc_library { 1988 name: "internaldep", 1989 } 1990 1991 cc_library { 1992 name: "stubslib", 1993 shared_libs: ["internaldep"], 1994 stubs: { 1995 symbol_file: "some/where/stubslib.map.txt", 1996 versions: ["1", "2", "3"], 1997 }, 1998 } 1999 `) 2000 2001 CheckSnapshot(t, result, "mysdk", "", 2002 checkAndroidBpContents(` 2003// This is auto-generated. DO NOT EDIT. 2004 2005cc_prebuilt_library_shared { 2006 name: "stubslib", 2007 prefer: false, 2008 visibility: ["//visibility:public"], 2009 apex_available: ["//apex_available:platform"], 2010 compile_multilib: "both", 2011 stubs: { 2012 versions: [ 2013 "1", 2014 "2", 2015 "3", 2016 "current", 2017 ], 2018 }, 2019 arch: { 2020 arm64: { 2021 srcs: ["arm64/lib/stubslib.so"], 2022 }, 2023 arm: { 2024 srcs: ["arm/lib/stubslib.so"], 2025 }, 2026 }, 2027} 2028`)) 2029} 2030 2031func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) { 2032 result := testSdkWithCc(t, ` 2033 sdk { 2034 name: "mysdk", 2035 host_supported: true, 2036 native_shared_libs: ["stubslib"], 2037 } 2038 2039 cc_library { 2040 name: "internaldep", 2041 host_supported: true, 2042 } 2043 2044 cc_library { 2045 name: "stubslib", 2046 host_supported: true, 2047 shared_libs: ["internaldep"], 2048 stubs: { 2049 symbol_file: "some/where/stubslib.map.txt", 2050 versions: ["1", "2", "3"], 2051 }, 2052 } 2053 `) 2054 2055 CheckSnapshot(t, result, "mysdk", "", 2056 checkAndroidBpContents(` 2057// This is auto-generated. DO NOT EDIT. 2058 2059cc_prebuilt_library_shared { 2060 name: "stubslib", 2061 prefer: false, 2062 visibility: ["//visibility:public"], 2063 apex_available: ["//apex_available:platform"], 2064 host_supported: true, 2065 compile_multilib: "both", 2066 stubs: { 2067 versions: [ 2068 "1", 2069 "2", 2070 "3", 2071 "current", 2072 ], 2073 }, 2074 target: { 2075 host: { 2076 enabled: false, 2077 }, 2078 android_arm64: { 2079 srcs: ["android/arm64/lib/stubslib.so"], 2080 }, 2081 android_arm: { 2082 srcs: ["android/arm/lib/stubslib.so"], 2083 }, 2084 linux_glibc_x86_64: { 2085 enabled: true, 2086 srcs: ["linux_glibc/x86_64/lib/stubslib.so"], 2087 }, 2088 linux_glibc_x86: { 2089 enabled: true, 2090 srcs: ["linux_glibc/x86/lib/stubslib.so"], 2091 }, 2092 }, 2093} 2094`), 2095 ) 2096} 2097 2098func TestUniqueHostSoname(t *testing.T) { 2099 result := testSdkWithCc(t, ` 2100 sdk { 2101 name: "mysdk", 2102 host_supported: true, 2103 native_shared_libs: ["mylib"], 2104 } 2105 2106 cc_library { 2107 name: "mylib", 2108 host_supported: true, 2109 unique_host_soname: true, 2110 } 2111 `) 2112 2113 CheckSnapshot(t, result, "mysdk", "", 2114 checkAndroidBpContents(` 2115// This is auto-generated. DO NOT EDIT. 2116 2117cc_prebuilt_library_shared { 2118 name: "mylib", 2119 prefer: false, 2120 visibility: ["//visibility:public"], 2121 apex_available: ["//apex_available:platform"], 2122 host_supported: true, 2123 unique_host_soname: true, 2124 compile_multilib: "both", 2125 target: { 2126 host: { 2127 enabled: false, 2128 }, 2129 android_arm64: { 2130 srcs: ["android/arm64/lib/mylib.so"], 2131 }, 2132 android_arm: { 2133 srcs: ["android/arm/lib/mylib.so"], 2134 }, 2135 linux_glibc_x86_64: { 2136 enabled: true, 2137 srcs: ["linux_glibc/x86_64/lib/mylib-host.so"], 2138 }, 2139 linux_glibc_x86: { 2140 enabled: true, 2141 srcs: ["linux_glibc/x86/lib/mylib-host.so"], 2142 }, 2143 }, 2144} 2145`), 2146 checkAllCopyRules(` 2147.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so 2148.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so 2149.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so 2150.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so 2151`), 2152 ) 2153} 2154 2155func TestNoSanitizerMembers(t *testing.T) { 2156 result := testSdkWithCc(t, ` 2157 sdk { 2158 name: "mysdk", 2159 native_shared_libs: ["mynativelib"], 2160 } 2161 2162 cc_library_shared { 2163 name: "mynativelib", 2164 srcs: ["Test.cpp"], 2165 export_include_dirs: ["myinclude"], 2166 arch: { 2167 arm64: { 2168 export_system_include_dirs: ["arm64/include"], 2169 sanitize: { 2170 hwaddress: true, 2171 }, 2172 }, 2173 }, 2174 } 2175 `) 2176 2177 CheckSnapshot(t, result, "mysdk", "", 2178 checkAndroidBpContents(` 2179// This is auto-generated. DO NOT EDIT. 2180 2181cc_prebuilt_library_shared { 2182 name: "mynativelib", 2183 prefer: false, 2184 visibility: ["//visibility:public"], 2185 apex_available: ["//apex_available:platform"], 2186 compile_multilib: "both", 2187 export_include_dirs: ["include/myinclude"], 2188 arch: { 2189 arm64: { 2190 export_system_include_dirs: ["arm64/include/arm64/include"], 2191 }, 2192 arm: { 2193 srcs: ["arm/lib/mynativelib.so"], 2194 }, 2195 }, 2196} 2197`), 2198 checkAllCopyRules(` 2199myinclude/Test.h -> include/myinclude/Test.h 2200arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h 2201.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so 2202`), 2203 ) 2204} 2205