Merge "Move vendor and product variant generation logic from cc package to android package" into main

This commit is contained in:
Jihoon Kang
2024-06-21 18:16:31 +00:00
committed by Gerrit Code Review
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"`