summaryrefslogtreecommitdiff
path: root/sdk/cc_sdk_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'sdk/cc_sdk_test.go')
-rw-r--r--sdk/cc_sdk_test.go1762
1 files changed, 1291 insertions, 471 deletions
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index dded15360..31555c02e 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -21,24 +21,38 @@ import (
"android/soong/cc"
)
-func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
+var ccTestFs = android.MockFS{
+ "Test.cpp": nil,
+ "myinclude/Test.h": nil,
+ "myinclude-android/AndroidTest.h": nil,
+ "myinclude-host/HostTest.h": nil,
+ "arm64/include/Arm64Test.h": nil,
+ "libfoo.so": nil,
+ "aidl/foo/bar/Test.aidl": nil,
+ "some/where/stubslib.map.txt": nil,
+}
+
+func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
t.Helper()
-
- fs := map[string][]byte{
- "Test.cpp": nil,
- "include/Test.h": nil,
- "include-android/AndroidTest.h": nil,
- "include-host/HostTest.h": nil,
- "arm64/include/Arm64Test.h": nil,
- "libfoo.so": nil,
- "aidl/foo/bar/Test.aidl": nil,
- "some/where/stubslib.map.txt": nil,
- }
- return testSdkWithFs(t, bp, fs)
+ return testSdkWithFs(t, bp, ccTestFs)
}
// Contains tests for SDK members provided by the cc package.
+func TestSingleDeviceOsAssumption(t *testing.T) {
+ // Mock a module with DeviceSupported() == true.
+ s := &sdk{}
+ android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
+
+ osTypes := s.getPossibleOsTypes()
+ if len(osTypes) != 1 {
+ // The snapshot generation assumes there is a single device OS. If more are
+ // added it might need to disable them by default, like it does for host
+ // OS'es.
+ t.Errorf("expected a single device OS, got %v", osTypes)
+ }
+}
+
func TestSdkIsCompileMultilibBoth(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
@@ -69,6 +83,98 @@ func TestSdkIsCompileMultilibBoth(t *testing.T) {
ensureListContains(t, inputs, arm64Output.String())
}
+func TestSdkCompileMultilibOverride(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ host_supported: true,
+ native_shared_libs: ["sdkmember"],
+ compile_multilib: "64",
+ }
+
+ cc_library_shared {
+ name: "sdkmember",
+ host_supported: true,
+ srcs: ["Test.cpp"],
+ stl: "none",
+ compile_multilib: "64",
+ }
+ `)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "sdkmember",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/sdkmember.so"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
+ },
+ },
+}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_sdkmember@current",
+ sdk_member_name: "sdkmember",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ installable: false,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/sdkmember.so"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ visibility: ["//visibility:public"],
+ host_supported: true,
+ compile_multilib: "64",
+ native_shared_libs: ["mysdk_sdkmember@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
+.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
+`))
+}
+
func TestBasicSdkWithCc(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
@@ -79,16 +185,18 @@ func TestBasicSdkWithCc(t *testing.T) {
cc_library_shared {
name: "sdkmember",
system_shared_libs: [],
+ stl: "none",
+ apex_available: ["mysdkapex"],
}
sdk_snapshot {
name: "mysdk@1",
- native_shared_libs: ["sdkmember_mysdk_1"],
+ native_shared_libs: ["sdkmember_mysdk@1"],
}
sdk_snapshot {
name: "mysdk@2",
- native_shared_libs: ["sdkmember_mysdk_2"],
+ native_shared_libs: ["sdkmember_mysdk@2"],
}
cc_prebuilt_library_shared {
@@ -100,7 +208,7 @@ func TestBasicSdkWithCc(t *testing.T) {
}
cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_1",
+ name: "sdkmember_mysdk@1",
sdk_member_name: "sdkmember",
srcs: ["libfoo.so"],
system_shared_libs: [],
@@ -113,7 +221,7 @@ func TestBasicSdkWithCc(t *testing.T) {
}
cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_2",
+ name: "sdkmember_mysdk@2",
sdk_member_name: "sdkmember",
srcs: ["libfoo.so"],
system_shared_libs: [],
@@ -143,6 +251,7 @@ func TestBasicSdkWithCc(t *testing.T) {
uses_sdks: ["mysdk@1"],
key: "myapex.key",
certificate: ":myapex.cert",
+ updatable: false,
}
apex {
@@ -151,14 +260,23 @@ func TestBasicSdkWithCc(t *testing.T) {
uses_sdks: ["mysdk@2"],
key: "myapex.key",
certificate: ":myapex.cert",
+ updatable: false,
+ }
+
+ apex {
+ name: "mysdkapex",
+ native_shared_libs: ["sdkmember"],
+ key: "myapex.key",
+ certificate: ":myapex.cert",
+ updatable: false,
}
`)
- sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
- sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
+ sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk@1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
+ sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk@2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
- cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
- cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
+ cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
+ cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
// Depending on the uses_sdks value, different libs are linked
ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
@@ -229,17 +347,26 @@ func TestSnapshotWithObject(t *testing.T) {
cc_object {
name: "crtobj",
stl: "none",
+ sanitize: {
+ never: true,
+ },
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_object {
- name: "mysdk_crtobj@current",
- sdk_member_name: "crtobj",
+ name: "crtobj",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
+ compile_multilib: "both",
+ sanitize: {
+ never: true,
+ },
arch: {
arm64: {
srcs: ["arm64/lib/crtobj.o"],
@@ -249,11 +376,21 @@ cc_prebuilt_object {
},
},
}
+`),
+ // Make sure that the generated sdk_snapshot uses the native_objects property.
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_object {
- name: "crtobj",
- prefer: false,
+ name: "mysdk_crtobj@current",
+ sdk_member_name: "crtobj",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
+ compile_multilib: "both",
+ sanitize: {
+ never: true,
+ },
arch: {
arm64: {
srcs: ["arm64/lib/crtobj.o"],
@@ -266,6 +403,7 @@ cc_prebuilt_object {
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
native_objects: ["mysdk_crtobj@current"],
}
`),
@@ -288,7 +426,7 @@ func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
srcs: [
"Test.cpp",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
stl: "none",
}
@@ -297,14 +435,14 @@ func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
srcs: [
"Test.cpp",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
stl: "none",
}
`)
- result.CheckSnapshot("mysdk", "",
+ CheckSnapshot(t, result, "mysdk", "",
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
@@ -313,9 +451,7 @@ include/Test.h -> include/include/Test.h
)
}
-// Verify that when the shared library has some common and some arch specific properties that the generated
-// snapshot is optimized properly.
-func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
+func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -326,62 +462,143 @@ func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
name: "mynativelib",
srcs: [
"Test.cpp",
- "aidl/foo/bar/Test.aidl",
],
- export_include_dirs: ["include"],
- arch: {
- arm64: {
- export_system_include_dirs: ["arm64/include"],
- },
- },
+ generated_headers: [
+ "generated_foo",
+ ],
+ export_generated_headers: [
+ "generated_foo",
+ ],
+ export_include_dirs: ["myinclude"],
stl: "none",
}
+
+ genrule {
+ name: "generated_foo",
+ cmd: "generate-foo",
+ out: [
+ "generated_foo/protos/foo/bar.h",
+ ],
+ export_include_dirs: [
+ ".",
+ "protos",
+ ],
+ }
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ // TODO(b/183322862): Remove this and fix the issue.
+ errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- installable: false,
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: [
+ "include/myinclude",
+ "include_gen/generated_foo/gen",
+ "include_gen/generated_foo/gen/protos",
+ ],
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.so"],
- export_system_include_dirs: ["arm64/include/arm64/include"],
},
arm: {
srcs: ["arm/lib/mynativelib.so"],
},
},
}
+`),
+ checkAllCopyRules(`
+myinclude/Test.h -> include/myinclude/Test.h
+.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h
+.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
+`),
+ snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler),
+ snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler),
+ snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler),
+ )
+}
+
+// Verify that when the shared library has some common and some arch specific
+// properties that the generated snapshot is optimized properly. Substruct
+// handling is tested with the sanitize clauses (but note there's a lot of
+// built-in logic in sanitize.go that can affect those flags).
+func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["mynativelib"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["myinclude"],
+ sanitize: {
+ fuzzer: false,
+ integer_overflow: true,
+ diag: { undefined: false },
+ },
+ arch: {
+ arm64: {
+ export_system_include_dirs: ["arm64/include"],
+ sanitize: {
+ integer_overflow: false,
+ },
+ },
+ },
+ stl: "none",
+ }
+ `)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ sanitize: {
+ fuzzer: false,
+ diag: {
+ undefined: false,
+ },
+ },
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.so"],
export_system_include_dirs: ["arm64/include/arm64/include"],
+ sanitize: {
+ integer_overflow: false,
+ },
},
arm: {
srcs: ["arm/lib/mynativelib.so"],
+ sanitize: {
+ integer_overflow: true,
+ },
},
},
}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_shared_libs: ["mysdk_mynativelib@current"],
-}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
@@ -401,18 +618,18 @@ func TestSnapshotWithCcBinary(t *testing.T) {
"Test.cpp",
],
compile_multilib: "both",
- stl: "none",
}
`)
- result.CheckSnapshot("mymodule_exports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mymodule_exports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
- name: "mymodule_exports_mynativebinary@current",
- sdk_member_name: "mynativebinary",
- installable: false,
+ name: "mynativebinary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
arch: {
arm64: {
@@ -423,10 +640,17 @@ cc_prebuilt_binary {
},
},
}
+`),
+ // Make sure that the generated sdk_snapshot uses the native_binaries property.
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
- name: "mynativebinary",
- prefer: false,
+ name: "mymodule_exports_mynativebinary@current",
+ sdk_member_name: "mynativebinary",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ installable: false,
compile_multilib: "both",
arch: {
arm64: {
@@ -440,6 +664,7 @@ cc_prebuilt_binary {
module_exports_snapshot {
name: "mymodule_exports@current",
+ visibility: ["//visibility:public"],
native_binaries: ["mymodule_exports_mynativebinary@current"],
}
`),
@@ -451,9 +676,6 @@ module_exports_snapshot {
}
func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -484,54 +706,75 @@ func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
}
`)
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
- name: "myexports_mynativebinary@current",
- sdk_member_name: "mynativebinary",
+ name: "mynativebinary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
- installable: false,
+ stl: "none",
target: {
+ host: {
+ enabled: false,
+ },
linux_glibc: {
compile_multilib: "both",
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/bin/mynativebinary"],
},
windows: {
compile_multilib: "64",
},
windows_x86_64: {
+ enabled: true,
srcs: ["windows/x86_64/bin/mynativebinary.exe"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
- name: "mynativebinary",
- prefer: false,
+ name: "myexports_mynativebinary@current",
+ sdk_member_name: "mynativebinary",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
+ installable: false,
+ stl: "none",
target: {
+ host: {
+ enabled: false,
+ },
linux_glibc: {
compile_multilib: "both",
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/bin/mynativebinary"],
},
windows: {
compile_multilib: "64",
},
windows_x86_64: {
+ enabled: true,
srcs: ["windows/x86_64/bin/mynativebinary.exe"],
},
},
@@ -539,6 +782,7 @@ cc_prebuilt_binary {
module_exports_snapshot {
name: "myexports@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
native_binaries: ["myexports_mynativebinary@current"],
@@ -546,6 +790,18 @@ module_exports_snapshot {
windows: {
compile_multilib: "64",
},
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ windows_x86_64: {
+ enabled: true,
+ },
},
}
`),
@@ -557,6 +813,283 @@ module_exports_snapshot {
)
}
+func TestSnapshotWithSingleHostOsType(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTest,
+ ccTestFs.AddToFixture(),
+ cc.PrepareForTestOnLinuxBionic,
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.Targets[android.LinuxBionic] = []android.Target{
+ {android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
+ }
+ }),
+ ).RunTestWithBp(t, `
+ cc_defaults {
+ name: "mydefaults",
+ device_supported: false,
+ host_supported: true,
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic: {
+ enabled: true,
+ },
+ },
+ }
+
+ module_exports {
+ name: "myexports",
+ defaults: ["mydefaults"],
+ native_shared_libs: ["mynativelib"],
+ native_binaries: ["mynativebinary"],
+ compile_multilib: "64", // The built-in default in sdk.go overrides mydefaults.
+ }
+
+ cc_library {
+ name: "mynativelib",
+ defaults: ["mydefaults"],
+ srcs: [
+ "Test.cpp",
+ ],
+ stl: "none",
+ }
+
+ cc_binary {
+ name: "mynativebinary",
+ defaults: ["mydefaults"],
+ srcs: [
+ "Test.cpp",
+ ],
+ stl: "none",
+ }
+ `)
+
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_binary {
+ name: "mynativebinary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/bin/mynativebinary"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/lib/mynativelib.so"],
+ },
+ },
+}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_binary {
+ name: "myexports_mynativebinary@current",
+ sdk_member_name: "mynativebinary",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ installable: false,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/bin/mynativebinary"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "myexports_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ installable: false,
+ stl: "none",
+ compile_multilib: "64",
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/lib/mynativelib.so"],
+ },
+ },
+}
+
+module_exports_snapshot {
+ name: "myexports@current",
+ visibility: ["//visibility:public"],
+ device_supported: false,
+ host_supported: true,
+ compile_multilib: "64",
+ native_binaries: ["myexports_mynativebinary@current"],
+ native_shared_libs: ["myexports_mynativelib@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_bionic_x86_64: {
+ enabled: true,
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
+.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
+`),
+ )
+}
+
+// Test that we support the necessary flags for the linker binary, which is
+// special in several ways.
+func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
+ result := testSdkWithCc(t, `
+ module_exports {
+ name: "mymodule_exports",
+ host_supported: true,
+ device_supported: false,
+ native_binaries: ["linker"],
+ }
+
+ cc_binary {
+ name: "linker",
+ host_supported: true,
+ static_executable: true,
+ nocrt: true,
+ stl: "none",
+ srcs: [
+ "Test.cpp",
+ ],
+ compile_multilib: "both",
+ }
+ `)
+
+ CheckSnapshot(t, result, "mymodule_exports", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_binary {
+ name: "linker",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ stl: "none",
+ compile_multilib: "both",
+ static_executable: true,
+ nocrt: true,
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/bin/linker"],
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ srcs: ["x86/bin/linker"],
+ },
+ },
+}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_binary {
+ name: "mymodule_exports_linker@current",
+ sdk_member_name: "linker",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ device_supported: false,
+ host_supported: true,
+ installable: false,
+ stl: "none",
+ compile_multilib: "both",
+ static_executable: true,
+ nocrt: true,
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["x86_64/bin/linker"],
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ srcs: ["x86/bin/linker"],
+ },
+ },
+}
+
+module_exports_snapshot {
+ name: "mymodule_exports@current",
+ visibility: ["//visibility:public"],
+ device_supported: false,
+ host_supported: true,
+ native_binaries: ["mymodule_exports_linker@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
+.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
+`),
+ )
+}
+
func TestSnapshotWithCcSharedLibrary(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
@@ -571,7 +1104,7 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
"aidl/foo/bar/Test.aidl",
],
apex_available: ["apex1", "apex2"],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
},
@@ -579,68 +1112,43 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- apex_available: [
- "apex1",
- "apex2",
- ],
- installable: false,
- stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- arm64: {
- srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: ["arm64/include_gen/mynativelib"],
- },
- arm: {
- srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: ["arm/include_gen/mynativelib"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
+ visibility: ["//visibility:public"],
apex_available: [
"apex1",
"apex2",
],
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: ["arm64/include_gen/mynativelib"],
+ export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_shared/gen/aidl"],
},
arm: {
srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: ["arm/include_gen/mynativelib"],
+ export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
},
},
}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_shared_libs: ["mysdk_mynativelib@current"],
-}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
-.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
-.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
`),
)
}
@@ -705,33 +1213,17 @@ func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- installable: false,
- stl: "none",
- shared_libs: [
- "mysdk_myothernativelib@current",
- "libc",
- ],
- arch: {
- arm64: {
- srcs: ["arm64/lib/mynativelib.so"],
- },
- arm: {
- srcs: ["arm/lib/mynativelib.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
+ compile_multilib: "both",
shared_libs: [
"myothernativelib",
"libc",
@@ -747,25 +1239,12 @@ cc_prebuilt_library_shared {
}
cc_prebuilt_library_shared {
- name: "mysdk_myothernativelib@current",
- sdk_member_name: "myothernativelib",
- installable: false,
- stl: "none",
- system_shared_libs: ["libm"],
- arch: {
- arm64: {
- srcs: ["arm64/lib/myothernativelib.so"],
- },
- arm: {
- srcs: ["arm/lib/myothernativelib.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "myothernativelib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
+ compile_multilib: "both",
system_shared_libs: ["libm"],
arch: {
arm64: {
@@ -778,24 +1257,12 @@ cc_prebuilt_library_shared {
}
cc_prebuilt_library_shared {
- name: "mysdk_mysystemnativelib@current",
- sdk_member_name: "mysystemnativelib",
- installable: false,
- stl: "none",
- arch: {
- arm64: {
- srcs: ["arm64/lib/mysystemnativelib.so"],
- },
- arm: {
- srcs: ["arm/lib/mysystemnativelib.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "mysystemnativelib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
+ compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/mysystemnativelib.so"],
@@ -805,15 +1272,6 @@ cc_prebuilt_library_shared {
},
},
}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_shared_libs: [
- "mysdk_mynativelib@current",
- "mysdk_myothernativelib@current",
- "mysdk_mysystemnativelib@current",
- ],
-}
`),
checkAllCopyRules(`
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
@@ -827,9 +1285,6 @@ sdk_snapshot {
}
func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -846,7 +1301,7 @@ func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
},
@@ -855,76 +1310,104 @@ func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
- installable: false,
sdk_version: "minimum",
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
},
- x86: {
+ linux_glibc_x86: {
+ enabled: true,
srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: ["x86/include_gen/mynativelib"],
+ export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mynativelib",
- prefer: false,
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
+ installable: false,
sdk_version: "minimum",
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
},
- x86: {
+ linux_glibc_x86: {
+ enabled: true,
srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: ["x86/include_gen/mynativelib"],
+ export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
},
},
}
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
native_shared_libs: ["mysdk_mynativelib@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
-.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
-.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
`),
)
}
func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -954,44 +1437,75 @@ func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
- installable: false,
stl: "none",
target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc: {
+ compile_multilib: "both",
+ },
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/mynativelib.so"],
},
+ windows: {
+ compile_multilib: "64",
+ },
windows_x86_64: {
+ enabled: true,
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mynativelib",
- prefer: false,
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
+ installable: false,
stl: "none",
target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc: {
+ compile_multilib: "both",
+ },
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/mynativelib.so"],
},
+ windows: {
+ compile_multilib: "64",
+ },
windows_x86_64: {
+ enabled: true,
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
},
@@ -999,6 +1513,7 @@ cc_prebuilt_library_shared {
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
native_shared_libs: ["mysdk_mynativelib@current"],
@@ -1006,6 +1521,18 @@ sdk_snapshot {
windows: {
compile_multilib: "64",
},
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ windows_x86_64: {
+ enabled: true,
+ },
},
}
`),
@@ -1030,7 +1557,7 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) {
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
},
@@ -1038,68 +1565,45 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- installable: false,
- stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- arm64: {
- srcs: ["arm64/lib/mynativelib.a"],
- export_include_dirs: ["arm64/include_gen/mynativelib"],
- },
- arm: {
- srcs: ["arm/lib/mynativelib.a"],
- export_include_dirs: ["arm/include_gen/mynativelib"],
- },
- },
-}
-
-cc_prebuilt_library_static {
name: "mynativelib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.a"],
- export_include_dirs: ["arm64/include_gen/mynativelib"],
+ export_include_dirs: ["arm64/include_gen/mynativelib/android_arm64_armv8-a_static/gen/aidl"],
},
arm: {
srcs: ["arm/lib/mynativelib.a"],
- export_include_dirs: ["arm/include_gen/mynativelib"],
+ export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_static/gen/aidl"],
},
},
}
-
-module_exports_snapshot {
- name: "myexports@current",
- native_static_libs: ["myexports_mynativelib@current"],
-}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
-.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
-.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
`),
)
}
func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1116,7 +1620,7 @@ func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
},
@@ -1124,66 +1628,97 @@ func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
- installable: false,
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.a"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
},
- x86: {
+ linux_glibc_x86: {
+ enabled: true,
srcs: ["x86/lib/mynativelib.a"],
- export_include_dirs: ["x86/include_gen/mynativelib"],
+ export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
- name: "mynativelib",
- prefer: false,
+ name: "myexports_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
+ installable: false,
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.a"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
},
- x86: {
+ linux_glibc_x86: {
+ enabled: true,
srcs: ["x86/lib/mynativelib.a"],
- export_include_dirs: ["x86/include_gen/mynativelib"],
+ export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
},
},
}
module_exports_snapshot {
name: "myexports@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
native_static_libs: ["myexports_mynativelib@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
-.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.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
+.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
+.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
`),
)
}
@@ -1200,21 +1735,27 @@ func TestSnapshotWithCcLibrary(t *testing.T) {
srcs: [
"Test.cpp",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
stl: "none",
+ recovery_available: true,
+ vendor_available: true,
}
`)
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- installable: false,
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ recovery_available: true,
+ vendor_available: true,
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
arch: {
arm64: {
static: {
@@ -1234,12 +1775,22 @@ cc_prebuilt_library {
},
},
}
+`),
+ // Make sure that the generated sdk_snapshot uses the native_libs property.
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library {
- name: "mynativelib",
- prefer: false,
+ name: "myexports_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ installable: false,
+ recovery_available: true,
+ vendor_available: true,
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
arch: {
arm64: {
static: {
@@ -1262,22 +1813,23 @@ cc_prebuilt_library {
module_exports_snapshot {
name: "myexports@current",
+ visibility: ["//visibility:public"],
native_libs: ["myexports_mynativelib@current"],
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
-.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
+`),
+ // TODO(b/183315522): Remove this and fix the issue.
+ snapshotTestErrorHandler(checkSnapshotPreferredWithSource, android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\Qunrecognized property "arch.arm.shared.export_include_dirs"\E`)),
)
}
func TestHostSnapshotWithMultiLib64(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1299,7 +1851,7 @@ func TestHostSnapshotWithMultiLib64(t *testing.T) {
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
},
@@ -1307,58 +1859,85 @@ func TestHostSnapshotWithMultiLib64(t *testing.T) {
}
`)
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "myexports", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
- installable: false,
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "64",
+ export_include_dirs: [
+ "include/myinclude",
+ "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
+ ],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.a"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
- name: "mynativelib",
- prefer: false,
+ name: "myexports_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
+ installable: false,
stl: "none",
- export_include_dirs: ["include/include"],
- arch: {
- x86_64: {
+ compile_multilib: "64",
+ export_include_dirs: [
+ "include/myinclude",
+ "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
+ ],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
srcs: ["x86_64/lib/mynativelib.a"],
- export_include_dirs: ["x86_64/include_gen/mynativelib"],
},
},
}
module_exports_snapshot {
name: "myexports@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
+ compile_multilib: "64",
native_static_libs: ["myexports_mynativelib@current"],
target: {
- linux_glibc: {
- compile_multilib: "64",
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
},
},
-}`),
+}
+`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
+.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
+.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
+.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
.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
`),
)
}
@@ -1372,44 +1951,32 @@ func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
cc_library_headers {
name: "mynativeheaders",
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
stl: "none",
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
- name: "mysdk_mynativeheaders@current",
- sdk_member_name: "mynativeheaders",
- stl: "none",
- export_include_dirs: ["include/include"],
-}
-
-cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
- export_include_dirs: ["include/include"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_header_libs: ["mysdk_mynativeheaders@current"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
`),
)
}
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1422,50 +1989,90 @@ func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
name: "mynativeheaders",
device_supported: false,
host_supported: true,
- export_include_dirs: ["include"],
+ export_include_dirs: ["myinclude"],
stl: "none",
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
- name: "mysdk_mynativeheaders@current",
- sdk_member_name: "mynativeheaders",
+ name: "mynativeheaders",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
- name: "mynativeheaders",
- prefer: false,
+ name: "mysdk_mynativeheaders@current",
+ sdk_member_name: "mynativeheaders",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
- export_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
device_supported: false,
host_supported: true,
native_header_libs: ["mysdk_mynativeheaders@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
+myinclude/Test.h -> include/myinclude/Test.h
`),
)
}
func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1477,72 +2084,108 @@ func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
name: "mynativeheaders",
host_supported: true,
stl: "none",
- export_system_include_dirs: ["include"],
+ export_system_include_dirs: ["myinclude"],
target: {
android: {
- export_include_dirs: ["include-android"],
+ export_include_dirs: ["myinclude-android"],
},
host: {
- export_include_dirs: ["include-host"],
+ export_include_dirs: ["myinclude-host"],
},
},
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
- name: "mysdk_mynativeheaders@current",
- sdk_member_name: "mynativeheaders",
+ name: "mynativeheaders",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
stl: "none",
- export_system_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_system_include_dirs: ["common_os/include/myinclude"],
target: {
+ host: {
+ enabled: false,
+ },
android: {
- export_include_dirs: ["include/include-android"],
+ export_include_dirs: ["android/include/myinclude-android"],
},
linux_glibc: {
- export_include_dirs: ["include/include-host"],
+ export_include_dirs: ["linux_glibc/include/myinclude-host"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
- name: "mynativeheaders",
- prefer: false,
+ name: "mysdk_mynativeheaders@current",
+ sdk_member_name: "mynativeheaders",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
stl: "none",
- export_system_include_dirs: ["include/include"],
+ compile_multilib: "both",
+ export_system_include_dirs: ["common_os/include/myinclude"],
target: {
+ host: {
+ enabled: false,
+ },
android: {
- export_include_dirs: ["include/include-android"],
+ export_include_dirs: ["android/include/myinclude-android"],
},
linux_glibc: {
- export_include_dirs: ["include/include-host"],
+ export_include_dirs: ["linux_glibc/include/myinclude-host"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
},
},
}
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
host_supported: true,
native_header_libs: ["mysdk_mynativeheaders@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`),
checkAllCopyRules(`
-include/Test.h -> include/include/Test.h
-include-android/AndroidTest.h -> include/include-android/AndroidTest.h
-include-host/HostTest.h -> include/include-host/HostTest.h
+myinclude/Test.h -> common_os/include/myinclude/Test.h
+myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
+myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
`),
)
}
func TestSystemSharedLibPropagation(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1565,27 +2208,16 @@ func TestSystemSharedLibPropagation(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_sslnil@current",
- sdk_member_name: "sslnil",
- installable: false,
- arch: {
- arm64: {
- srcs: ["arm64/lib/sslnil.so"],
- },
- arm: {
- srcs: ["arm/lib/sslnil.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "sslnil",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ compile_multilib: "both",
arch: {
arm64: {
srcs: ["arm64/lib/sslnil.so"],
@@ -1597,23 +2229,11 @@ cc_prebuilt_library_shared {
}
cc_prebuilt_library_shared {
- name: "mysdk_sslempty@current",
- sdk_member_name: "sslempty",
- installable: false,
- system_shared_libs: [],
- arch: {
- arm64: {
- srcs: ["arm64/lib/sslempty.so"],
- },
- arm: {
- srcs: ["arm/lib/sslempty.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "sslempty",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ compile_multilib: "both",
system_shared_libs: [],
arch: {
arm64: {
@@ -1626,23 +2246,11 @@ cc_prebuilt_library_shared {
}
cc_prebuilt_library_shared {
- name: "mysdk_sslnonempty@current",
- sdk_member_name: "sslnonempty",
- installable: false,
- system_shared_libs: ["mysdk_sslnil@current"],
- arch: {
- arm64: {
- srcs: ["arm64/lib/sslnonempty.so"],
- },
- arm: {
- srcs: ["arm/lib/sslnonempty.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "sslnonempty",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ compile_multilib: "both",
system_shared_libs: ["sslnil"],
arch: {
arm64: {
@@ -1653,15 +2261,6 @@ cc_prebuilt_library_shared {
},
},
}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_shared_libs: [
- "mysdk_sslnil@current",
- "mysdk_sslempty@current",
- "mysdk_sslnonempty@current",
- ],
-}
`))
result = testSdkWithCc(t, `
@@ -1682,16 +2281,21 @@ sdk_snapshot {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_sslvariants@current",
- sdk_member_name: "sslvariants",
+ name: "sslvariants",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
- installable: false,
+ compile_multilib: "both",
target: {
+ host: {
+ enabled: false,
+ },
android: {
system_shared_libs: [],
},
@@ -1702,19 +2306,31 @@ cc_prebuilt_library_shared {
srcs: ["android/arm/lib/sslvariants.so"],
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/sslvariants.so"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "sslvariants",
- prefer: false,
+ name: "mysdk_sslvariants@current",
+ sdk_member_name: "sslvariants",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
+ installable: false,
+ compile_multilib: "both",
target: {
+ host: {
+ enabled: false,
+ },
android: {
system_shared_libs: [],
},
@@ -1725,9 +2341,11 @@ cc_prebuilt_library_shared {
srcs: ["android/arm/lib/sslvariants.so"],
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/sslvariants.so"],
},
},
@@ -1735,8 +2353,20 @@ cc_prebuilt_library_shared {
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
host_supported: true,
native_shared_libs: ["mysdk_sslvariants@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`))
}
@@ -1762,32 +2392,23 @@ func TestStubsLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_stubslib@current",
- sdk_member_name: "stubslib",
- installable: false,
- stubs: {
- versions: ["3"],
- },
- arch: {
- arm64: {
- srcs: ["arm64/lib/stubslib.so"],
- },
- arm: {
- srcs: ["arm/lib/stubslib.so"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
name: "stubslib",
prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ compile_multilib: "both",
stubs: {
- versions: ["3"],
+ versions: [
+ "1",
+ "2",
+ "3",
+ "current",
+ ],
},
arch: {
arm64: {
@@ -1798,18 +2419,10 @@ cc_prebuilt_library_shared {
},
},
}
-
-sdk_snapshot {
- name: "mysdk@current",
- native_shared_libs: ["mysdk_stubslib@current"],
-}
`))
}
func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
- // b/145598135 - Generating host snapshots for anything other than linux is not supported.
- SkipIfNotLinux(t)
-
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1833,19 +2446,29 @@ func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
}
`)
- result.CheckSnapshot("mysdk", "",
- checkAndroidBpContents(`
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "mysdk_stubslib@current",
- sdk_member_name: "stubslib",
+ name: "stubslib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
- installable: false,
+ compile_multilib: "both",
stubs: {
- versions: ["3"],
+ versions: [
+ "1",
+ "2",
+ "3",
+ "current",
+ ],
},
target: {
+ host: {
+ enabled: false,
+ },
android_arm64: {
srcs: ["android/arm64/lib/stubslib.so"],
},
@@ -1853,22 +2476,39 @@ cc_prebuilt_library_shared {
srcs: ["android/arm/lib/stubslib.so"],
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/stubslib.so"],
},
},
}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
- name: "stubslib",
- prefer: false,
+ name: "mysdk_stubslib@current",
+ sdk_member_name: "stubslib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
+ installable: false,
+ compile_multilib: "both",
stubs: {
- versions: ["3"],
+ versions: [
+ "1",
+ "2",
+ "3",
+ "current",
+ ],
},
target: {
+ host: {
+ enabled: false,
+ },
android_arm64: {
srcs: ["android/arm64/lib/stubslib.so"],
},
@@ -1876,9 +2516,11 @@ cc_prebuilt_library_shared {
srcs: ["android/arm/lib/stubslib.so"],
},
linux_glibc_x86_64: {
+ enabled: true,
srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
},
linux_glibc_x86: {
+ enabled: true,
srcs: ["linux_glibc/x86/lib/stubslib.so"],
},
},
@@ -1886,8 +2528,186 @@ cc_prebuilt_library_shared {
sdk_snapshot {
name: "mysdk@current",
+ visibility: ["//visibility:public"],
host_supported: true,
native_shared_libs: ["mysdk_stubslib@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
}
`))
}
+
+func TestUniqueHostSoname(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ host_supported: true,
+ native_shared_libs: ["mylib"],
+ }
+
+ cc_library {
+ name: "mylib",
+ host_supported: true,
+ unique_host_soname: true,
+ }
+ `)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mylib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ unique_host_soname: true,
+ compile_multilib: "both",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/mylib.so"],
+ },
+ android_arm: {
+ srcs: ["android/arm/lib/mylib.so"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ srcs: ["linux_glibc/x86/lib/mylib-host.so"],
+ },
+ },
+}
+`),
+ checkVersionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_mylib@current",
+ sdk_member_name: "mylib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ installable: false,
+ unique_host_soname: true,
+ compile_multilib: "both",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/mylib.so"],
+ },
+ android_arm: {
+ srcs: ["android/arm/lib/mylib.so"],
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ srcs: ["linux_glibc/x86/lib/mylib-host.so"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ visibility: ["//visibility:public"],
+ host_supported: true,
+ native_shared_libs: ["mysdk_mylib@current"],
+ target: {
+ host: {
+ enabled: false,
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
+.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
+.intermediates/mylib/linux_glibc_x86_64_shared/mylib-host.so -> linux_glibc/x86_64/lib/mylib-host.so
+.intermediates/mylib/linux_glibc_x86_shared/mylib-host.so -> linux_glibc/x86/lib/mylib-host.so
+`),
+ )
+}
+
+func TestNoSanitizerMembers(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["mynativelib"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ srcs: ["Test.cpp"],
+ export_include_dirs: ["myinclude"],
+ arch: {
+ arm64: {
+ export_system_include_dirs: ["arm64/include"],
+ sanitize: {
+ hwaddress: true,
+ },
+ },
+ },
+ }
+ `)
+
+ // Mixing the snapshot with the source (irrespective of which one is preferred) causes a problem
+ // due to missing variants.
+ // TODO(b/183204176): Remove this and fix the cause.
+ snapshotWithSourceErrorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QReplaceDependencies could not find identical variant {os:android,image:,arch:arm64_armv8-a,sdk:,link:shared,version:} for module mynativelib\E`)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ compile_multilib: "both",
+ export_include_dirs: ["include/myinclude"],
+ arch: {
+ arm64: {
+ export_system_include_dirs: ["arm64/include/arm64/include"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+myinclude/Test.h -> include/myinclude/Test.h
+arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
+`),
+ snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, snapshotWithSourceErrorHandler),
+ snapshotTestErrorHandler(checkSnapshotPreferredWithSource, snapshotWithSourceErrorHandler),
+ )
+}