Dedup prebuilt apis module type/mutator registration
Test: m checkbuild
Bug: 146540677
Change-Id: If5d6fdace2574df6314fbcf6441838cd11df58ae
diff --git a/android/register.go b/android/register.go
index 86943f2..9182f8b 100644
--- a/android/register.go
+++ b/android/register.go
@@ -122,6 +122,7 @@
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) RegisterSingletonType(name string, factory SingletonFactory) {
RegisterSingletonType(name, factory)
}
+
+func (ctx initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
+ PreArchMutators(f)
+}
diff --git a/java/java_test.go b/java/java_test.go
index adc5ad1..1f25962 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -74,13 +74,12 @@
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))
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index 0d5e31f..cb17fee 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -23,9 +23,13 @@
)
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()
})
}