diff options
Diffstat (limited to 'cc/image.go')
| -rw-r--r-- | cc/image.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/cc/image.go b/cc/image.go index 13d77cc2d..11ba55c84 100644 --- a/cc/image.go +++ b/cc/image.go @@ -67,9 +67,8 @@ const ( ) func (ctx *moduleContext) ProductSpecific() bool { - //TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant() return ctx.ModuleContext.ProductSpecific() || - (ctx.mod.HasNonSystemVariants() && ctx.mod.InProduct()) + (ctx.mod.HasProductVariant() && ctx.mod.InProduct()) } func (ctx *moduleContext) SocSpecific() bool { @@ -277,6 +276,9 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion() boardVndkVersion := mctx.DeviceConfig().VndkVersion() productVndkVersion := mctx.DeviceConfig().ProductVndkVersion() + recoverySnapshotVersion := mctx.DeviceConfig().RecoverySnapshotVersion() + usingRecoverySnapshot := recoverySnapshotVersion != "current" && + recoverySnapshotVersion != "" if boardVndkVersion == "current" { boardVndkVersion = platformVndkVersion } @@ -315,7 +317,11 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { if snapshot, ok := m.linker.(interface { version() string }); ok { - vendorVariants = append(vendorVariants, snapshot.version()) + if m.InstallInRecovery() { + recoveryVariantNeeded = true + } else { + vendorVariants = append(vendorVariants, snapshot.version()) + } } else { mctx.ModuleErrorf("version is unknown for snapshot prebuilt") } @@ -421,6 +427,15 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { coreVariantNeeded = false } + // If using a snapshot, the recovery variant under AOSP directories is not needed, + // except for kernel headers, which needs all variants. + if _, ok := m.linker.(*kernelHeadersDecorator); !ok && + !m.isSnapshotPrebuilt() && + usingRecoverySnapshot && + !isRecoveryProprietaryModule(mctx) { + recoveryVariantNeeded = false + } + for _, variant := range android.FirstUniqueStrings(vendorVariants) { m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, VendorVariationPrefix+variant) } @@ -433,6 +448,14 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) { m.Properties.VendorRamdiskVariantNeeded = vendorRamdiskVariantNeeded m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded m.Properties.CoreVariantNeeded = coreVariantNeeded + + // Disable the module if no variants are needed. + if !ramdiskVariantNeeded && + !recoveryVariantNeeded && + !coreVariantNeeded && + len(m.Properties.ExtraVariants) == 0 { + m.Disable() + } } func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |