Add support for using cc_library in sdk/module_exports

Added link type support in module creation code as cc_prebuilt_library
has to provide both shared and static libraries.

Had to add some calls to FirstUniquePaths() around the include dirs
settings in library_sdk_member as otherwise the shared variant contains
duplicate include dirs (presumably because it gets one set from its
dependency on the static variant and one set of its own). That
difference in include dirs causes problems in the generated
cc_prebuilt_library.

Test: m nothing
Bug: 142918168
Change-Id: Ie7f23fc2341c83c7814cc98e3970df4f5d4c8423
This commit is contained in:
Paul Duffin
2020-03-12 10:24:35 +00:00
parent 71da478f51
commit 9b76c0b65a
5 changed files with 198 additions and 8 deletions

View File

@@ -1196,6 +1196,93 @@ include/Test.h -> include/include/Test.h
)
}
func TestSnapshotWithCcLibrary(t *testing.T) {
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
native_libs: ["mynativelib"],
}
cc_library {
name: "mynativelib",
srcs: [
"Test.cpp",
],
export_include_dirs: ["include"],
system_shared_libs: [],
stl: "none",
}
`)
result.CheckSnapshot("myexports", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library {
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
installable: false,
stl: "none",
export_include_dirs: ["include/include"],
arch: {
arm64: {
static: {
srcs: ["arm64/lib/mynativelib.a"],
},
shared: {
srcs: ["arm64/lib/mynativelib.so"],
},
},
arm: {
static: {
srcs: ["arm/lib/mynativelib.a"],
},
shared: {
srcs: ["arm/lib/mynativelib.so"],
},
},
},
}
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
stl: "none",
export_include_dirs: ["include/include"],
arch: {
arm64: {
static: {
srcs: ["arm64/lib/mynativelib.a"],
},
shared: {
srcs: ["arm64/lib/mynativelib.so"],
},
},
arm: {
static: {
srcs: ["arm/lib/mynativelib.a"],
},
shared: {
srcs: ["arm/lib/mynativelib.so"],
},
},
},
}
module_exports_snapshot {
name: "myexports@current",
native_libs: ["myexports_mynativelib@current"],
}
`),
checkAllCopyRules(`
include/Test.h -> include/include/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`),
)
}
func TestHostSnapshotWithMultiLib64(t *testing.T) {
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
SkipIfNotLinux(t)