Merge changes from topics "board_use_recovery_as_root_soong", "ramdisk"

* changes:
  libatomic / libgcc_stripped: ramdisk_available
  Add target.ramdisk
  Ramdisk modules install to correct location
  Add ramdisk image.
This commit is contained in:
Yifan Hong
2020-01-24 22:39:41 +00:00
committed by Gerrit Code Review
20 changed files with 188 additions and 20 deletions

View File

@@ -549,6 +549,7 @@ toolchain_library {
name: "libatomic", name: "libatomic",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
ramdisk_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
@@ -595,6 +596,7 @@ toolchain_library {
name: "libgcc_stripped", name: "libgcc_stripped",
defaults: ["linux_bionic_supported"], defaults: ["linux_bionic_supported"],
vendor_available: true, vendor_available: true,
ramdisk_available: true,
recovery_available: true, recovery_available: true,
native_bridge_supported: true, native_bridge_supported: true,
sdk_version: "current", sdk_version: "current",

View File

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

View File

@@ -1237,3 +1237,7 @@ func (c *deviceConfig) DeviceSecondaryArch() string {
func (c *deviceConfig) DeviceSecondaryArchVariant() string { func (c *deviceConfig) DeviceSecondaryArchVariant() string {
return String(c.config.productVariables.DeviceSecondaryArchVariant) return String(c.config.productVariables.DeviceSecondaryArchVariant)
} }
func (c *deviceConfig) BoardUsesRecoveryAsBoot() bool {
return Bool(c.config.productVariables.BoardUsesRecoveryAsBoot)
}

View File

@@ -22,6 +22,10 @@ type ImageInterface interface {
// CoreVariantNeeded should return true if the module needs a core variant (installed on the system image). // CoreVariantNeeded should return true if the module needs a core variant (installed on the system image).
CoreVariantNeeded(ctx BaseModuleContext) bool CoreVariantNeeded(ctx BaseModuleContext) bool
// RamdiskVariantNeeded should return true if the module needs a ramdisk variant (installed on the
// ramdisk partition).
RamdiskVariantNeeded(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
@@ -46,6 +50,9 @@ const (
// RecoveryVariation means a module to be installed to recovery image. // RecoveryVariation means a module to be installed to recovery image.
RecoveryVariation string = "recovery" RecoveryVariation string = "recovery"
// RamdiskVariation means a module to be installed to ramdisk image.
RamdiskVariation string = "ramdisk"
) )
// imageMutator creates variants for modules that implement the ImageInterface that // imageMutator creates variants for modules that implement the ImageInterface that
@@ -63,6 +70,9 @@ func imageMutator(ctx BottomUpMutatorContext) {
if m.CoreVariantNeeded(ctx) { if m.CoreVariantNeeded(ctx) {
variations = append(variations, CoreVariation) variations = append(variations, CoreVariation)
} }
if m.RamdiskVariantNeeded(ctx) {
variations = append(variations, RamdiskVariation)
}
if m.RecoveryVariantNeeded(ctx) { if m.RecoveryVariantNeeded(ctx) {
variations = append(variations, RecoveryVariation) variations = append(variations, RecoveryVariation)
} }

View File

@@ -167,6 +167,7 @@ type ModuleContext interface {
InstallInData() bool InstallInData() bool
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@@ -207,6 +208,7 @@ type Module interface {
InstallInData() bool InstallInData() bool
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@@ -384,6 +386,9 @@ type commonProperties struct {
// Whether this module is installed to recovery partition // Whether this module is installed to recovery partition
Recovery *bool Recovery *bool
// Whether this module is installed to ramdisk
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"`
@@ -867,6 +872,10 @@ func (m *ModuleBase) InstallInSanitizerDir() bool {
return false return false
} }
func (m *ModuleBase) InstallInRamdisk() bool {
return Bool(m.commonProperties.Ramdisk)
}
func (m *ModuleBase) InstallInRecovery() bool { func (m *ModuleBase) InstallInRecovery() bool {
return Bool(m.commonProperties.Recovery) return Bool(m.commonProperties.Recovery)
} }
@@ -898,6 +907,10 @@ func (m *ModuleBase) ImageVariation() blueprint.Variation {
} }
} }
func (m *ModuleBase) InRamdisk() bool {
return m.base().commonProperties.ImageVariation == RamdiskVariation
}
func (m *ModuleBase) InRecovery() bool { func (m *ModuleBase) InRecovery() bool {
return m.base().commonProperties.ImageVariation == RecoveryVariation return m.base().commonProperties.ImageVariation == RecoveryVariation
} }
@@ -1649,6 +1662,10 @@ func (m *moduleContext) InstallInSanitizerDir() bool {
return m.module.InstallInSanitizerDir() return m.module.InstallInSanitizerDir()
} }
func (m *moduleContext) InstallInRamdisk() bool {
return m.module.InstallInRamdisk()
}
func (m *moduleContext) InstallInRecovery() bool { func (m *moduleContext) InstallInRecovery() bool {
return m.module.InstallInRecovery() return m.module.InstallInRecovery()
} }

View File

@@ -49,6 +49,7 @@ type ModuleInstallPathContext interface {
InstallInData() bool InstallInData() bool
InstallInTestcases() bool InstallInTestcases() bool
InstallInSanitizerDir() bool InstallInSanitizerDir() bool
InstallInRamdisk() bool
InstallInRecovery() bool InstallInRecovery() bool
InstallInRoot() bool InstallInRoot() bool
InstallBypassMake() bool InstallBypassMake() bool
@@ -1254,6 +1255,15 @@ func modulePartition(ctx ModuleInstallPathContext) string {
partition = "data" partition = "data"
} else if ctx.InstallInTestcases() { } else if ctx.InstallInTestcases() {
partition = "testcases" partition = "testcases"
} else if ctx.InstallInRamdisk() {
if ctx.DeviceConfig().BoardUsesRecoveryAsBoot() {
partition = "recovery/root/first_stage_ramdisk"
} else {
partition = "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

@@ -202,6 +202,7 @@ type moduleInstallPathContextImpl struct {
inData bool inData bool
inTestcases bool inTestcases bool
inSanitizerDir bool inSanitizerDir bool
inRamdisk bool
inRecovery bool inRecovery bool
inRoot bool inRoot bool
} }
@@ -224,6 +225,10 @@ func (m moduleInstallPathContextImpl) InstallInSanitizerDir() bool {
return m.inSanitizerDir return m.inSanitizerDir
} }
func (m moduleInstallPathContextImpl) InstallInRamdisk() bool {
return m.inRamdisk
}
func (m moduleInstallPathContextImpl) InstallInRecovery() bool { func (m moduleInstallPathContextImpl) InstallInRecovery() bool {
return m.inRecovery return m.inRecovery
} }

View File

@@ -41,6 +41,9 @@ type prebuiltEtcProperties struct {
// is the same as the file name of the source file. // is the same as the file name of the source file.
Filename_from_src *bool `android:"arch_variant"` Filename_from_src *bool `android:"arch_variant"`
// Make this module available when building for ramdisk.
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
@@ -69,6 +72,18 @@ type PrebuiltEtc struct {
additionalDependencies *Paths additionalDependencies *Paths
} }
func (p *PrebuiltEtc) inRamdisk() bool {
return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
}
func (p *PrebuiltEtc) onlyInRamdisk() bool {
return p.ModuleBase.InstallInRamdisk()
}
func (p *PrebuiltEtc) InstallInRamdisk() bool {
return p.inRamdisk()
}
func (p *PrebuiltEtc) inRecovery() bool { func (p *PrebuiltEtc) inRecovery() bool {
return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery() return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
} }
@@ -86,7 +101,11 @@ var _ ImageInterface = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) ImageMutatorBegin(ctx BaseModuleContext) {} func (p *PrebuiltEtc) ImageMutatorBegin(ctx BaseModuleContext) {}
func (p *PrebuiltEtc) CoreVariantNeeded(ctx BaseModuleContext) bool { func (p *PrebuiltEtc) CoreVariantNeeded(ctx BaseModuleContext) bool {
return !p.ModuleBase.InstallInRecovery() return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk()
}
func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx BaseModuleContext) bool {
return Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
} }
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx BaseModuleContext) bool { func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx BaseModuleContext) bool {
@@ -167,6 +186,9 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries { func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
nameSuffix := "" nameSuffix := ""
if p.inRamdisk() && !p.onlyInRamdisk() {
nameSuffix = ".ramdisk"
}
if p.inRecovery() && !p.onlyInRecovery() { if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery" nameSuffix = ".recovery"
} }

View File

@@ -317,6 +317,8 @@ type productVariables struct {
EnforceProductPartitionInterface *bool `json:",omitempty"` EnforceProductPartitionInterface *bool `json:",omitempty"`
InstallExtraFlattenedApexes *bool `json:",omitempty"` InstallExtraFlattenedApexes *bool `json:",omitempty"`
BoardUsesRecoveryAsBoot *bool `json:",omitempty"`
} }
func boolPtr(v bool) *bool { func boolPtr(v bool) *bool {

View File

@@ -27,6 +27,7 @@ var (
nativeBridgeSuffix = ".native_bridge" nativeBridgeSuffix = ".native_bridge"
productSuffix = ".product" productSuffix = ".product"
vendorSuffix = ".vendor" vendorSuffix = ".vendor"
ramdiskSuffix = ".ramdisk"
recoverySuffix = ".recovery" recoverySuffix = ".recovery"
) )
@@ -40,6 +41,7 @@ type AndroidMkContext interface {
UseVndk() bool UseVndk() bool
VndkVersion() string VndkVersion() string
static() bool static() bool
InRamdisk() bool
InRecovery() bool InRecovery() bool
} }
@@ -233,7 +235,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
}) })
} }
if len(library.Properties.Stubs.Versions) > 0 && if len(library.Properties.Stubs.Versions) > 0 &&
android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRecovery() && !ctx.UseVndk() && android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
!ctx.static() { !ctx.static() {
if !library.buildStubs() { if !library.buildStubs() {
ret.SubName = ".bootstrap" ret.SubName = ".bootstrap"

View File

@@ -264,7 +264,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() { if ctx.bootstrap() && !ctx.inRecovery() && !ctx.inRamdisk() {
flags.DynamicLinker = "/system/bin/bootstrap/linker" flags.DynamicLinker = "/system/bin/bootstrap/linker"
} else { } else {
flags.DynamicLinker = "/system/bin/linker" flags.DynamicLinker = "/system/bin/linker"
@@ -458,7 +458,7 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
// The original path becomes a symlink to the corresponding file in the // The original path becomes a symlink to the corresponding file in the
// runtime APEX. // runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexName() == "" && !ctx.inRecovery() { if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() {
if ctx.Device() && isBionic(ctx.baseModuleName()) { if ctx.Device() && isBionic(ctx.baseModuleName()) {
binary.installSymlinkToRuntimeApex(ctx, file) binary.installSymlinkToRuntimeApex(ctx, file)
} }

View File

@@ -223,11 +223,15 @@ type BaseProperties struct {
// file // file
Logtags []string Logtags []string
// Make this module available when building for ramdisk
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"`
RecoveryVariantNeeded bool `blueprint:"mutated"` RecoveryVariantNeeded bool `blueprint:"mutated"`
ExtraVariants []string `blueprint:"mutated"` ExtraVariants []string `blueprint:"mutated"`
@@ -290,6 +294,7 @@ type ModuleContextIntf interface {
isVndkExt() bool isVndkExt() bool
inProduct() bool inProduct() bool
inVendor() bool inVendor() bool
inRamdisk() bool
inRecovery() bool inRecovery() bool
shouldCreateSourceAbiDump() bool shouldCreateSourceAbiDump() bool
selectedStl() string selectedStl() string
@@ -878,10 +883,18 @@ func (c *Module) inVendor() bool {
return c.Properties.ImageVariationPrefix == VendorVariationPrefix return c.Properties.ImageVariationPrefix == VendorVariationPrefix
} }
func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
}
func (c *Module) InRecovery() bool { func (c *Module) InRecovery() bool {
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery() return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
} }
func (c *Module) OnlyInRamdisk() bool {
return c.ModuleBase.InstallInRamdisk()
}
func (c *Module) OnlyInRecovery() bool { func (c *Module) OnlyInRecovery() bool {
return c.ModuleBase.InstallInRecovery() return c.ModuleBase.InstallInRecovery()
} }
@@ -1018,7 +1031,7 @@ func (ctx *moduleContextImpl) header() bool {
} }
func (ctx *moduleContextImpl) useSdk() bool { func (ctx *moduleContextImpl) useSdk() bool {
if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() { if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() {
return String(ctx.mod.Properties.Sdk_version) != "" return String(ctx.mod.Properties.Sdk_version) != ""
} }
return false return false
@@ -1090,6 +1103,10 @@ func (ctx *moduleContextImpl) inVendor() bool {
return ctx.mod.inVendor() return ctx.mod.inVendor()
} }
func (ctx *moduleContextImpl) inRamdisk() bool {
return ctx.mod.InRamdisk()
}
func (ctx *moduleContextImpl) inRecovery() bool { func (ctx *moduleContextImpl) inRecovery() bool {
return ctx.mod.InRecovery() return ctx.mod.InRecovery()
} }
@@ -1335,6 +1352,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with // .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp. // such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
c.Properties.SubName += vendorSuffix c.Properties.SubName += vendorSuffix
} else if c.InRamdisk() && !c.OnlyInRamdisk() {
c.Properties.SubName += ramdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() { } else if c.InRecovery() && !c.OnlyInRecovery() {
c.Properties.SubName += recoverySuffix c.Properties.SubName += recoverySuffix
} }
@@ -1444,7 +1463,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// (unless it is explicitly referenced via .bootstrap suffix or the // (unless it is explicitly referenced via .bootstrap suffix or the
// module is marked with 'bootstrap: true'). // module is marked with 'bootstrap: true').
if c.HasStubsVariants() && if c.HasStubsVariants() &&
android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && !c.InRamdisk() &&
!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() && !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() { c.IsStubs() {
c.Properties.HideFromMake = false // unhide c.Properties.HideFromMake = false // unhide
@@ -1732,7 +1751,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) { addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
var variations []blueprint.Variation var variations []blueprint.Variation
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"}) variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
versionVariantAvail := !ctx.useVndk() && !c.InRecovery() versionVariantAvail := !ctx.useVndk() && !c.InRecovery() && !c.InRamdisk()
if version != "" && versionVariantAvail { if version != "" && versionVariantAvail {
// Version is explicitly specified. i.e. libFoo#30 // Version is explicitly specified. i.e. libFoo#30
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version}) variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
@@ -1863,6 +1882,10 @@ func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to Linkabl
// Platform code can link to anything // Platform code can link to anything
return return
} }
if from.InRamdisk() {
// Ramdisk code is not NDK
return
}
if from.InRecovery() { if from.InRecovery() {
// Recovery code is not NDK // Recovery code is not NDK
return return
@@ -2123,8 +2146,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// 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)
useThisDep = (depInPlatform != depIsStubs) useThisDep = (depInPlatform != depIsStubs)
if c.InRecovery() || c.bootstrap() { if c.InRamdisk() || c.InRecovery() || c.bootstrap() {
// However, for recovery or bootstrap modules, // However, for ramdisk, recovery or bootstrap modules,
// always link to non-stub variant // always link to non-stub variant
useThisDep = !depIsStubs useThisDep = !depIsStubs
} }
@@ -2275,7 +2298,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
isVendorPublicLib := inList(libName, *vendorPublicLibraries) isVendorPublicLib := inList(libName, *vendorPublicLibraries)
bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk
if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRecovery() { if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRamdisk() && !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
@@ -2285,6 +2308,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return libName + c.getNameSuffixWithVndkVersion(ctx) return libName + c.getNameSuffixWithVndkVersion(ctx)
} else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib { } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
return libName + vendorPublicLibrarySuffix return libName + vendorPublicLibrarySuffix
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
return libName + ramdiskSuffix
} 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 {
@@ -2369,6 +2394,10 @@ func (c *Module) InstallInSanitizerDir() bool {
return c.installer.inSanitizerDir() return c.installer.inSanitizerDir()
} }
func (c *Module) InstallInRamdisk() bool {
return c.InRamdisk()
}
func (c *Module) InstallInRecovery() bool { func (c *Module) InstallInRecovery() bool {
return c.InRecovery() return c.InRecovery()
} }
@@ -2441,6 +2470,8 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:product" return "native:product"
} }
return "native:vendor" return "native:vendor"
} else if c.InRamdisk() {
return "native: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) != "" {
@@ -2647,6 +2678,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
} }
var coreVariantNeeded bool = false var coreVariantNeeded bool = false
var ramdiskVariantNeeded bool = false
var recoveryVariantNeeded bool = false var recoveryVariantNeeded bool = false
var vendorVariants []string var vendorVariants []string
@@ -2729,6 +2761,15 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
productVariants = []string{} productVariants = []string{}
} }
if Bool(m.Properties.Ramdisk_available) {
ramdiskVariantNeeded = true
}
if m.ModuleBase.InstallInRamdisk() {
ramdiskVariantNeeded = true
coreVariantNeeded = false
}
if Bool(m.Properties.Recovery_available) { if Bool(m.Properties.Recovery_available) {
recoveryVariantNeeded = true recoveryVariantNeeded = true
} }
@@ -2746,6 +2787,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant) m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant)
} }
m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
m.Properties.CoreVariantNeeded = coreVariantNeeded m.Properties.CoreVariantNeeded = coreVariantNeeded
} }
@@ -2754,6 +2796,10 @@ func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.CoreVariantNeeded return c.Properties.CoreVariantNeeded
} }
func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RamdiskVariantNeeded
}
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RecoveryVariantNeeded return c.Properties.RecoveryVariantNeeded
} }
@@ -2764,7 +2810,9 @@ 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.RecoveryVariation { if variant == android.RamdiskVariation {
m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform() m.MakeAsPlatform()
squashRecoverySrcs(m) squashRecoverySrcs(m)
} else if strings.HasPrefix(variant, VendorVariationPrefix) { } else if strings.HasPrefix(variant, VendorVariationPrefix) {

View File

@@ -355,10 +355,10 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
return return
} }
// Discard vendor-NDK-linked + recovery modules, they're duplicates of // Discard vendor-NDK-linked + 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.UseVndk() || ccModule.InRecovery() { ccModule.UseVndk() || ccModule.InRamdisk() || ccModule.InRecovery() {
return return
} }

