diff options
author | 2022-05-24 14:13:19 +0000 | |
---|---|---|
committer | 2022-05-24 14:13:19 +0000 | |
commit | 91f10eccc6a081800b24f8d7e5f8ad6ad14c4e40 (patch) | |
tree | 212aa469a575ecc7466a4c1706b4eccd41ad5170 /sdk/cc_sdk_test.go | |
parent | 40f9873612fe2b1ec122f0c147ae811ffa4d2574 (diff) | |
parent | 96320dfff8fd5859a5e5f2a5c74bf8d79dd6499d (diff) |
Merge "Handle multiple linkages in sdk snapshots"
Diffstat (limited to 'sdk/cc_sdk_test.go')
-rw-r--r-- | sdk/cc_sdk_test.go | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index 571d21420..a4c7a8559 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -1740,6 +1740,229 @@ myinclude/Test.h -> include/myinclude/Test.h ) } +func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) { + result := testSdkWithCc(t, ` + module_exports { + host_supported: true, + name: "myexports", + target: { + android: { + native_shared_libs: [ + "mynativelib", + ], + }, + not_windows: { + native_libs: [ + "mynativelib", + ], + }, + }, + } + + cc_library { + name: "mynativelib", + host_supported: true, + srcs: [ + "Test.cpp", + ], + stl: "none", + recovery_available: true, + vendor_available: true, + } + `) + + CheckSnapshot(t, result, "myexports", "", + checkUnversionedAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +cc_prebuilt_library { + name: "mynativelib", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + host_supported: true, + vendor_available: true, + stl: "none", + compile_multilib: "both", + target: { + host: { + enabled: false, + }, + android_arm64: { + shared: { + srcs: ["android/arm64/lib/mynativelib.so"], + }, + static: { + enabled: false, + }, + }, + android_arm: { + shared: { + srcs: ["android/arm/lib/mynativelib.so"], + }, + static: { + enabled: false, + }, + }, + linux_glibc_x86_64: { + enabled: true, + static: { + srcs: ["linux_glibc/x86_64/lib/mynativelib.a"], + }, + shared: { + srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], + }, + }, + linux_glibc_x86: { + enabled: true, + static: { + srcs: ["linux_glibc/x86/lib/mynativelib.a"], + }, + shared: { + srcs: ["linux_glibc/x86/lib/mynativelib.so"], + }, + }, + }, +} +`), + checkAllCopyRules(` +.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so +.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so +.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> linux_glibc/x86_64/lib/mynativelib.a +.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so +.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> linux_glibc/x86/lib/mynativelib.a +.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so +`), + ) +} + +func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) { + result := testSdkWithCc(t, ` + module_exports { + host_supported: true, + name: "myexports", + target: { + android: { + native_libs: [ + "mynativelib", + ], + }, + not_windows: { + native_shared_libs: [ + "mynativelib", + ], + }, + }, + } + + cc_library { + name: "mynativelib", + host_supported: true, + srcs: [ + "Test.cpp", + ], + stl: "none", + recovery_available: true, + vendor_available: true, + } + `) + + CheckSnapshot(t, result, "myexports", "", + checkUnversionedAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +cc_prebuilt_library { + name: "mynativelib", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + host_supported: true, + vendor_available: true, + stl: "none", + compile_multilib: "both", + target: { + host: { + enabled: false, + }, + android_arm64: { + static: { + srcs: ["android/arm64/lib/mynativelib.a"], + }, + shared: { + srcs: ["android/arm64/lib/mynativelib.so"], + }, + }, + android_arm: { + static: { + srcs: ["android/arm/lib/mynativelib.a"], + }, + shared: { + srcs: ["android/arm/lib/mynativelib.so"], + }, + }, + linux_glibc_x86_64: { + enabled: true, + shared: { + srcs: ["linux_glibc/x86_64/lib/mynativelib.so"], + }, + static: { + enabled: false, + }, + }, + linux_glibc_x86: { + enabled: true, + shared: { + srcs: ["linux_glibc/x86/lib/mynativelib.so"], + }, + static: { + enabled: false, + }, + }, + }, +} +`), + checkAllCopyRules(` +.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> android/arm64/lib/mynativelib.a +.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so +.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> android/arm/lib/mynativelib.a +.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so +.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so +.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so +`), + ) +} + +func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) { + testSdkError(t, "Incompatible member types", ` + module_exports { + host_supported: true, + name: "myexports", + target: { + android: { + native_shared_libs: [ + "mynativelib", + ], + }, + not_windows: { + native_static_libs: [ + "mynativelib", + ], + }, + }, + } + + cc_library { + name: "mynativelib", + host_supported: true, + srcs: [ + ], + stl: "none", + recovery_available: true, + vendor_available: true, + } + `) +} + func TestHostSnapshotWithMultiLib64(t *testing.T) { result := testSdkWithCc(t, ` module_exports { |