Dedup prebuilt apis module type/mutator registration

Test: m checkbuild
Bug: 146540677
Change-Id: If5d6fdace2574df6314fbcf6441838cd11df58ae
This commit is contained in:
Paul Duffin
2019-12-19 11:25:19 +00:00
parent 43dc1cc2bc
commit a48f758d84
3 changed files with 14 additions and 6 deletions

View File

@@ -122,6 +122,7 @@ func ModuleTypeFactories() map[string]ModuleFactory {
type RegistrationContext interface {
RegisterModuleType(name string, factory ModuleFactory)
RegisterSingletonType(name string, factory SingletonFactory)
PreArchMutators(f RegisterMutatorFunc)
}
// Used to register build components from an init() method, e.g.
@@ -154,3 +155,7 @@ func (ctx initRegistrationContext) RegisterModuleType(name string, factory Modul
func (ctx initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {
RegisterSingletonType(name, factory)
}
func (ctx initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
PreArchMutators(f)
}

View File

@@ -74,13 +74,12 @@ func testContext() *android.TestContext {
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
RegisterSdkLibraryBuildComponents(ctx)
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
})
RegisterPrebuiltApisBuildComponents(ctx)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(OverlaySingletonFactory))
ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(sdkPreSingletonFactory))

View File

@@ -23,9 +23,13 @@ import (
)
func init() {
android.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
RegisterPrebuiltApisBuildComponents(android.InitRegistrationContext)
}
android.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
func RegisterPrebuiltApisBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
})
}