Merge "Refactor for preliminary Rust vendor image support"

This commit is contained in:
Ivan Lozano
2020-12-11 13:40:20 +00:00
committed by Gerrit Code Review
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()) entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
// VNDK libraries available to vendor are not installed because // VNDK libraries available to vendor are not installed because
// they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go) // 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) entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
} }
} }

View File

@@ -409,7 +409,7 @@ type ModuleContextIntf interface {
isVndkPrivate(config android.Config) bool isVndkPrivate(config android.Config) bool
isVndk() bool isVndk() bool
isVndkSp() bool isVndkSp() bool
isVndkExt() bool IsVndkExt() bool
inProduct() bool inProduct() bool
inVendor() bool inVendor() bool
inRamdisk() bool inRamdisk() bool
@@ -1035,7 +1035,7 @@ func (c *Module) isLlndkPublic(config android.Config) bool {
return isLlndkLibrary(name, config) && !isVndkPrivateLibrary(name, config) 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. // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
return isVndkPrivateLibrary(c.BaseModuleName(), config) return isVndkPrivateLibrary(c.BaseModuleName(), config)
} }
@@ -1068,7 +1068,7 @@ func (c *Module) isVndkSp() bool {
return false return false
} }
func (c *Module) isVndkExt() bool { func (c *Module) IsVndkExt() bool {
if vndkdep := c.vndkdep; vndkdep != nil { if vndkdep := c.vndkdep; vndkdep != nil {
return vndkdep.isVndkExt() return vndkdep.isVndkExt()
} }
@@ -1252,7 +1252,7 @@ func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool {
} }
func (ctx *moduleContextImpl) isVndkPrivate(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 { func (ctx *moduleContextImpl) isVndk() bool {
@@ -1271,8 +1271,8 @@ func (ctx *moduleContextImpl) isVndkSp() bool {
return ctx.mod.isVndkSp() return ctx.mod.isVndkSp()
} }
func (ctx *moduleContextImpl) isVndkExt() bool { func (ctx *moduleContextImpl) IsVndkExt() bool {
return ctx.mod.isVndkExt() return ctx.mod.IsVndkExt()
} }
func (ctx *moduleContextImpl) mustUseVendorVariant() bool { 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. // "current", it will append the VNDK version to the name suffix.
var vndkVersion string var vndkVersion string
var nameSuffix string var nameSuffix string
if c.inProduct() { if c.InProduct() {
vndkVersion = ctx.DeviceConfig().ProductVndkVersion() vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
nameSuffix = productSuffix nameSuffix = productSuffix
} else { } else {
@@ -1459,7 +1459,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
c.hideApexVariantFromMake = true c.hideApexVariantFromMake = true
} }
c.makeLinkType = c.getMakeLinkType(actx) c.makeLinkType = GetMakeLinkType(actx, c)
c.Properties.SubName = "" c.Properties.SubName = ""
@@ -2101,7 +2101,7 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
return return
} }
if from.Module().Target().Os != android.Android { if from.Target().Os != android.Android {
// Host code is not restricted // Host code is not restricted
return return
} }
@@ -2115,6 +2115,11 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
if ccFrom.vndkdep != nil { if ccFrom.vndkdep != nil {
ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag) 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 { } else {
ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type") 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 return libName + vendorRamdiskSuffix
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() { } else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
return libName + recoverySuffix return libName + recoverySuffix
} else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled { } else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
return libName + nativeBridgeSuffix return libName + nativeBridgeSuffix
} else { } else {
return libName return libName
@@ -2903,22 +2908,24 @@ func (c *Module) object() bool {
return false return false
} }
func (c *Module) getMakeLinkType(actx android.ModuleContext) string { func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
if c.UseVndk() { 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) { if Bool(lib.Properties.Vendor_available) {
return "native:vndk" return "native:vndk"
} }
return "native:vndk_private" 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" return "native:vndk_private"
} }
if c.inProduct() { return "native:vndk"
}
if c.InProduct() {
return "native:product" return "native:product"
} }
return "native:vendor" return "native:vendor"
@@ -2928,7 +2935,7 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:vendor_ramdisk" return "native:vendor_ramdisk"
} else if c.InRecovery() { } else if c.InRecovery() {
return "native:recovery" 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" return "native:ndk:none:none"
// TODO(b/114741097): use the correct ndk stl once build errors have been fixed // TODO(b/114741097): use the correct ndk stl once build errors have been fixed
//family, link := getNdkStlFamilyAndLinkType(c) //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. // Check VNDK extension properties.
isVndkExt := extends != "" isVndkExt := extends != ""
if mod.isVndkExt() != isVndkExt { if mod.IsVndkExt() != isVndkExt {
t.Errorf("%q isVndkExt() must equal to %t", name, isVndkExt) t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt)
} }
if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends { if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends {

View File

@@ -41,7 +41,7 @@ func (c *Module) getImageVariantType() imageVariantType {
return hostImageVariant return hostImageVariant
} else if c.inVendor() { } else if c.inVendor() {
return vendorImageVariant return vendorImageVariant
} else if c.inProduct() { } else if c.InProduct() {
return productImageVariant return productImageVariant
} else if c.InRamdisk() { } else if c.InRamdisk() {
return ramdiskImageVariant return ramdiskImageVariant
@@ -67,7 +67,7 @@ const (
func (ctx *moduleContext) ProductSpecific() bool { func (ctx *moduleContext) ProductSpecific() bool {
//TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant() //TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
return ctx.ModuleContext.ProductSpecific() || return ctx.ModuleContext.ProductSpecific() ||
(ctx.mod.HasNonSystemVariants() && ctx.mod.inProduct()) (ctx.mod.HasNonSystemVariants() && ctx.mod.InProduct())
} }
func (ctx *moduleContext) SocSpecific() bool { func (ctx *moduleContext) SocSpecific() bool {
@@ -76,7 +76,7 @@ func (ctx *moduleContext) SocSpecific() bool {
} }
func (ctx *moduleContextImpl) inProduct() bool { func (ctx *moduleContextImpl) inProduct() bool {
return ctx.mod.inProduct() return ctx.mod.InProduct()
} }
func (ctx *moduleContextImpl) inVendor() bool { 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 // 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 return c.Properties.ImageVariationPrefix == ProductVariationPrefix
} }
@@ -265,7 +265,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} else { } else {
mctx.ModuleErrorf("version is unknown for snapshot prebuilt") 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 // This will be available to /system unless it is product_specific
// which will be handled later. // which will be handled later.
coreVariantNeeded = true 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.useVndk() && ctx.isVndk() && !ctx.isVndkPrivate(ctx.Config()) {
if ctx.isVndkSp() { if ctx.isVndkSp() {
if ctx.isVndkExt() { if ctx.IsVndkExt() {
return "VNDK-SP-ext" return "VNDK-SP-ext"
} else { } else {
return "VNDK-SP" return "VNDK-SP"
} }
} else { } else {
if ctx.isVndkExt() { if ctx.IsVndkExt() {
return "VNDK-ext" return "VNDK-ext"
} else { } else {
return "VNDK-core" return "VNDK-core"
@@ -767,7 +767,7 @@ func (library *libraryDecorator) getLibNameHelper(baseModuleName string, useVndk
func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string { func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string {
name := library.getLibNameHelper(ctx.baseModuleName(), ctx.useVndk()) name := library.getLibNameHelper(ctx.baseModuleName(), ctx.useVndk())
if ctx.isVndkExt() { if ctx.IsVndkExt() {
// vndk-ext lib should have the same name with original lib // vndk-ext lib should have the same name with original lib
ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) { ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) {
originalName := module.(*Module).outputFile.Path() originalName := module.(*Module).outputFile.Path()
@@ -1190,7 +1190,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(), library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
refAbiDumpFile, fileName, exportedHeaderFlags, refAbiDumpFile, fileName, exportedHeaderFlags,
Bool(library.Properties.Header_abi_checker.Check_all_apis), 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 library.shared() {
if ctx.Device() && ctx.useVndk() { if ctx.Device() && ctx.useVndk() {
// set subDir for VNDK extensions // set subDir for VNDK extensions
if ctx.isVndkExt() { if ctx.IsVndkExt() {
if ctx.isVndkSp() { if ctx.isVndkSp() {
library.baseInstaller.subDir = "vndk-sp" library.baseInstaller.subDir = "vndk-sp"
} else { } 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 // 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 mayUseCoreVariant := true
if ctx.mustUseVendorVariant() { if ctx.mustUseVendorVariant() {
@@ -1350,7 +1350,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
// do not install vndk libs // do not install vndk libs
// vndk libs are packaged into VNDK APEX // vndk libs are packaged into VNDK APEX
if ctx.isVndk() && !ctx.isVndkExt() { if ctx.isVndk() && !ctx.IsVndkExt() {
return return
} }
} else if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.directlyInAnyApex() { } 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. // LinkableInterface is an interface for a type of module that is linkable in a C++ library.
type LinkableInterface interface { type LinkableInterface interface {
android.Module
Module() android.Module Module() android.Module
CcLibrary() bool CcLibrary() bool
CcLibraryInterface() bool CcLibraryInterface() bool
@@ -42,7 +44,10 @@ type LinkableInterface interface {
UseVndk() bool UseVndk() bool
MustUseVendorVariant() bool MustUseVendorVariant() bool
IsVndk() bool IsVndk() bool
IsVndkExt() bool
IsVndkPrivate(config android.Config) bool
HasVendorVariant() bool HasVendorVariant() bool
InProduct() bool
SdkVersion() string SdkVersion() string
AlwaysSdk() bool AlwaysSdk() bool

View File

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

View File

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

View File

@@ -211,6 +211,18 @@ func (mod *Module) HasVendorVariant() bool {
return false 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 { func (mod *Module) SdkVersion() string {
return "" return ""
} }