Make defaults TopDownMutator parallel
Append .Parallel() to the defaults RegisterTopDownMutator call to tell Blueprint it can run it in parallel. Saves ~500ms in soong_build. Change-Id: I43ddd9d6995674ccc06fed6928514f15a15712c1
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator).Parallel()
|
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator).Parallel()
|
||||||
RegisterTopDownMutator("defaults", defaultsMutator)
|
RegisterTopDownMutator("defaults", defaultsMutator).Parallel()
|
||||||
|
|
||||||
RegisterBottomUpMutator("arch", ArchMutator).Parallel()
|
RegisterBottomUpMutator("arch", ArchMutator).Parallel()
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ type androidBottomUpMutatorContext struct {
|
|||||||
androidBaseContextImpl
|
androidBaseContextImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) soong.BottomUpMutatorHandle {
|
func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) soong.MutatorHandle {
|
||||||
return soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) {
|
return soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &androidBottomUpMutatorContext{
|
actx := &androidBottomUpMutatorContext{
|
||||||
@@ -56,8 +56,8 @@ func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) soong.
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) {
|
func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) soong.MutatorHandle {
|
||||||
soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) {
|
return soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &androidTopDownMutatorContext{
|
actx := &androidTopDownMutatorContext{
|
||||||
TopDownMutatorContext: ctx,
|
TopDownMutatorContext: ctx,
|
||||||
|
24
register.go
24
register.go
@@ -47,21 +47,23 @@ func RegisterSingletonType(name string, factory blueprint.SingletonFactory) {
|
|||||||
singletons = append(singletons, singleton{name, factory})
|
singletons = append(singletons, singleton{name, factory})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterBottomUpMutator(name string, m blueprint.BottomUpMutator) BottomUpMutatorHandle {
|
func RegisterBottomUpMutator(name string, m blueprint.BottomUpMutator) MutatorHandle {
|
||||||
mutator := &mutator{name: name, bottomUpMutator: m}
|
mutator := &mutator{name: name, bottomUpMutator: m}
|
||||||
mutators = append(mutators, mutator)
|
mutators = append(mutators, mutator)
|
||||||
return mutator
|
return mutator
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterTopDownMutator(name string, m blueprint.TopDownMutator) {
|
func RegisterTopDownMutator(name string, m blueprint.TopDownMutator) MutatorHandle {
|
||||||
mutators = append(mutators, &mutator{name: name, topDownMutator: m})
|
mutator := &mutator{name: name, topDownMutator: m}
|
||||||
|
mutators = append(mutators, mutator)
|
||||||
|
return mutator
|
||||||
}
|
}
|
||||||
|
|
||||||
type BottomUpMutatorHandle interface {
|
type MutatorHandle interface {
|
||||||
Parallel() BottomUpMutatorHandle
|
Parallel() MutatorHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mutator *mutator) Parallel() BottomUpMutatorHandle {
|
func (mutator *mutator) Parallel() MutatorHandle {
|
||||||
mutator.parallel = true
|
mutator.parallel = true
|
||||||
return mutator
|
return mutator
|
||||||
}
|
}
|
||||||
@@ -78,16 +80,16 @@ func NewContext() *blueprint.Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range mutators {
|
for _, t := range mutators {
|
||||||
|
var handle blueprint.MutatorHandle
|
||||||
if t.bottomUpMutator != nil {
|
if t.bottomUpMutator != nil {
|
||||||
handle := ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator)
|
handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator)
|
||||||
|
} else if t.topDownMutator != nil {
|
||||||
|
handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator)
|
||||||
|
}
|
||||||
if t.parallel {
|
if t.parallel {
|
||||||
handle.Parallel()
|
handle.Parallel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.topDownMutator != nil {
|
|
||||||
ctx.RegisterTopDownMutator(t.name, t.topDownMutator)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user