Merge "Refactor for preliminary Rust vendor image support" am: f48c89cd39

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1515798

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9adbb2de42979541340c995fa527b4f103a5e111
This commit is contained in:
Ivan Lozano 2020-12-11 14:03:02 +00:00 committed by Automerger Merge Worker
commit f0da84ce8e
9 changed files with 65 additions and 41 deletions

View file

@ -113,7 +113,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
// VNDK libraries available to vendor are not installed because
// they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
if !c.isVndkExt() {
if !c.IsVndkExt() {
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
}
}

View file

@ -409,7 +409,7 @@ type ModuleContextIntf interface {
isVndkPrivate(config android.Config) bool
isVndk() bool
isVndkSp() bool
isVndkExt() bool
IsVndkExt() bool
inProduct() bool
inVendor() bool
inRamdisk() bool
@ -1035,7 +1035,7 @@ func (c *Module) isLlndkPublic(config android.Config) bool {
return isLlndkLibrary(name, config) && !isVndkPrivateLibrary(name, config)
}
func (c *Module) isVndkPrivate(config android.Config) bool {
func (c *Module) IsVndkPrivate(config android.Config) bool {
// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
return isVndkPrivateLibrary(c.BaseModuleName(), config)
}
@ -1068,7 +1068,7 @@ func (c *Module) isVndkSp() bool {
return false
}
func (c *Module) isVndkExt() bool {
func (c *Module) IsVndkExt() bool {
if vndkdep := c.vndkdep; vndkdep != nil {
return vndkdep.isVndkExt()
}
@ -1252,7 +1252,7 @@ func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool {
}
func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool {
return ctx.mod.isVndkPrivate(config)
return ctx.mod.IsVndkPrivate(config)
}
func (ctx *moduleContextImpl) isVndk() bool {
@ -1271,8 +1271,8 @@ func (ctx *moduleContextImpl) isVndkSp() bool {
return ctx.mod.isVndkSp()
}
func (ctx *moduleContextImpl) isVndkExt() bool {
return ctx.mod.isVndkExt()
func (ctx *moduleContextImpl) IsVndkExt() bool {
return ctx.mod.IsVndkExt()
}
func (ctx *moduleContextImpl) mustUseVendorVariant() bool {
@ -1425,7 +1425,7 @@ func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string
// "current", it will append the VNDK version to the name suffix.
var vndkVersion string
var nameSuffix string
if c.inProduct() {
if c.InProduct() {
vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
nameSuffix = productSuffix
} else {
@ -1459,7 +1459,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
c.hideApexVariantFromMake = true
}
c.makeLinkType = c.getMakeLinkType(actx)
c.makeLinkType = GetMakeLinkType(actx, c)
c.Properties.SubName = ""
@ -2101,7 +2101,7 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
return
}
if from.Module().Target().Os != android.Android {
if from.Target().Os != android.Android {
// Host code is not restricted
return
}
@ -2115,6 +2115,11 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
if ccFrom.vndkdep != nil {
ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
}
} else if linkableMod, ok := to.(LinkableInterface); ok {
// Static libraries from other languages can be linked
if !linkableMod.Static() {
ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
}
} else {
ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
}
@ -2791,7 +2796,7 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,
return libName + vendorRamdiskSuffix
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
return libName + recoverySuffix
} else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled {
} else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
return libName + nativeBridgeSuffix
} else {
return libName
@ -2903,22 +2908,24 @@ func (c *Module) object() bool {
return false
}
func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
if c.UseVndk() {
if lib, ok := c.linker.(*llndkStubDecorator); ok {
if ccModule, ok := c.Module().(*Module); ok {
// Only CC modules provide stubs at the moment.
if lib, ok := ccModule.linker.(*llndkStubDecorator); ok {
if Bool(lib.Properties.Vendor_available) {
return "native:vndk"
}
return "native:vndk_private"
}
if c.IsVndk() && !c.isVndkExt() {
// Product_available, if defined, must have the same value with Vendor_available.
if Bool(c.VendorProperties.Vendor_available) {
return "native:vndk"
}
if c.IsVndk() && !c.IsVndkExt() {
if c.IsVndkPrivate(actx.Config()) {
return "native:vndk_private"
}
if c.inProduct() {
return "native:vndk"
}
if c.InProduct() {
return "native:product"
}
return "native:vendor"
@ -2928,7 +2935,7 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:vendor_ramdisk"
} else if c.InRecovery() {
return "native:recovery"
} else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" {
} else if c.Target().Os == android.Android && c.SdkVersion() != "" {
return "native:ndk:none:none"
// TODO(b/114741097): use the correct ndk stl once build errors have been fixed
//family, link := getNdkStlFamilyAndLinkType(c)

View file

@ -250,8 +250,8 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
// Check VNDK extension properties.
isVndkExt := extends != ""
if mod.isVndkExt() != isVndkExt {
t.Errorf("%q isVndkExt() must equal to %t", name, isVndkExt)
if mod.IsVndkExt() != isVndkExt {
t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt)
}
if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends {

View file

@ -41,7 +41,7 @@ func (c *Module) getImageVariantType() imageVariantType {
return hostImageVariant
} else if c.inVendor() {
return vendorImageVariant
} else if c.inProduct() {
} else if c.InProduct() {
return productImageVariant
} else if c.InRamdisk() {
return ramdiskImageVariant
@ -67,7 +67,7 @@ const (
func (ctx *moduleContext) ProductSpecific() bool {
//TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
return ctx.ModuleContext.ProductSpecific() ||
(ctx.mod.HasNonSystemVariants() && ctx.mod.inProduct())
(ctx.mod.HasNonSystemVariants() && ctx.mod.InProduct())
}
func (ctx *moduleContext) SocSpecific() bool {
@ -76,7 +76,7 @@ func (ctx *moduleContext) SocSpecific() bool {
}
func (ctx *moduleContextImpl) inProduct() bool {
return ctx.mod.inProduct()
return ctx.mod.InProduct()
}
func (ctx *moduleContextImpl) inVendor() bool {
@ -111,7 +111,7 @@ func (c *Module) HasNonSystemVariants() bool {
}
// Returns true if the module is "product" variant. Usually these modules are installed in /product
func (c *Module) inProduct() bool {
func (c *Module) InProduct() bool {
return c.Properties.ImageVariationPrefix == ProductVariationPrefix
}
@ -265,7 +265,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} else {
mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
}
} else if m.HasNonSystemVariants() && !m.isVndkExt() {
} else if m.HasNonSystemVariants() && !m.IsVndkExt() {
// This will be available to /system unless it is product_specific
// which will be handled later.
coreVariantNeeded = true

View file

@ -610,13 +610,13 @@ func (library *libraryDecorator) classifySourceAbiDump(ctx ModuleContext) string
}
if ctx.useVndk() && ctx.isVndk() && !ctx.isVndkPrivate(ctx.Config()) {
if ctx.isVndkSp() {
if ctx.isVndkExt() {
if ctx.IsVndkExt() {
return "VNDK-SP-ext"
} else {
return "VNDK-SP"
}
} else {
if ctx.isVndkExt() {
if ctx.IsVndkExt() {
return "VNDK-ext"
} else {
return "VNDK-core"
@ -767,7 +767,7 @@ func (library *libraryDecorator) getLibNameHelper(baseModuleName string, useVndk
func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string {
name := library.getLibNameHelper(ctx.baseModuleName(), ctx.useVndk())
if ctx.isVndkExt() {
if ctx.IsVndkExt() {
// vndk-ext lib should have the same name with original lib
ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) {
originalName := module.(*Module).outputFile.Path()
@ -1190,7 +1190,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
refAbiDumpFile, fileName, exportedHeaderFlags,
Bool(library.Properties.Header_abi_checker.Check_all_apis),
ctx.isLlndk(ctx.Config()), ctx.isNdk(ctx.Config()), ctx.isVndkExt())
ctx.isLlndk(ctx.Config()), ctx.isNdk(ctx.Config()), ctx.IsVndkExt())
}
}
}
@ -1320,7 +1320,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() {
if ctx.Device() && ctx.useVndk() {
// set subDir for VNDK extensions
if ctx.isVndkExt() {
if ctx.IsVndkExt() {
if ctx.isVndkSp() {
library.baseInstaller.subDir = "vndk-sp"
} else {
@ -1329,7 +1329,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
}
// In some cases we want to use core variant for VNDK-Core libs
if ctx.isVndk() && !ctx.isVndkSp() && !ctx.isVndkExt() {
if ctx.isVndk() && !ctx.isVndkSp() && !ctx.IsVndkExt() {
mayUseCoreVariant := true
if ctx.mustUseVendorVariant() {
@ -1350,7 +1350,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
// do not install vndk libs
// vndk libs are packaged into VNDK APEX
if ctx.isVndk() && !ctx.isVndkExt() {
if ctx.isVndk() && !ctx.IsVndkExt() {
return
}
} else if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.directlyInAnyApex() {

View file

@ -8,6 +8,8 @@ import (
// LinkableInterface is an interface for a type of module that is linkable in a C++ library.
type LinkableInterface interface {
android.Module
Module() android.Module
CcLibrary() bool
CcLibraryInterface() bool
@ -42,7 +44,10 @@ type LinkableInterface interface {
UseVndk() bool
MustUseVendorVariant() bool
IsVndk() bool
IsVndkExt() bool
IsVndkPrivate(config android.Config) bool
HasVendorVariant() bool
InProduct() bool
SdkVersion() string
AlwaysSdk() bool

View file

@ -245,7 +245,7 @@ func isSnapshotAware(m *Module, inProprietaryPath bool, apexInfo android.ApexInf
if !m.IsVndk() {
return true
}
return m.isVndkExt()
return m.IsVndkExt()
}
}
return true
@ -353,7 +353,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// Common properties among snapshots.
prop.ModuleName = ctx.ModuleName(m)
if c.supportsVndkExt && m.isVndkExt() {
if c.supportsVndkExt && m.IsVndkExt() {
// vndk exts are installed to /vendor/lib(64)?/vndk(-sp)?
if m.isVndkSp() {
prop.RelativeInstallPath = "vndk-sp"

View file

@ -389,7 +389,7 @@ func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
useCoreVariant := m.VndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
return lib.shared() && m.inVendor() && m.IsVndk() && !m.isVndkExt() && !useCoreVariant
return lib.shared() && m.inVendor() && m.IsVndk() && !m.IsVndkExt() && !useCoreVariant
}
return false
}
@ -549,7 +549,7 @@ func isVndkSnapshotAware(config android.DeviceConfig, m *Module,
if !ok || !l.shared() {
return nil, "", false
}
if m.VndkVersion() == config.PlatformVndkVersion() && m.IsVndk() && !m.isVndkExt() {
if m.VndkVersion() == config.PlatformVndkVersion() && m.IsVndk() && !m.IsVndkExt() {
if m.isVndkSp() {
return l, "vndk-sp", true
} else {

View file

@ -211,6 +211,18 @@ func (mod *Module) HasVendorVariant() bool {
return false
}
func (mod *Module) IsVndkExt() bool {
return false
}
func (c *Module) IsVndkPrivate(config android.Config) bool {
return false
}
func (mod *Module) InProduct() bool {
return false
}
func (mod *Module) SdkVersion() string {
return ""
}