summaryrefslogtreecommitdiff
path: root/sdk/cc_sdk_test.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2019-12-11 20:00:57 +0000
committer Paul Duffin <paulduffin@google.com> 2019-12-13 09:59:48 +0000
commita7cd8c8344b7e2be3dc82ecaa0c92adf09489158 (patch)
tree6cc4e4df5545ce7fa4d7c7892bd665650a6e32df /sdk/cc_sdk_test.go
parentcf96a82fbd3cd240901bbf64af7fca98136f256b (diff)
Generalize common property extraction
Previously, code that attempted to optimize the generated .bp rules treated the properties structure as a single entity. So, a single arch specific value would cause all properties to be treated as arch specific. Also, that code was specific to one structure type. This generalizes the optimization to work with any properties structure which will be helpful for other multi-variant module types. It also treats each property separately. The hasArchSpecificFlags field has been removed from nativeLibInfo and a commonProperties field has been added instead into which the common values will be found. File path creation that conditionally prefixed a path with archType has been replaced with general code that relies on archType being "" for common properties and filepath.Join(..) ignoring empty string components. The common and arch variant properties are always processed. The first within the context of the .bp module's property set and the latter within an arch specific property set. There are always some properties that are arch specific, e.g. outputFile, so there is no need to worry about an empty arch property set being created. The archSpecificNativeLibInfo type was renamed nativeLibInfoProperties as it may not be arch specific. The printExportedDirCopyCommandsForNativeLibs variable was renamed to addExportedDirCopyCommandsForNativeLibs as it no longer does any printing. Bug: 142918168 Test: m checkbuild Change-Id: Iad45913299c37fd76fe03ed0ca68bdc68ed76431
Diffstat (limited to 'sdk/cc_sdk_test.go')
-rw-r--r--sdk/cc_sdk_test.go86
1 files changed, 82 insertions, 4 deletions
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index bc22dbb9d..4a5cf5ee6 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -24,10 +24,11 @@ func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
t.Helper()
fs := map[string][]byte{
- "Test.cpp": nil,
- "include/Test.h": nil,
- "libfoo.so": nil,
- "aidl/foo/bar/Test.aidl": nil,
+ "Test.cpp": nil,
+ "include/Test.h": nil,
+ "arm64/include/Arm64Test.h": nil,
+ "libfoo.so": nil,
+ "aidl/foo/bar/Test.aidl": nil,
}
return testSdkWithFs(t, bp, fs)
}
@@ -181,6 +182,83 @@ 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) {
+ 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: ["include"],
+ arch: {
+ arm64: {
+ export_system_include_dirs: ["arm64/include"],
+ },
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_system_include_dirs: ["arm64/include/arm64/include"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_system_include_dirs: ["arm64/include/arm64/include"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_shared_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
+.intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so -> arm64/lib/mynativelib.so
+arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/mynativelib.so -> arm/lib/mynativelib.so`),
+ )
+}
+
func TestSnapshotWithCcSharedLibrary(t *testing.T) {
result := testSdkWithCc(t, `
sdk {