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
commit a8c82cc218
20 changed files with 188 additions and 20 deletions

View file

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

View file

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

View file

@ -1237,3 +1237,7 @@ func (c *deviceConfig) DeviceSecondaryArch() string {
func (c *deviceConfig) DeviceSecondaryArchVariant() string {
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(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
// recovery partition).
RecoveryVariantNeeded(ctx BaseModuleContext) bool
@ -46,6 +50,9 @@ const (
// RecoveryVariation means a module to be installed to recovery image.
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
@ -63,6 +70,9 @@ func imageMutator(ctx BottomUpMutatorContext) {
if m.CoreVariantNeeded(ctx) {
variations = append(variations, CoreVariation)
}
if m.RamdiskVariantNeeded(ctx) {
variations = append(variations, RamdiskVariation)
}
if m.RecoveryVariantNeeded(ctx) {
variations = append(variations, RecoveryVariation)
}

View file

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

View file

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

View file

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

View file

@ -41,6 +41,9 @@ type prebuiltEtcProperties struct {
// is the same as the file name of the source file.
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.
Recovery_available *bool
@ -69,6 +72,18 @@ type PrebuiltEtc struct {
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 {
return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
}
@ -86,7 +101,11 @@ var _ ImageInterface = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) ImageMutatorBegin(ctx BaseModuleContext) {}
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 {
@ -167,6 +186,9 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
nameSuffix := ""
if p.inRamdisk() && !p.onlyInRamdisk() {
nameSuffix = ".ramdisk"
}
if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery"
}

View file

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

View file

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

View file

@ -264,7 +264,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags
} else {
switch ctx.Os() {
case android.Android:
if ctx.bootstrap() && !ctx.inRecovery() {
if ctx.bootstrap() && !ctx.inRecovery() && !ctx.inRamdisk() {
flags.DynamicLinker = "/system/bin/bootstrap/linker"
} else {
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
// runtime APEX.
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()) {
binary.installSymlinkToRuntimeApex(ctx, file)
}

View file

@ -223,11 +223,15 @@ type BaseProperties struct {
// file
Logtags []string
// Make this module available when building for ramdisk
Ramdisk_available *bool
// Make this module available when building for recovery
Recovery_available *bool
// Set by imageMutator
CoreVariantNeeded bool `blueprint:"mutated"`
RamdiskVariantNeeded bool `blueprint:"mutated"`
RecoveryVariantNeeded bool `blueprint:"mutated"`
ExtraVariants []string `blueprint:"mutated"`
@ -290,6 +294,7 @@ type ModuleContextIntf interface {
isVndkExt() bool
inProduct() bool
inVendor() bool
inRamdisk() bool
inRecovery() bool
shouldCreateSourceAbiDump() bool
selectedStl() string
@ -878,10 +883,18 @@ func (c *Module) inVendor() bool {
return c.Properties.ImageVariationPrefix == VendorVariationPrefix
}
func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
}
func (c *Module) InRecovery() bool {
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
}
func (c *Module) OnlyInRamdisk() bool {
return c.ModuleBase.InstallInRamdisk()
}
func (c *Module) OnlyInRecovery() bool {
return c.ModuleBase.InstallInRecovery()
}
@ -1018,7 +1031,7 @@ func (ctx *moduleContextImpl) header() 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 false
@ -1090,6 +1103,10 @@ func (ctx *moduleContextImpl) inVendor() bool {
return ctx.mod.inVendor()
}
func (ctx *moduleContextImpl) inRamdisk() bool {
return ctx.mod.InRamdisk()
}
func (ctx *moduleContextImpl) inRecovery() bool {
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
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
c.Properties.SubName += vendorSuffix
} else if c.InRamdisk() && !c.OnlyInRamdisk() {
c.Properties.SubName += ramdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() {
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
// module is marked with 'bootstrap: true').
if c.HasStubsVariants() &&
android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) &&
android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && !c.InRamdisk() &&
!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() {
c.Properties.HideFromMake = false // unhide
@ -1732,7 +1751,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
var variations []blueprint.Variation
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
versionVariantAvail := !ctx.useVndk() && !c.InRecovery()
versionVariantAvail := !ctx.useVndk() && !c.InRecovery() && !c.InRamdisk()
if version != "" && versionVariantAvail {
// Version is explicitly specified. i.e. libFoo#30
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
return
}
if from.InRamdisk() {
// Ramdisk code is not NDK
return
}
if from.InRecovery() {
// Recovery code is not NDK
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
// an APEX (and not from platform)
useThisDep = (depInPlatform != depIsStubs)
if c.InRecovery() || c.bootstrap() {
// However, for recovery or bootstrap modules,
if c.InRamdisk() || c.InRecovery() || c.bootstrap() {
// However, for ramdisk, recovery or bootstrap modules,
// always link to non-stub variant
useThisDep = !depIsStubs
}
@ -2275,7 +2298,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
isVendorPublicLib := inList(libName, *vendorPublicLibraries)
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
// core module instead.
return libName
@ -2285,6 +2308,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return libName + c.getNameSuffixWithVndkVersion(ctx)
} else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
return libName + vendorPublicLibrarySuffix
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
return libName + ramdiskSuffix
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
return libName + recoverySuffix
} else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled {
@ -2369,6 +2394,10 @@ func (c *Module) InstallInSanitizerDir() bool {
return c.installer.inSanitizerDir()
}
func (c *Module) InstallInRamdisk() bool {
return c.InRamdisk()
}
func (c *Module) InstallInRecovery() bool {
return c.InRecovery()
}
@ -2441,6 +2470,8 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
return "native:product"
}
return "native:vendor"
} else if c.InRamdisk() {
return "native:ramdisk"
} else if c.InRecovery() {
return "native:recovery"
} 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 ramdiskVariantNeeded bool = false
var recoveryVariantNeeded bool = false
var vendorVariants []string
@ -2729,6 +2761,15 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
productVariants = []string{}
}
if Bool(m.Properties.Ramdisk_available) {
ramdiskVariantNeeded = true
}
if m.ModuleBase.InstallInRamdisk() {
ramdiskVariantNeeded = true
coreVariantNeeded = false
}
if Bool(m.Properties.Recovery_available) {
recoveryVariantNeeded = true
}
@ -2746,6 +2787,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant)
}
m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
m.Properties.CoreVariantNeeded = coreVariantNeeded
}
@ -2754,6 +2796,10 @@ func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.CoreVariantNeeded
}
func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RamdiskVariantNeeded
}
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
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) {
m := module.(*Module)
if variant == android.RecoveryVariation {
if variant == android.RamdiskVariation {
m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
} else if strings.HasPrefix(variant, VendorVariationPrefix) {

View file

@ -355,10 +355,10 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
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.
if !ccModule.Enabled() || ccModule.Properties.PreventInstall ||
ccModule.UseVndk() || ccModule.InRecovery() {
ccModule.UseVndk() || ccModule.InRamdisk() || ccModule.InRecovery() {
return
}

View file

@ -25,6 +25,7 @@ func init() {
type GenruleExtraProperties struct {
Vendor_available *bool
Ramdisk_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())
}
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return Bool(g.Ramdisk_available)
}
func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
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.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
}
@ -1040,7 +1047,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
isVendor := ctx.useVndk()
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")
}
}
@ -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
// runtime APEX.
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() {
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() &&
!ctx.useVndk() && !ctx.inRecovery() && ctx.Device() &&
!ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() &&
!library.buildStubs() {
installPath := getNdkSysrootBase(ctx).Join(

View file

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

View file

@ -141,6 +141,19 @@ type BaseLinkerProperties struct {
// of the C/C++ module.
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.
@ -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)
}
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() {
// libclang_rt.builtins and libatomic have to be last on the command line
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.
// Keep libc instrumented so that recovery can run hwasan-instrumented code if necessary.
if ctx.inRecovery() && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") {
// Keep libc instrumented so that ramdisk / recovery can run hwasan-instrumented code if necessary.
if (ctx.inRamdisk() || ctx.inRecovery()) && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") {
s.Hwaddress = nil
}

View file

@ -550,6 +550,7 @@ type noopImageInterface struct{}
func (x noopImageInterface) ImageMutatorBegin(android.BaseModuleContext) {}
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) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
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
}
func (mod *Module) RamdiskVariantNeeded(android.BaseModuleContext) bool {
return mod.InRamdisk()
}
func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool {
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()))
}
func (mod *Module) OnlyInRamdisk() bool {
return false
}
func (mod *Module) OnlyInRecovery() bool {
return false
}