Support for recovery snapshot.
Bug: 171231437
Test: source build/envsetup.sh
Test: ALLOW_MISSING_DEPENDENCIES=true m -j nothing
Change-Id: I74636cf7f97e027a229a5ef7c776f2b7a42ead95
diff --git a/cc/image.go b/cc/image.go
index 380c1db..7f215e8 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -223,6 +223,9 @@
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
}
@@ -261,7 +264,11 @@
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")
}
@@ -367,6 +374,15 @@
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)
}
@@ -379,6 +395,14 @@
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 {