Merge "Cleanup ImageInterface.SetImageVariation" into main

This commit is contained in:
Treehugger Robot 2024-06-14 04:26:52 +00:00 committed by Gerrit Code Review
commit 77858402e4
9 changed files with 30 additions and 35 deletions

View file

@ -44,9 +44,8 @@ type ImageInterface interface {
ExtraImageVariations(ctx BaseModuleContext) []string
// SetImageVariation is called for each newly created image variant. The receiver is the original
// module, "variation" is the name of the newly created variant and "module" is the newly created
// variant itself.
SetImageVariation(ctx BaseModuleContext, variation string, module Module)
// module, "variation" is the name of the newly created variant. "variation" is set on the receiver.
SetImageVariation(ctx BaseModuleContext, variation string)
}
const (
@ -106,7 +105,7 @@ func imageMutator(ctx BottomUpMutatorContext) {
mod := ctx.CreateVariations(variations...)
for i, v := range variations {
mod[i].base().setImageVariation(v)
m.SetImageVariation(ctx, v, mod[i])
mod[i].(ImageInterface).SetImageVariation(ctx, v)
}
}
}

View file

@ -131,7 +131,7 @@ func (bpf *bpf) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return nil
}
func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string) {
bpf.properties.VendorInternal = variation == "vendor"
}

View file

@ -114,5 +114,5 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
return variants
}
func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}

View file

@ -628,30 +628,29 @@ func squashRamdiskSrcs(m *Module) {
}
}
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.RamdiskVariation {
m.MakeAsPlatform()
squashRamdiskSrcs(m)
c.MakeAsPlatform()
squashRamdiskSrcs(c)
} else if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
squashVendorRamdiskSrcs(m)
c.MakeAsPlatform()
squashVendorRamdiskSrcs(c)
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
c.MakeAsPlatform()
squashRecoverySrcs(c)
} else if strings.HasPrefix(variant, VendorVariation) {
m.Properties.ImageVariation = VendorVariation
c.Properties.ImageVariation = VendorVariation
if strings.HasPrefix(variant, VendorVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
c.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
}
squashVendorSrcs(m)
squashVendorSrcs(c)
} else if strings.HasPrefix(variant, ProductVariation) {
m.Properties.ImageVariation = ProductVariation
c.Properties.ImageVariation = ProductVariation
if strings.HasPrefix(variant, ProductVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
c.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
}
squashProductSrcs(m)
squashProductSrcs(c)
}
if c.NeedsVendorPublicLibraryVariants() &&

View file

@ -511,5 +511,5 @@ func (v *CcApiVariant) ExtraImageVariations(ctx android.BaseModuleContext) []str
return variations
}
func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}

View file

@ -241,7 +241,7 @@ func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []stri
return nil
}
func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {

View file

@ -650,7 +650,7 @@ func (x noopImageInterface) VendorRamdiskVariantNeeded(android.BaseModuleContext
func (x noopImageInterface) DebugRamdiskVariantNeeded(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) {
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func NewGenSrcs() *Module {

View file

@ -197,21 +197,20 @@ func (mod *Module) InVendorOrProduct() bool {
return mod.InVendor() || mod.InProduct()
}
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
mod.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
mod.MakeAsPlatform()
} else if strings.HasPrefix(variant, cc.VendorVariation) {
m.Properties.ImageVariation = cc.VendorVariation
mod.Properties.ImageVariation = cc.VendorVariation
if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
}
} else if strings.HasPrefix(variant, cc.ProductVariation) {
m.Properties.ImageVariation = cc.ProductVariation
mod.Properties.ImageVariation = cc.ProductVariation
if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
}
}
}

View file

@ -243,10 +243,8 @@ func (s *ShBinary) ExtraImageVariations(ctx android.BaseModuleContext) []string
return extraVariations
}
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
if m, ok := module.(*ShBinary); ok {
m.properties.ImageVariation = variation
}
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string) {
s.properties.ImageVariation = variation
}
// Overrides ModuleBase.InstallInRamdisk() so that the install rule respects