Enable goma in soong

When the UseGoma flag is set, put all rules except the C compilation
rule in an externally defined local_pool, which will have been created
by kati.  The gomacc wrapper will already be in the CC_WRAPPER
environment variable.

Bug: 31142427
Change-Id: I699d4edff2e302eee398dad8692ceb14721a628c
This commit is contained in:
Colin Cross
2016-08-29 16:14:13 -07:00
parent 3cfaba1654
commit 9d45bb78c5
11 changed files with 74 additions and 34 deletions

View File

@@ -131,3 +131,35 @@ func (p AndroidPackageContext) PrefixedPathsForOptionalSourceVariable(
return JoinWithPrefix(paths.Strings(), prefix), nil
})
}
type RuleParams struct {
blueprint.RuleParams
GomaSupported bool
}
// AndroidStaticRule wraps blueprint.StaticRule and provides a default Pool if none is specified
func (p AndroidPackageContext) AndroidStaticRule(name string, params blueprint.RuleParams,
argNames ...string) blueprint.Rule {
return p.AndroidRuleFunc(name, func(interface{}) (blueprint.RuleParams, error) {
return params, nil
}, argNames...)
}
// AndroidGomaStaticRule wraps blueprint.StaticRule but uses goma's parallelism if goma is enabled
func (p AndroidPackageContext) AndroidGomaStaticRule(name string, params blueprint.RuleParams,
argNames ...string) blueprint.Rule {
return p.StaticRule(name, params, argNames...)
}
func (p AndroidPackageContext) AndroidRuleFunc(name string,
f func(interface{}) (blueprint.RuleParams, error), argNames ...string) blueprint.Rule {
return p.PackageContext.RuleFunc(name, func(config interface{}) (blueprint.RuleParams, error) {
params, err := f(config)
if config.(Config).UseGoma() && params.Pool == nil {
// When USE_GOMA=true is set and the rule is not supported by goma, restrict jobs to the
// local parallelism value
params.Pool = localPool
}
return params, err
}, argNames...)
}