From 450ae72314f1bb4be868c8436ba3fac5fd7f302c Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Fri, 16 Apr 2021 19:58:18 +0900 Subject: [PATCH] Add LLNDK stubs and headers to VNDK snapshot LLNDK stubs and headers are required to build the vendor modules against VNDK snapshot libraries. Add the LLNDK stubs and headers to the VNDK snapshot prebuilt files. The stub libraries will be included in shared/llndk-stub directory. Bug: 181815415 Test: development/vndk/snapshot/build.sh --build-artifacts Change-Id: If518f3e91080e69fa1da94af0aa27320d4e71a08 --- cc/cc_test.go | 24 +++++++++++++++++++++++- cc/vndk.go | 23 +++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/cc/cc_test.go b/cc/cc_test.go index 07dcc951f..26d1f8e88 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -546,6 +546,22 @@ func TestVndk(t *testing.T) { }, } + cc_library { + name: "libllndk", + llndk_stubs: "libllndk.llndk", + } + + llndk_library { + name: "libllndk.llndk", + symbol_file: "", + export_llndk_headers: ["libllndk_headers"], + } + + llndk_headers { + name: "libllndk_headers", + export_include_dirs: ["include"], + } + llndk_libraries_txt { name: "llndk.libraries.txt", } @@ -597,8 +613,11 @@ func TestVndk(t *testing.T) { vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core") vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp") + llndkLibPath := filepath.Join(vndkLibPath, "shared", "llndk-stub") + vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core") vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp") + llndkLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "llndk-stub") variant := "android_vendor.29_arm64_armv8-a_shared" variant2nd := "android_vendor.29_arm_armv7-a-neon_shared" @@ -611,6 +630,8 @@ func TestVndk(t *testing.T) { checkSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLib2ndPath, variant2nd) checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant) checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd) + checkSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLibPath, variant) + checkSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLib2ndPath, variant2nd) snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs") checkSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "") @@ -623,6 +644,7 @@ func TestVndk(t *testing.T) { "LLNDK: libc.so", "LLNDK: libdl.so", "LLNDK: libft2.so", + "LLNDK: libllndk.so", "LLNDK: libm.so", "VNDK-SP: libc++.so", "VNDK-SP: libvndk_sp-x.so", @@ -639,7 +661,7 @@ func TestVndk(t *testing.T) { "VNDK-product: libvndk_product.so", "VNDK-product: libvndk_sp_product_private-x.so", }) - checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libdl.so", "libft2.so", "libm.so"}) + checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libdl.so", "libft2.so", "libllndk.so", "libm.so"}) checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so", "libvndk_product.so"}) checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) diff --git a/cc/vndk.go b/cc/vndk.go index 1a8a45439..41f9fd3c8 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -609,19 +609,26 @@ func isVndkSnapshotAware(config android.DeviceConfig, m *Module, } // !inVendor: There's product/vendor variants for VNDK libs. We only care about vendor variants. // !installable: Snapshot only cares about "installable" modules. + // !m.IsLlndk: llndk stubs are required for building against snapshots. // IsSnapshotPrebuilt: Snapshotting a snapshot doesn't make sense. - if !m.InVendor() || !m.installable(apexInfo) || m.IsSnapshotPrebuilt() { + // !outputFile.Valid: Snapshot requires valid output file. + if !m.InVendor() || (!m.installable(apexInfo) && !m.IsLlndk()) || m.IsSnapshotPrebuilt() || !m.outputFile.Valid() { return nil, "", false } l, ok := m.linker.(snapshotLibraryInterface) if !ok || !l.shared() { return nil, "", false } - if m.VndkVersion() == config.PlatformVndkVersion() && m.IsVndk() && !m.IsVndkExt() { - if m.isVndkSp() { - return l, "vndk-sp", true - } else { - return l, "vndk-core", true + if m.VndkVersion() == config.PlatformVndkVersion() { + if m.IsVndk() && !m.IsVndkExt() { + if m.isVndkSp() { + return l, "vndk-sp", true + } else { + return l, "vndk-core", true + } + } else if l.hasLLNDKStubs() && l.stubsVersion() == "" { + // Use default version for the snapshot. + return l, "llndk-stub", true } } @@ -652,12 +659,16 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex (VNDK-core libraries, e.g. libbinder.so) vndk-sp/ (VNDK-SP libraries, e.g. libc++.so) + llndk-stub/ + (LLNDK stub libraries) arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/ shared/ vndk-core/ (VNDK-core libraries, e.g. libbinder.so) vndk-sp/ (VNDK-SP libraries, e.g. libc++.so) + llndk-stub/ + (LLNDK stub libraries) binder32/ (This directory is newly introduced in v28 (Android P) to hold prebuilts built for 32-bit binder interface.)