Convert trivial TopDown mutators to BottomUp
Many TopDown mutators can be easily converted to BottomUp mutators, which are easier to handle for incremental and partial analysis. Bug: 367784740 Test: all soong tests pass Test: no change to build.ninja Flag: EXEMPT refactor Change-Id: I82955e844ed0eb6680854678c0744ac5398eb7ba
This commit is contained in:
@@ -193,16 +193,16 @@ type BaseMutatorContext interface {
|
||||
// Rename all variants of a module. The new name is not visible to calls to ModuleName,
|
||||
// AddDependency or OtherModuleName until after this mutator pass is complete.
|
||||
Rename(name string)
|
||||
|
||||
// CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
|
||||
// the specified property structs to it as if the properties were set in a blueprint file.
|
||||
CreateModule(ModuleFactory, ...interface{}) Module
|
||||
}
|
||||
|
||||
type TopDownMutator func(TopDownMutatorContext)
|
||||
|
||||
type TopDownMutatorContext interface {
|
||||
BaseMutatorContext
|
||||
|
||||
// CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
|
||||
// the specified property structs to it as if the properties were set in a blueprint file.
|
||||
CreateModule(ModuleFactory, ...interface{}) Module
|
||||
}
|
||||
|
||||
type topDownMutatorContext struct {
|
||||
@@ -739,6 +739,14 @@ func (b *bottomUpMutatorContext) Rename(name string) {
|
||||
b.Module().base().commonProperties.DebugName = name
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module {
|
||||
return b.bp.CreateModule(factory, name, props...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module {
|
||||
return createModule(b, factory, "_bottomUpMutatorModule", props...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module {
|
||||
if b.baseModuleContext.checkedMissingDeps() {
|
||||
panic("Adding deps not allowed after checking for missing deps")
|
||||
|
Reference in New Issue
Block a user