View File

@@ -25,6 +25,7 @@ func init() {
type GenruleExtraProperties struct { type GenruleExtraProperties struct {
Vendor_available *bool Vendor_available *bool
Ramdisk_available *bool
Recovery_available *bool Recovery_available *bool
} }
@@ -62,6 +63,10 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific()) return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
} }
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return Bool(g.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

@@ -757,6 +757,13 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs) deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs)
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
} }
if ctx.inRamdisk() {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Ramdisk.Exclude_shared_libs)
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Ramdisk.Exclude_shared_libs)
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Ramdisk.Exclude_static_libs)
}
return deps return deps
} }
@@ -1040,7 +1047,7 @@ 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.inRecovery() && (isProduct || (isOwnerPlatform == isVendor)) { if !ctx.inRamdisk() && !ctx.inRecovery() && (isProduct || (isOwnerPlatform == isVendor)) {
dir = android.PathForModuleGen(ctx, "sysprop/public", "include") dir = android.PathForModuleGen(ctx, "sysprop/public", "include")
} }
} }
@@ -1118,7 +1125,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
// The original path becomes a symlink to the corresponding file in the // The original path becomes a symlink to the corresponding file in the
// runtime APEX. // runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && !translatedArch && !ctx.inRecovery() { if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && !translatedArch && !ctx.inRamdisk() && !ctx.inRecovery() {
if ctx.Device() { if ctx.Device() {
library.installSymlinkToRuntimeApex(ctx, file) library.installSymlinkToRuntimeApex(ctx, file)
} }
@@ -1133,7 +1140,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.inRecovery() && ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() && library.baseLinker.sanitize.isUnsanitizedVariant() &&
!library.buildStubs() { !library.buildStubs() {
installPath := getNdkSysrootBase(ctx).Join( installPath := getNdkSysrootBase(ctx).Join(

View File

@@ -38,6 +38,9 @@ type LinkableInterface interface {
Shared() bool Shared() bool
Toc() android.OptionalPath Toc() android.OptionalPath
InRamdisk() bool
OnlyInRamdisk() bool
InRecovery() bool InRecovery() bool
OnlyInRecovery() bool OnlyInRecovery() bool

View File

@@ -141,6 +141,19 @@ type BaseLinkerProperties struct {
// of the C/C++ module. // of the C/C++ module.
Exclude_header_libs []string Exclude_header_libs []string
} }
Ramdisk struct {
// list of static libs that only should be used to build the recovery
// variant of the C/C++ module.
Static_libs []string
// list of shared libs that should not be used to build
// the ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
// list of static libs that should not be used to build
// the ramdisk variant of the C/C++ module.
Exclude_static_libs []string
}
} }
// make android::build:GetBuildNumber() available containing the build ID. // make android::build:GetBuildNumber() available containing the build ID.
@@ -223,6 +236,15 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs)
} }
if ctx.inRamdisk() {
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Recovery.Exclude_shared_libs)
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Recovery.Exclude_shared_libs)
deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Recovery.Static_libs...)
deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs)
}
if ctx.toolchain().Bionic() { if ctx.toolchain().Bionic() {
// libclang_rt.builtins and libatomic have to be last on the command line // libclang_rt.builtins and libatomic have to be last on the command line
if !Bool(linker.Properties.No_libcrt) { if !Bool(linker.Properties.No_libcrt) {

View File

@@ -351,8 +351,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 recovery can run hwasan-instrumented code if necessary. // Keep libc instrumented so that ramdisk / recovery can run hwasan-instrumented code if necessary.
if ctx.inRecovery() && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") { if (ctx.inRamdisk() || ctx.inRecovery()) && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") {
s.Hwaddress = nil s.Hwaddress = nil
} }

View File

@@ -550,6 +550,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) 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

@@ -85,6 +85,10 @@ func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return true return true
} }
func (mod *Module) RamdiskVariantNeeded(android.BaseModuleContext) bool {
return mod.InRamdisk()
}
func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool { func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool {
return mod.InRecovery() return mod.InRecovery()
} }
@@ -152,6 +156,10 @@ func (mod *Module) Toc() android.OptionalPath {
panic(fmt.Errorf("Toc() called on non-library module: %q", mod.BaseModuleName())) panic(fmt.Errorf("Toc() called on non-library module: %q", mod.BaseModuleName()))
} }
func (mod *Module) OnlyInRamdisk() bool {
return false
}
func (mod *Module) OnlyInRecovery() bool { func (mod *Module) OnlyInRecovery() bool {
return false return false
} }