Merge changes from topic "vendor_ramdisk_soong"

* changes:
  Vendor ramdisk modules install to correct location
  Add vendor-ramdisk image to Soong.
This commit is contained in:
Yifan Hong 2020-10-24 01:08:16 +00:00 committed by Gerrit Code Review
commit b646bc183a
21 changed files with 200 additions and 48 deletions

View File

@ -914,8 +914,8 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
osTargets = targets osTargets = targets
} }
// only the primary arch in the ramdisk / recovery partition // only the primary arch in the ramdisk / vendor_ramdisk / recovery partition
if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk()) { if os == Android && (module.InstallInRecovery() || module.InstallInRamdisk() || module.InstallInVendorRamdisk()) {
osTargets = []Target{osTargets[0]} osTargets = []Target{osTargets[0]}
} }

View File

@ -1312,6 +1312,10 @@ func (c *deviceConfig) BoardKernelModuleInterfaceVersions() []string {
return c.config.productVariables.BoardKernelModuleInterfaceVersions return c.config.productVariables.BoardKernelModuleInterfaceVersions
} }
func (c *deviceConfig) BoardMoveRecoveryResourcesToVendorBoot() bool {
return Bool(c.config.productVariables.BoardMoveRecoveryResourcesToVendorBoot)
}
// The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs. // The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs.
// Such lists are used in the build system for things like bootclasspath jars or system server jars. // Such lists are used in the build system for things like bootclasspath jars or system server jars.
// The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a // The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a

View File

@ -26,6 +26,10 @@ type ImageInterface interface {
// ramdisk partition). // ramdisk partition).
RamdiskVariantNeeded(ctx BaseModuleContext) bool RamdiskVariantNeeded(ctx BaseModuleContext) bool
// VendorRamdiskVariantNeeded should return true if the module needs a vendor ramdisk variant (installed on the
// vendor ramdisk partition).
VendorRamdiskVariantNeeded(ctx BaseModuleContext) bool
// RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the // RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the
// recovery partition). // recovery partition).
RecoveryVariantNeeded(ctx BaseModuleContext) bool RecoveryVariantNeeded(ctx BaseModuleContext) bool
@ -53,6 +57,9 @@ const (
// RamdiskVariation means a module to be installed to ramdisk image. // RamdiskVariation means a module to be installed to ramdisk image.
RamdiskVariation string = "ramdisk" RamdiskVariation string = "ramdisk"
// VendorRamdiskVariation means a module to be installed to vendor ramdisk image.
VendorRamdiskVariation string = "vendor_ramdisk"
) )
// imageMutator creates variants for modules that implement the ImageInterface that // imageMutator creates variants for modules that implement the ImageInterface that
@ -73,6 +80,9 @@ func imageMutator(ctx BottomUpMutatorContext) {
if m.RamdiskVariantNeeded(ctx) { if m.RamdiskVariantNeeded(ctx) {
variations = append(variations, RamdiskVariation) variations = append(variations, RamdiskVariation)
} }
if m.VendorRamdiskVariantNeeded(ctx) {
variations = append(variations, VendorRamdiskVariation)
}
if m.RecoveryVariantNeeded(ctx) { if m.RecoveryVariantNeeded(ctx) {
variations = append(variations, RecoveryVariation) variations = append(variations, RecoveryVariation)
} }

View File

@ -348,6 +348,7 @@ type ModuleContext interface {
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool InstallInRamdisk() bool
InstallInVendorRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@ -403,6 +404,7 @@ type Module interface {
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool InstallInRamdisk() bool
InstallInVendorRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@ -623,6 +625,9 @@ type commonProperties struct {
// Whether this module is installed to ramdisk // Whether this module is installed to ramdisk
Ramdisk *bool Ramdisk *bool
// Whether this module is installed to vendor ramdisk
Vendor_ramdisk *bool
// Whether this module is built for non-native architecures (also known as native bridge binary) // Whether this module is built for non-native architecures (also known as native bridge binary)
Native_bridge_supported *bool `android:"arch_variant"` Native_bridge_supported *bool `android:"arch_variant"`
@ -1274,6 +1279,10 @@ func (m *ModuleBase) InstallInRamdisk() bool {
return Bool(m.commonProperties.Ramdisk) return Bool(m.commonProperties.Ramdisk)
} }
func (m *ModuleBase) InstallInVendorRamdisk() bool {
return Bool(m.commonProperties.Vendor_ramdisk)
}
func (m *ModuleBase) InstallInRecovery() bool { func (m *ModuleBase) InstallInRecovery() bool {
return Bool(m.commonProperties.Recovery) return Bool(m.commonProperties.Recovery)
} }
@ -1323,6 +1332,10 @@ func (m *ModuleBase) InRamdisk() bool {
return m.base().commonProperties.ImageVariation == RamdiskVariation return m.base().commonProperties.ImageVariation == RamdiskVariation
} }
func (m *ModuleBase) InVendorRamdisk() bool {
return m.base().commonProperties.ImageVariation == VendorRamdiskVariation
}
func (m *ModuleBase) InRecovery() bool { func (m *ModuleBase) InRecovery() bool {
return m.base().commonProperties.ImageVariation == RecoveryVariation return m.base().commonProperties.ImageVariation == RecoveryVariation
} }
@ -2224,6 +2237,10 @@ func (m *moduleContext) InstallInRamdisk() bool {
return m.module.InstallInRamdisk() return m.module.InstallInRamdisk()
} }
func (m *moduleContext) InstallInVendorRamdisk() bool {
return m.module.InstallInVendorRamdisk()
}
func (m *moduleContext) InstallInRecovery() bool { func (m *moduleContext) InstallInRecovery() bool {
return m.module.InstallInRecovery() return m.module.InstallInRecovery()
} }

View File

@ -58,6 +58,7 @@ type ModuleInstallPathContext interface {
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool InstallInRamdisk() bool
InstallInVendorRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@ -1376,6 +1377,15 @@ func modulePartition(ctx ModuleInstallPathContext, os OsType) string {
if !ctx.InstallInRoot() { if !ctx.InstallInRoot() {
partition += "/system" partition += "/system"
} }
} else if ctx.InstallInVendorRamdisk() {
if ctx.DeviceConfig().BoardMoveRecoveryResourcesToVendorBoot() {
partition = "recovery/root/first_stage_ramdisk"
} else {
partition = "vendor-ramdisk"
}
if !ctx.InstallInRoot() {
partition += "/system"
}
} else if ctx.InstallInRecovery() { } else if ctx.InstallInRecovery() {
if ctx.InstallInRoot() { if ctx.InstallInRoot() {
partition = "recovery/root" partition = "recovery/root"

View File

@ -200,14 +200,15 @@ func p(in interface{}) string {
type moduleInstallPathContextImpl struct { type moduleInstallPathContextImpl struct {
baseModuleContext baseModuleContext
inData bool inData bool
inTestcases bool inTestcases bool
inSanitizerDir bool inSanitizerDir bool
inRamdisk bool inRamdisk bool
inRecovery bool inVendorRamdisk bool
inRoot bool inRecovery bool
forceOS *OsType inRoot bool
forceArch *ArchType forceOS *OsType
forceArch *ArchType
} }
func (m moduleInstallPathContextImpl) Config() Config { func (m moduleInstallPathContextImpl) Config() Config {
@ -232,6 +233,10 @@ func (m moduleInstallPathContextImpl) InstallInRamdisk() bool {
return m.inRamdisk return m.inRamdisk
} }
func (m moduleInstallPathContextImpl) InstallInVendorRamdisk() bool {
return m.inVendorRamdisk
}
func (m moduleInstallPathContextImpl) InstallInRecovery() bool { func (m moduleInstallPathContextImpl) InstallInRecovery() bool {
return m.inRecovery return m.inRecovery
} }

View File

@ -352,6 +352,8 @@ type productVariables struct {
BoardKernelBinaries []string `json:",omitempty"` BoardKernelBinaries []string `json:",omitempty"`
BoardKernelModuleInterfaceVersions []string `json:",omitempty"` BoardKernelModuleInterfaceVersions []string `json:",omitempty"`
BoardMoveRecoveryResourcesToVendorBoot *bool `json:",omitempty"`
} }
func boolPtr(v bool) *bool { func boolPtr(v bool) *bool {

View File

@ -24,12 +24,13 @@ import (
) )
var ( var (
nativeBridgeSuffix = ".native_bridge" nativeBridgeSuffix = ".native_bridge"
productSuffix = ".product" productSuffix = ".product"
vendorSuffix = ".vendor" vendorSuffix = ".vendor"
ramdiskSuffix = ".ramdisk" ramdiskSuffix = ".ramdisk"
recoverySuffix = ".recovery" vendorRamdiskSuffix = ".vendor_ramdisk"
sdkSuffix = ".sdk" recoverySuffix = ".recovery"
sdkSuffix = ".sdk"
) )
type AndroidMkContext interface { type AndroidMkContext interface {
@ -43,6 +44,7 @@ type AndroidMkContext interface {
VndkVersion() string VndkVersion() string
static() bool static() bool
InRamdisk() bool InRamdisk() bool
InVendorRamdisk() bool
InRecovery() bool InRecovery() bool
AnyVariantDirectlyInAnyApex() bool AnyVariantDirectlyInAnyApex() bool
} }
@ -280,7 +282,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
}) })
} }
if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.AnyVariantDirectlyInAnyApex() && if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.AnyVariantDirectlyInAnyApex() &&
!ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() { !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
if library.buildStubs() && library.isLatestStubVersion() { if library.buildStubs() && library.isLatestStubVersion() {
// reference the latest version via its name without suffix when it is provided by apex // reference the latest version via its name without suffix when it is provided by apex
entries.SubName = "" entries.SubName = ""

View File

@ -251,7 +251,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags
} else { } else {
switch ctx.Os() { switch ctx.Os() {
case android.Android: case android.Android:
if ctx.bootstrap() && !ctx.inRecovery() && !ctx.inRamdisk() { if ctx.bootstrap() && !ctx.inRecovery() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() {
flags.DynamicLinker = "/system/bin/bootstrap/linker" flags.DynamicLinker = "/system/bin/bootstrap/linker"
} else { } else {
flags.DynamicLinker = "/system/bin/linker" flags.DynamicLinker = "/system/bin/linker"
@ -446,7 +446,8 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
// runtime APEX. // runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && ctx.directlyInAnyApex() && if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && ctx.directlyInAnyApex() &&
!translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() { !translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() &&
!ctx.inVendorRamdisk() {
if ctx.Device() && isBionic(ctx.baseModuleName()) { if ctx.Device() && isBionic(ctx.baseModuleName()) {
binary.installSymlinkToRuntimeApex(ctx, file) binary.installSymlinkToRuntimeApex(ctx, file)

View File

@ -258,14 +258,18 @@ type BaseProperties struct {
// Make this module available when building for ramdisk // Make this module available when building for ramdisk
Ramdisk_available *bool Ramdisk_available *bool
// Make this module available when building for vendor ramdisk
Vendor_ramdisk_available *bool
// Make this module available when building for recovery // Make this module available when building for recovery
Recovery_available *bool Recovery_available *bool
// Set by imageMutator // Set by imageMutator
CoreVariantNeeded bool `blueprint:"mutated"` CoreVariantNeeded bool `blueprint:"mutated"`
RamdiskVariantNeeded bool `blueprint:"mutated"` RamdiskVariantNeeded bool `blueprint:"mutated"`
RecoveryVariantNeeded bool `blueprint:"mutated"` VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
ExtraVariants []string `blueprint:"mutated"` RecoveryVariantNeeded bool `blueprint:"mutated"`
ExtraVariants []string `blueprint:"mutated"`
// Allows this module to use non-APEX version of libraries. Useful // Allows this module to use non-APEX version of libraries. Useful
// for building binaries that are started before APEXes are activated. // for building binaries that are started before APEXes are activated.
@ -353,6 +357,7 @@ type ModuleContextIntf interface {
inProduct() bool inProduct() bool
inVendor() bool inVendor() bool
inRamdisk() bool inRamdisk() bool
inVendorRamdisk() bool
inRecovery() bool inRecovery() bool
shouldCreateSourceAbiDump() bool shouldCreateSourceAbiDump() bool
selectedStl() string selectedStl() string
@ -947,7 +952,7 @@ func (c *Module) UseVndk() bool {
} }
func (c *Module) canUseSdk() bool { func (c *Module) canUseSdk() bool {
return c.Os() == android.Android && !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() return c.Os() == android.Android && !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
} }
func (c *Module) UseSdk() bool { func (c *Module) UseSdk() bool {
@ -1407,6 +1412,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
c.Properties.SubName += vendorSuffix c.Properties.SubName += vendorSuffix
} else if c.InRamdisk() && !c.OnlyInRamdisk() { } else if c.InRamdisk() && !c.OnlyInRamdisk() {
c.Properties.SubName += ramdiskSuffix c.Properties.SubName += ramdiskSuffix
} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
c.Properties.SubName += vendorRamdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() { } else if c.InRecovery() && !c.OnlyInRecovery() {
c.Properties.SubName += recoverySuffix c.Properties.SubName += recoverySuffix
} else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) { } else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) {
@ -1519,7 +1526,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// module is marked with 'bootstrap: true'). // module is marked with 'bootstrap: true').
if c.HasStubsVariants() && c.AnyVariantDirectlyInAnyApex() && !c.InRamdisk() && if c.HasStubsVariants() && c.AnyVariantDirectlyInAnyApex() && !c.InRamdisk() &&
!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() && !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() { c.IsStubs() && !c.InVendorRamdisk() {
c.Properties.HideFromMake = false // unhide c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable // Note: this is still non-installable
} }
@ -2055,6 +2062,10 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
// Ramdisk code is not NDK // Ramdisk code is not NDK
return return
} }
if from.InVendorRamdisk() {
// Vendor ramdisk code is not NDK
return
}
if from.InRecovery() { if from.InRecovery() {
// Recovery code is not NDK // Recovery code is not NDK
return return
@ -2369,7 +2380,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
} else if apexInfo.IsForPlatform() { } else if apexInfo.IsForPlatform() {
// If not building for APEX, use stubs only when it is from // If not building for APEX, use stubs only when it is from
// an APEX (and not from platform) // an APEX (and not from platform)
// However, for host, ramdisk, recovery or bootstrap modules, // However, for host, ramdisk, vendor_ramdisk, recovery or bootstrap modules,
// always link to non-stub variant // always link to non-stub variant
useStubs = dep.(android.ApexModule).AnyVariantDirectlyInAnyApex() && !c.bootstrap() useStubs = dep.(android.ApexModule).AnyVariantDirectlyInAnyApex() && !c.bootstrap()
// Another exception: if this module is bundled with an APEX, then // Another exception: if this module is bundled with an APEX, then
@ -2663,7 +2674,8 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,
} }
} }
if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRamdisk() && !c.InRecovery() { if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() &&
!c.InRamdisk() && !c.InVendorRamdisk() && !c.InRecovery() {
// The vendor module is a no-vendor-variant VNDK library. Depend on the // The vendor module is a no-vendor-variant VNDK library. Depend on the
// core module instead. // core module instead.
return libName return libName
@ -2675,6 +2687,8 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,
return libName + vendorPublicLibrarySuffix return libName + vendorPublicLibrarySuffix
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() { } else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
return libName + ramdiskSuffix return libName + ramdiskSuffix
} else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() {
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.Module().Target().NativeBridge == android.NativeBridgeEnabled {
@ -2705,6 +2719,10 @@ func (c *Module) InstallInRamdisk() bool {
return c.InRamdisk() return c.InRamdisk()
} }
func (c *Module) InstallInVendorRamdisk() bool {
return c.InVendorRamdisk()
}
func (c *Module) InstallInRecovery() bool { func (c *Module) InstallInRecovery() bool {
return c.InRecovery() return c.InRecovery()
} }
@ -2805,6 +2823,8 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:vendor" return "native:vendor"
} else if c.InRamdisk() { } else if c.InRamdisk() {
return "native:ramdisk" return "native:ramdisk"
} else if c.InVendorRamdisk() {
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 && String(c.Properties.Sdk_version) != "" {

View File

@ -388,10 +388,10 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
return return
} }
// Discard ramdisk + recovery modules, they're duplicates of // Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of
// fuzz targets we're going to package anyway. // fuzz targets we're going to package anyway.
if !ccModule.Enabled() || ccModule.Properties.PreventInstall || if !ccModule.Enabled() || ccModule.Properties.PreventInstall ||
ccModule.InRamdisk() || ccModule.InRecovery() { ccModule.InRamdisk() || ccModule.InVendorRamdisk() || ccModule.InRecovery() {
return return
} }

View File

@ -24,10 +24,11 @@ func init() {
} }
type GenruleExtraProperties struct { type GenruleExtraProperties struct {
Vendor_available *bool Vendor_available *bool
Ramdisk_available *bool Ramdisk_available *bool
Recovery_available *bool Vendor_ramdisk_available *bool
Sdk_version *string Recovery_available *bool
Sdk_version *string
} }
// cc_genrule is a genrule that can depend on other cc_* objects. // cc_genrule is a genrule that can depend on other cc_* objects.
@ -68,6 +69,10 @@ func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleCont
return Bool(g.Ramdisk_available) return Bool(g.Ramdisk_available)
} }
func (g *GenruleExtraProperties) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return Bool(g.Vendor_ramdisk_available)
}
func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return Bool(g.Recovery_available) return Bool(g.Recovery_available)
} }

View File

@ -27,12 +27,13 @@ var _ android.ImageInterface = (*Module)(nil)
type imageVariantType string type imageVariantType string
const ( const (
coreImageVariant imageVariantType = "core" coreImageVariant imageVariantType = "core"
vendorImageVariant imageVariantType = "vendor" vendorImageVariant imageVariantType = "vendor"
productImageVariant imageVariantType = "product" productImageVariant imageVariantType = "product"
ramdiskImageVariant imageVariantType = "ramdisk" ramdiskImageVariant imageVariantType = "ramdisk"
recoveryImageVariant imageVariantType = "recovery" vendorRamdiskImageVariant imageVariantType = "vendor_ramdisk"
hostImageVariant imageVariantType = "host" recoveryImageVariant imageVariantType = "recovery"
hostImageVariant imageVariantType = "host"
) )
func (c *Module) getImageVariantType() imageVariantType { func (c *Module) getImageVariantType() imageVariantType {
@ -44,6 +45,8 @@ func (c *Module) getImageVariantType() imageVariantType {
return productImageVariant return productImageVariant
} else if c.InRamdisk() { } else if c.InRamdisk() {
return ramdiskImageVariant return ramdiskImageVariant
} else if c.InVendorRamdisk() {
return vendorRamdiskImageVariant
} else if c.InRecovery() { } else if c.InRecovery() {
return recoveryImageVariant return recoveryImageVariant
} else { } else {
@ -83,6 +86,10 @@ func (ctx *moduleContextImpl) inRamdisk() bool {
return ctx.mod.InRamdisk() return ctx.mod.InRamdisk()
} }
func (ctx *moduleContextImpl) inVendorRamdisk() bool {
return ctx.mod.InVendorRamdisk()
}
func (ctx *moduleContextImpl) inRecovery() bool { func (ctx *moduleContextImpl) inRecovery() bool {
return ctx.mod.InRecovery() return ctx.mod.InRecovery()
} }
@ -107,6 +114,10 @@ func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk() return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
} }
func (c *Module) InVendorRamdisk() bool {
return c.ModuleBase.InVendorRamdisk() || c.ModuleBase.InstallInVendorRamdisk()
}
func (c *Module) InRecovery() bool { func (c *Module) InRecovery() bool {
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery() return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
} }
@ -115,6 +126,10 @@ func (c *Module) OnlyInRamdisk() bool {
return c.ModuleBase.InstallInRamdisk() return c.ModuleBase.InstallInRamdisk()
} }
func (c *Module) OnlyInVendorRamdisk() bool {
return c.ModuleBase.InstallInVendorRamdisk()
}
func (c *Module) OnlyInRecovery() bool { func (c *Module) OnlyInRecovery() bool {
return c.ModuleBase.InstallInRecovery() return c.ModuleBase.InstallInRecovery()
} }
@ -165,6 +180,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
var coreVariantNeeded bool = false var coreVariantNeeded bool = false
var ramdiskVariantNeeded bool = false var ramdiskVariantNeeded bool = false
var vendorRamdiskVariantNeeded bool = false
var recoveryVariantNeeded bool = false var recoveryVariantNeeded bool = false
var vendorVariants []string var vendorVariants []string
@ -283,6 +299,15 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
coreVariantNeeded = false coreVariantNeeded = false
} }
if Bool(m.Properties.Vendor_ramdisk_available) {
vendorRamdiskVariantNeeded = true
}
if m.ModuleBase.InstallInVendorRamdisk() {
vendorRamdiskVariantNeeded = true
coreVariantNeeded = false
}
if Bool(m.Properties.Recovery_available) { if Bool(m.Properties.Recovery_available) {
recoveryVariantNeeded = true recoveryVariantNeeded = true
} }
@ -301,6 +326,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} }
m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
m.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
m.Properties.CoreVariantNeeded = coreVariantNeeded m.Properties.CoreVariantNeeded = coreVariantNeeded
} }
@ -313,6 +339,10 @@ func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RamdiskVariantNeeded return c.Properties.RamdiskVariantNeeded
} }
func (c *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.VendorRamdiskVariantNeeded
}
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RecoveryVariantNeeded return c.Properties.RecoveryVariantNeeded
} }
@ -323,7 +353,7 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) { func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module) m := module.(*Module)
if variant == android.RamdiskVariation { if variant == android.RamdiskVariation || variant == android.VendorRamdiskVariation {
m.MakeAsPlatform() m.MakeAsPlatform()
} else if variant == android.RecoveryVariation { } else if variant == android.RecoveryVariation {
m.MakeAsPlatform() m.MakeAsPlatform()

View File

@ -1199,7 +1199,8 @@ func (library *libraryDecorator) link(ctx ModuleContext,
isVendor := ctx.useVndk() isVendor := ctx.useVndk()
isOwnerPlatform := Bool(library.Properties.Sysprop.Platform) isOwnerPlatform := Bool(library.Properties.Sysprop.Platform)
if !ctx.inRamdisk() && !ctx.inRecovery() && (isProduct || (isOwnerPlatform == isVendor)) { if !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() &&
(isProduct || (isOwnerPlatform == isVendor)) {
dir = android.PathForModuleGen(ctx, "sysprop/public", "include") dir = android.PathForModuleGen(ctx, "sysprop/public", "include")
} }
} }
@ -1291,7 +1292,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
// runtime APEX. // runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() &&
!translatedArch && !ctx.inRamdisk() && !ctx.inRecovery() { !translatedArch && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() {
if ctx.Device() { if ctx.Device() {
library.installSymlinkToRuntimeApex(ctx, file) library.installSymlinkToRuntimeApex(ctx, file)
} }
@ -1306,7 +1307,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
} }
if Bool(library.Properties.Static_ndk_lib) && library.static() && if Bool(library.Properties.Static_ndk_lib) && library.static() &&
!ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() && library.baseLinker.sanitize.isUnsanitizedVariant() &&
!library.buildStubs() && ctx.sdkVersion() == "" { !library.buildStubs() && ctx.sdkVersion() == "" {
installPath := getNdkSysrootBase(ctx).Join( installPath := getNdkSysrootBase(ctx).Join(
@ -1644,14 +1645,16 @@ func createPerApiVersionVariations(mctx android.BottomUpMutatorContext, minSdkVe
func CanBeOrLinkAgainstVersionVariants(module interface { func CanBeOrLinkAgainstVersionVariants(module interface {
Host() bool Host() bool
InRamdisk() bool InRamdisk() bool
InVendorRamdisk() bool
InRecovery() bool InRecovery() bool
}) bool { }) bool {
return !module.Host() && !module.InRamdisk() && !module.InRecovery() return !module.Host() && !module.InRamdisk() && !module.InVendorRamdisk() && !module.InRecovery()
} }
func CanBeVersionVariant(module interface { func CanBeVersionVariant(module interface {
Host() bool Host() bool
InRamdisk() bool InRamdisk() bool
InVendorRamdisk() bool
InRecovery() bool InRecovery() bool
CcLibraryInterface() bool CcLibraryInterface() bool
Shared() bool Shared() bool

View File

@ -40,6 +40,9 @@ type LinkableInterface interface {
InRamdisk() bool InRamdisk() bool
OnlyInRamdisk() bool OnlyInRamdisk() bool
InVendorRamdisk() bool
OnlyInVendorRamdisk() bool
InRecovery() bool InRecovery() bool
OnlyInRecovery() bool OnlyInRecovery() bool

View File

@ -376,8 +376,8 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
} }
// HWASan ramdisk (which is built from recovery) goes over some bootloader limit. // HWASan ramdisk (which is built from recovery) goes over some bootloader limit.
// Keep libc instrumented so that ramdisk / recovery can run hwasan-instrumented code if necessary. // Keep libc instrumented so that ramdisk / vendor_ramdisk / recovery can run hwasan-instrumented code if necessary.
if (ctx.inRamdisk() || ctx.inRecovery()) && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") { if (ctx.inRamdisk() || ctx.inVendorRamdisk() || ctx.inRecovery()) && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") {
s.Hwaddress = nil s.Hwaddress = nil
} }

View File

@ -1005,9 +1005,10 @@ func VendorSnapshotSourceMutator(ctx android.BottomUpMutatorContext) {
// But we can't just check SocSpecific() since we already passed the image mutator. // But we can't just check SocSpecific() since we already passed the image mutator.
// Check ramdisk and recovery to see if we are real "vendor: true" module. // Check ramdisk and recovery to see if we are real "vendor: true" module.
ramdisk_available := module.InRamdisk() && !module.OnlyInRamdisk() ramdisk_available := module.InRamdisk() && !module.OnlyInRamdisk()
vendor_ramdisk_available := module.InVendorRamdisk() && !module.OnlyInVendorRamdisk()
recovery_available := module.InRecovery() && !module.OnlyInRecovery() recovery_available := module.InRecovery() && !module.OnlyInRecovery()
if !ramdisk_available && !recovery_available { if !ramdisk_available && !recovery_available && !vendor_ramdisk_available {
vendorSnapshotsLock.Lock() vendorSnapshotsLock.Lock()
defer vendorSnapshotsLock.Unlock() defer vendorSnapshotsLock.Unlock()

View File

@ -61,6 +61,9 @@ type prebuiltEtcProperties struct {
// Make this module available when building for ramdisk. // Make this module available when building for ramdisk.
Ramdisk_available *bool Ramdisk_available *bool
// Make this module available when building for vendor ramdisk.
Vendor_ramdisk_available *bool
// Make this module available when building for recovery. // Make this module available when building for recovery.
Recovery_available *bool Recovery_available *bool
@ -105,6 +108,18 @@ func (p *PrebuiltEtc) InstallInRamdisk() bool {
return p.inRamdisk() return p.inRamdisk()
} }
func (p *PrebuiltEtc) inVendorRamdisk() bool {
return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
}
func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
return p.ModuleBase.InstallInVendorRamdisk()
}
func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
return p.inVendorRamdisk()
}
func (p *PrebuiltEtc) inRecovery() bool { func (p *PrebuiltEtc) inRecovery() bool {
return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery() return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
} }
@ -122,13 +137,18 @@ var _ android.ImageInterface = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {} func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool { func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
!p.ModuleBase.InstallInVendorRamdisk()
} }
func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk() return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
} }
func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
}
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery() return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
} }
@ -228,6 +248,9 @@ func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
if p.inRamdisk() && !p.onlyInRamdisk() { if p.inRamdisk() && !p.onlyInRamdisk() {
nameSuffix = ".ramdisk" nameSuffix = ".ramdisk"
} }
if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
nameSuffix = ".vendor_ramdisk"
}
if p.inRecovery() && !p.onlyInRecovery() { if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery" nameSuffix = ".recovery"
} }

View File

@ -605,6 +605,7 @@ type noopImageInterface struct{}
func (x noopImageInterface) ImageMutatorBegin(android.BaseModuleContext) {} func (x noopImageInterface) ImageMutatorBegin(android.BaseModuleContext) {}
func (x noopImageInterface) CoreVariantNeeded(android.BaseModuleContext) bool { return false } func (x noopImageInterface) CoreVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) RamdiskVariantNeeded(android.BaseModuleContext) bool { return false } func (x noopImageInterface) RamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) VendorRamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false } func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil } func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {

View File

@ -118,6 +118,10 @@ func (mod *Module) RamdiskVariantNeeded(android.BaseModuleContext) bool {
return mod.InRamdisk() return mod.InRamdisk()
} }
func (mod *Module) VendorRamdiskVariantNeeded(android.BaseModuleContext) bool {
return mod.InVendorRamdisk()
}
func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool { func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool {
return mod.InRecovery() return mod.InRecovery()
} }
@ -185,6 +189,10 @@ func (mod *Module) OnlyInRamdisk() bool {
return false return false
} }
func (mod *Module) OnlyInVendorRamdisk() bool {
return false
}
func (mod *Module) OnlyInRecovery() bool { func (mod *Module) OnlyInRecovery() bool {
return false return false
} }

View File

@ -68,6 +68,9 @@ type shBinaryProperties struct {
// Make this module available when building for ramdisk. // Make this module available when building for ramdisk.
Ramdisk_available *bool Ramdisk_available *bool
// Make this module available when building for vendor ramdisk.
Vendor_ramdisk_available *bool
// Make this module available when building for recovery. // Make this module available when building for recovery.
Recovery_available *bool Recovery_available *bool
} }
@ -176,6 +179,10 @@ func (s *ShBinary) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk() return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk()
} }
func (s *ShBinary) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.ModuleBase.InstallInVendorRamdisk()
}
func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery() return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery()
} }