Move vendor and product variant generation logic from cc package to android package

Although image variation generation logic has moved out of cc package to
the android package, the vendor and product partition variants
generation logic is still specific to cc package. Therefore, in order to
create a product or vendor variant, they have to specified in
`ExtraImageVariants`. In order to avoid such confusing behaviors and
enforce modules to specify product and vendor installation rules, this
change moves the vendor and product variant generation logic to
android.ImageInterface.

Test: m nothing --no-skip-soong-tests && diff contents of out/soong/Android-{product}.mk
Change-Id: I9e14f3739d9dea94167ee6a91e92b2f942055aba
This commit is contained in:
Jihoon Kang
2024-06-19 00:51:16 +00:00
parent 25cdff6815
commit 47e918450f
12 changed files with 137 additions and 92 deletions

View File

@@ -77,6 +77,14 @@ func (mod *Module) SetCoreVariantNeeded(b bool) {
mod.Properties.CoreVariantNeeded = b
}
func (mod *Module) SetProductVariantNeeded(b bool) {
mod.Properties.ProductVariantNeeded = b
}
func (mod *Module) SetVendorVariantNeeded(b bool) {
mod.Properties.VendorVariantNeeded = b
}
func (mod *Module) SnapshotVersion(mctx android.BaseModuleContext) string {
if snapshot, ok := mod.compiler.(cc.SnapshotInterface); ok {
return snapshot.Version()
@@ -86,6 +94,14 @@ func (mod *Module) SnapshotVersion(mctx android.BaseModuleContext) string {
}
}
func (mod *Module) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
return mod.Properties.VendorVariantNeeded
}
func (mod *Module) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
return mod.Properties.ProductVariantNeeded
}
func (mod *Module) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return mod.Properties.VendorRamdiskVariantNeeded
}
@@ -184,12 +200,12 @@ func (mod *Module) HasNonSystemVariants() bool {
}
func (mod *Module) InProduct() bool {
return mod.Properties.ImageVariation == cc.ProductVariation
return mod.Properties.ImageVariation == android.ProductVariation
}
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
func (mod *Module) InVendor() bool {
return mod.Properties.ImageVariation == cc.VendorVariation
return mod.Properties.ImageVariation == android.VendorVariation
}
// Returns true if the module is "vendor" or "product" variant.
@@ -202,13 +218,13 @@ func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant stri
mod.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
mod.MakeAsPlatform()
} else if strings.HasPrefix(variant, cc.VendorVariation) {
mod.Properties.ImageVariation = cc.VendorVariation
} else if strings.HasPrefix(variant, android.VendorVariation) {
mod.Properties.ImageVariation = android.VendorVariation
if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
}
} else if strings.HasPrefix(variant, cc.ProductVariation) {
mod.Properties.ImageVariation = cc.ProductVariation
} else if strings.HasPrefix(variant, android.ProductVariation) {
mod.Properties.ImageVariation = android.ProductVariation
if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
}

View File

@@ -80,6 +80,8 @@ type BaseProperties struct {
RustSubName string `blueprint:"mutated"`
// Set by imageMutator
ProductVariantNeeded bool `blueprint:"mutated"`
VendorVariantNeeded bool `blueprint:"mutated"`
CoreVariantNeeded bool `blueprint:"mutated"`
VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
RamdiskVariantNeeded bool `blueprint:"mutated"`