Refactor for preliminary Rust vendor image support
Refactors parts of CC to prepare for preliminary support for using Rust static libraries in vendor images. Some previously private functions are made public, and additional functions are added to LinkableInterface so GetMakeLinkType can be passed a LinkableInterface. Bug: 172525289 Test: m Change-Id: I5fda48e79532fe9ceab255e18d910af58048a123
This commit is contained in:
parent
110d13bef3
commit
f9e2172aec
9 changed files with 65 additions and 41 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
43
cc/cc.go
43
cc/cc.go
|
@ -401,7 +401,7 @@ type ModuleContextIntf interface {
|
|||
isVndkPrivate(config android.Config) bool
|
||||
isVndk() bool
|
||||
isVndkSp() bool
|
||||
isVndkExt() bool
|
||||
IsVndkExt() bool
|
||||
inProduct() bool
|
||||
inVendor() bool
|
||||
inRamdisk() bool
|
||||
|
@ -1024,7 +1024,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)
|
||||
}
|
||||
|
@ -1057,7 +1057,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()
|
||||
}
|
||||
|
@ -1241,7 +1241,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 {
|
||||
|
@ -1260,8 +1260,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 {
|
||||
|
@ -1414,7 +1414,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 {
|
||||
|
@ -1448,7 +1448,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||
c.hideApexVariantFromMake = true
|
||||
}
|
||||
|
||||
c.makeLinkType = c.getMakeLinkType(actx)
|
||||
c.makeLinkType = GetMakeLinkType(actx, c)
|
||||
|
||||
c.Properties.SubName = ""
|
||||
|
||||
|
@ -2097,7 +2097,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
|
||||
}
|
||||
|
@ -2111,6 +2111,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")
|
||||
}
|
||||
|
@ -2762,7 +2767,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
|
||||
|
@ -2874,22 +2879,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"
|
||||
|
@ -2899,7 +2906,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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
10
cc/image.go
10
cc/image.go
|
@ -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
|
||||
|
|
|
@ -575,13 +575,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"
|
||||
|
@ -730,7 +730,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()
|
||||
|
@ -1153,7 +1153,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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1269,7 +1269,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 {
|
||||
|
@ -1278,7 +1278,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() {
|
||||
|
@ -1299,7 +1299,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() {
|
||||
|
|
|
@ -7,6 +7,8 @@ import (
|
|||
)
|
||||
|
||||
type LinkableInterface interface {
|
||||
android.Module
|
||||
|
||||
Module() android.Module
|
||||
CcLibrary() bool
|
||||
CcLibraryInterface() bool
|
||||
|
@ -41,7 +43,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
|
||||
|
|
|
@ -842,7 +842,7 @@ func isSnapshotModule(m *Module, inProprietaryPath bool, apexInfo android.ApexIn
|
|||
if !m.IsVndk() {
|
||||
return true
|
||||
}
|
||||
return m.isVndkExt()
|
||||
return m.IsVndkExt()
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
@ -944,7 +944,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"
|
||||
|
|
|
@ -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 isVndkSnapshotLibrary(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 {
|
||||
|
|
12
rust/rust.go
12
rust/rust.go
|
@ -208,6 +208,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 ""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue