Dedup system modules and sdk library module type registration
Test: m checkbuild
Bug: 146540677
Change-Id: I982fcb8d723e8e2f7679434051ddc427d4fbd7be
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 1840900..bb6e026 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -305,7 +305,7 @@
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
java.RegisterJavaBuildComponents(ctx)
- ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory)
+ java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
diff --git a/java/java_test.go b/java/java_test.go
index d9a43f5..adc5ad1 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -67,14 +67,13 @@
RegisterAppBuildComponents(ctx)
RegisterAARBuildComponents(ctx)
RegisterGenRuleBuildComponents(ctx)
- ctx.RegisterModuleType("java_system_modules", SystemModulesFactory)
+ RegisterSystemModulesBuildComponents(ctx)
ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
- ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
- ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
+ RegisterSdkLibraryBuildComponents(ctx)
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index e204659..32b2d1a 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -68,8 +68,7 @@
// 2) HTML generation
func init() {
- android.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
- android.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
+ RegisterSdkLibraryBuildComponents(android.InitRegistrationContext)
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
javaSdkLibraries := javaSdkLibraries(ctx.Config())
@@ -78,6 +77,11 @@
})
}
+func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
+ ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
+}
+
type sdkLibraryProperties struct {
// List of Java libraries that will be in the classpath when building stubs
Stub_only_libs []string `android:"arch_variant"`
diff --git a/java/system_modules.go b/java/system_modules.go
index b56a401..ed2fc18 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -28,11 +28,15 @@
// system modules in a runtime image using the jmod and jlink tools.
func init() {
- android.RegisterModuleType("java_system_modules", SystemModulesFactory)
+ RegisterSystemModulesBuildComponents(android.InitRegistrationContext)
pctx.SourcePathVariable("moduleInfoJavaPath", "build/soong/scripts/jars-to-module-info-java.sh")
}
+func RegisterSystemModulesBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("java_system_modules", SystemModulesFactory)
+}
+
var (
jarsTosystemModules = pctx.AndroidStaticRule("jarsTosystemModules", blueprint.RuleParams{
Command: `rm -rf ${outDir} ${workDir} && mkdir -p ${workDir}/jmod && ` +
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index d44f4cf..d24262d 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -58,7 +58,8 @@
ctx := android.NewTestArchContext()
java.RegisterJavaBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
- ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory)
+ java.RegisterSystemModulesBuildComponents(ctx)
+
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)