diff options
author | 2019-11-18 16:00:16 -0800 | |
---|---|---|
committer | 2019-11-20 15:21:32 -0800 | |
commit | 7228ecd5e3c9282e7e6f4a81d81fd333cb08eaff (patch) | |
tree | b08a1652d573a01819c7937ad22659429f50578f /cc/genrule.go | |
parent | 43b92e0d0f477e2ae9f3c3e07696e2d1760b7d84 (diff) |
Move cc.imageMutator into the android package
Prepare for making the image mutator available to all modules and
moving it between the os and arch mutators by moving it into the
android package and using an interface implemented by the module
types to control it.
Bug: 142286466
Test: No unexpected changes to out/soong/build.ninja
Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
Diffstat (limited to 'cc/genrule.go')
-rw-r--r-- | cc/genrule.go | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/cc/genrule.go b/cc/genrule.go index e594f4b2f..e74dd4d72 100644 --- a/cc/genrule.go +++ b/cc/genrule.go @@ -26,9 +26,6 @@ func init() { type GenruleExtraProperties struct { Vendor_available *bool Recovery_available *bool - - // This genrule is for recovery variant - InRecovery bool `blueprint:"mutated"` } // cc_genrule is a genrule that can depend on other cc_* objects. @@ -37,7 +34,9 @@ type GenruleExtraProperties struct { func genRuleFactory() android.Module { module := genrule.NewGenRule() - module.Extra = &GenruleExtraProperties{} + extra := &GenruleExtraProperties{} + module.Extra = extra + module.ImageInterface = extra module.AddProperties(module.Extra) android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibBoth) @@ -46,3 +45,44 @@ func genRuleFactory() android.Module { return module } + +var _ android.ImageInterface = (*GenruleExtraProperties)(nil) + +func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {} + +func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool { + if ctx.DeviceConfig().VndkVersion() == "" { + return true + } + + return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific()) +} + +func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { + if Bool(g.Recovery_available) { + primaryArch := ctx.Config().DevicePrimaryArchType() + moduleArch := ctx.Target().Arch.ArchType + return moduleArch == primaryArch + } + return false +} + +func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string { + if ctx.DeviceConfig().VndkVersion() == "" { + return nil + } + + if Bool(g.Vendor_available) || ctx.SocSpecific() || ctx.DeviceSpecific() { + var variants []string + variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion()) + if vndkVersion := ctx.DeviceConfig().VndkVersion(); vndkVersion != "current" { + variants = append(variants, VendorVariationPrefix+vndkVersion) + } + return variants + } + + return nil +} + +func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { +} |