Merge "Cleanup ImageInterface.SetImageVariation" into main
This commit is contained in:
commit
77858402e4
9 changed files with 30 additions and 35 deletions
|
@ -44,9 +44,8 @@ type ImageInterface interface {
|
||||||
ExtraImageVariations(ctx BaseModuleContext) []string
|
ExtraImageVariations(ctx BaseModuleContext) []string
|
||||||
|
|
||||||
// SetImageVariation is called for each newly created image variant. The receiver is the original
|
// 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
|
// module, "variation" is the name of the newly created variant. "variation" is set on the receiver.
|
||||||
// variant itself.
|
SetImageVariation(ctx BaseModuleContext, variation string)
|
||||||
SetImageVariation(ctx BaseModuleContext, variation string, module Module)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -106,7 +105,7 @@ func imageMutator(ctx BottomUpMutatorContext) {
|
||||||
mod := ctx.CreateVariations(variations...)
|
mod := ctx.CreateVariations(variations...)
|
||||||
for i, v := range variations {
|
for i, v := range variations {
|
||||||
mod[i].base().setImageVariation(v)
|
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
|
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"
|
bpf.properties.VendorInternal = variation == "vendor"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,5 +114,5 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
|
||||||
return variants
|
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) {
|
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
|
||||||
m := module.(*Module)
|
|
||||||
if variant == android.RamdiskVariation {
|
if variant == android.RamdiskVariation {
|
||||||
m.MakeAsPlatform()
|
c.MakeAsPlatform()
|
||||||
squashRamdiskSrcs(m)
|
squashRamdiskSrcs(c)
|
||||||
} else if variant == android.VendorRamdiskVariation {
|
} else if variant == android.VendorRamdiskVariation {
|
||||||
m.MakeAsPlatform()
|
c.MakeAsPlatform()
|
||||||
squashVendorRamdiskSrcs(m)
|
squashVendorRamdiskSrcs(c)
|
||||||
} else if variant == android.RecoveryVariation {
|
} else if variant == android.RecoveryVariation {
|
||||||
m.MakeAsPlatform()
|
c.MakeAsPlatform()
|
||||||
squashRecoverySrcs(m)
|
squashRecoverySrcs(c)
|
||||||
} else if strings.HasPrefix(variant, VendorVariation) {
|
} else if strings.HasPrefix(variant, VendorVariation) {
|
||||||
m.Properties.ImageVariation = VendorVariation
|
c.Properties.ImageVariation = VendorVariation
|
||||||
|
|
||||||
if strings.HasPrefix(variant, VendorVariationPrefix) {
|
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) {
|
} else if strings.HasPrefix(variant, ProductVariation) {
|
||||||
m.Properties.ImageVariation = ProductVariation
|
c.Properties.ImageVariation = ProductVariation
|
||||||
if strings.HasPrefix(variant, ProductVariationPrefix) {
|
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() &&
|
if c.NeedsVendorPublicLibraryVariants() &&
|
||||||
|
|
|
@ -511,5 +511,5 @@ func (v *CcApiVariant) ExtraImageVariations(ctx android.BaseModuleContext) []str
|
||||||
|
|
||||||
return variations
|
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
|
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 {
|
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) DebugRamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
|
||||||
func (x noopImageInterface) RecoveryVariantNeeded(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) 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 {
|
func NewGenSrcs() *Module {
|
||||||
|
|
|
@ -197,21 +197,20 @@ func (mod *Module) InVendorOrProduct() bool {
|
||||||
return mod.InVendor() || mod.InProduct()
|
return mod.InVendor() || mod.InProduct()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
|
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
|
||||||
m := module.(*Module)
|
|
||||||
if variant == android.VendorRamdiskVariation {
|
if variant == android.VendorRamdiskVariation {
|
||||||
m.MakeAsPlatform()
|
mod.MakeAsPlatform()
|
||||||
} else if variant == android.RecoveryVariation {
|
} else if variant == android.RecoveryVariation {
|
||||||
m.MakeAsPlatform()
|
mod.MakeAsPlatform()
|
||||||
} else if strings.HasPrefix(variant, cc.VendorVariation) {
|
} else if strings.HasPrefix(variant, cc.VendorVariation) {
|
||||||
m.Properties.ImageVariation = cc.VendorVariation
|
mod.Properties.ImageVariation = cc.VendorVariation
|
||||||
if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
|
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) {
|
} else if strings.HasPrefix(variant, cc.ProductVariation) {
|
||||||
m.Properties.ImageVariation = cc.ProductVariation
|
mod.Properties.ImageVariation = cc.ProductVariation
|
||||||
if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
|
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
|
return extraVariations
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
|
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string) {
|
||||||
if m, ok := module.(*ShBinary); ok {
|
s.properties.ImageVariation = variation
|
||||||
m.properties.ImageVariation = variation
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overrides ModuleBase.InstallInRamdisk() so that the install rule respects
|
// Overrides ModuleBase.InstallInRamdisk() so that the install rule respects
|
||||||
|
|
Loading…
Reference in a new issue