diff --git a/cc/androidmk.go b/cc/androidmk.go index e58a172b8..5c5505385 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -482,12 +482,6 @@ func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, en entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { c.libraryDecorator.androidMkWriteExportedFlags(entries) - path, file := filepath.Split(c.path.ToMakePath().String()) - stem, suffix, ext := android.SplitFileExt(file) - entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) - entries.SetString("LOCAL_MODULE_SUFFIX", suffix) - entries.SetString("LOCAL_MODULE_PATH", path) - entries.SetString("LOCAL_MODULE_STEM", stem) if c.tocFile.Valid() { entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) } diff --git a/cc/cc_test.go b/cc/cc_test.go index c3caac81e..9a7753e1c 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -111,6 +111,7 @@ func testCcError(t *testing.T, pattern string, bp string) { } func testCcErrorProductVndk(t *testing.T, pattern string, bp string) { + t.Helper() config := TestConfig(buildDir, android.Android, nil, bp, nil) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.ProductVndkVersion = StringPtr("current") @@ -388,10 +389,12 @@ func TestVndk(t *testing.T) { ctx := testCcWithConfig(t, config) - checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "", vendorVariant) + // subdir == "" because VNDK libs are not supposed to be installed separately. + // They are installed as part of VNDK APEX instead. + checkVndkModule(t, ctx, "libvndk", "", false, "", vendorVariant) + checkVndkModule(t, ctx, "libvndk_private", "", false, "", vendorVariant) + checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant) + checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant) // Check VNDK snapshot output. @@ -2452,8 +2455,8 @@ func TestEnforceProductVndkVersion(t *testing.T) { ctx := testCcWithConfig(t, config) - checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "", productVariant) - checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "", productVariant) + checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant) + checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant) } func TestEnforceProductVndkVersionErrors(t *testing.T) { diff --git a/cc/library.go b/cc/library.go index 090abf997..1b7e1ed67 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1246,19 +1246,23 @@ func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { if library.shared() { if ctx.Device() && ctx.useVndk() { - if ctx.isVndkSp() { - library.baseInstaller.subDir = "vndk-sp" - } else if ctx.isVndk() { + // set subDir for VNDK extensions + if ctx.isVndkExt() { + if ctx.isVndkSp() { + library.baseInstaller.subDir = "vndk-sp" + } else { + library.baseInstaller.subDir = "vndk" + } + } + + // In some cases we want to use core variant for VNDK-Core libs + if ctx.isVndk() && !ctx.isVndkSp() && !ctx.isVndkExt() { mayUseCoreVariant := true if ctx.mustUseVendorVariant() { mayUseCoreVariant = false } - if ctx.isVndkExt() { - mayUseCoreVariant = false - } - if ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 { mayUseCoreVariant = false } @@ -1269,15 +1273,12 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { library.useCoreVariant = true } } - library.baseInstaller.subDir = "vndk" } - // Append a version to vndk or vndk-sp directories on the system partition. + // do not install vndk libs + // vndk libs are packaged into VNDK APEX if ctx.isVndk() && !ctx.isVndkExt() { - vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() - if vndkVersion != "current" && vndkVersion != "" { - library.baseInstaller.subDir += "-" + vndkVersion - } + return } } else if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.directlyInAnyApex() { // Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory. diff --git a/cc/vndk.go b/cc/vndk.go index 981e039ec..b05b85646 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -540,6 +540,9 @@ func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module, if m.Target().NativeBridge == android.NativeBridgeEnabled { return nil, "", false } + // !inVendor: There's product/vendor variants for VNDK libs. We only care about vendor variants. + // !installable: Snapshot only cares about "installable" modules. + // isSnapshotPrebuilt: Snapshotting a snapshot doesn't make sense. if !m.inVendor() || !m.installable(apexInfo) || m.isSnapshotPrebuilt() { return nil, "", false } diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go index 3556d94d5..82a7732aa 100644 --- a/cc/vndk_prebuilt.go +++ b/cc/vndk_prebuilt.go @@ -201,21 +201,7 @@ func (p *vndkPrebuiltLibraryDecorator) isSnapshotPrebuilt() bool { } func (p *vndkPrebuiltLibraryDecorator) install(ctx ModuleContext, file android.Path) { - arches := ctx.DeviceConfig().Arches() - if len(arches) == 0 || arches[0].ArchType.String() != p.arch() { - return - } - if ctx.DeviceConfig().BinderBitness() != p.binderBit() { - return - } - if p.shared() { - if ctx.isVndkSp() { - p.baseInstaller.subDir = "vndk-sp-" + p.version() - } else if ctx.isVndk() { - p.baseInstaller.subDir = "vndk-" + p.version() - } - p.baseInstaller.install(ctx, file) - } + // do not install vndk libs } func vndkPrebuiltSharedLibrary() *Module {