Cleanup ImageInterface.SetImageVariation
This change modifies the interface method of ImageInterface.SetImageVariation so that the image variation is set directly at the caller image variation module, instead of passing the pointer to set the image variation. Test: m nothing Change-Id: I8eadb5149365530243e19a8cd37eb49d335fbeef
This commit is contained in:
parent
71825167e0
commit
7583e835f7
9 changed files with 30 additions and 35 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
27
cc/image.go
27
cc/image.go
|
@ -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() &&
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue