Dedup system modules and sdk library module type registration

Test: m checkbuild
Bug: 146540677
Change-Id: I982fcb8d723e8e2f7679434051ddc427d4fbd7be
This commit is contained in:
Paul Duffin 2019-12-19 11:18:54 +00:00
parent b0f850784a
commit 43dc1cc2bc
5 changed files with 16 additions and 8 deletions

View File

@ -305,7 +305,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory) ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
java.RegisterJavaBuildComponents(ctx) java.RegisterJavaBuildComponents(ctx)
ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory) java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx) java.RegisterAppBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)

View File

@ -67,14 +67,13 @@ func testContext() *android.TestContext {
RegisterAppBuildComponents(ctx) RegisterAppBuildComponents(ctx)
RegisterAARBuildComponents(ctx) RegisterAARBuildComponents(ctx)
RegisterGenRuleBuildComponents(ctx) RegisterGenRuleBuildComponents(ctx)
ctx.RegisterModuleType("java_system_modules", SystemModulesFactory) RegisterSystemModulesBuildComponents(ctx)
ctx.RegisterModuleType("java_plugin", PluginFactory) ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory) ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
RegisterDocsBuildComponents(ctx) RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx) RegisterStubsBuildComponents(ctx)
ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory) RegisterSdkLibraryBuildComponents(ctx)
ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory) ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)

View File

@ -68,8 +68,7 @@ var (
// 2) HTML generation // 2) HTML generation
func init() { func init() {
android.RegisterModuleType("java_sdk_library", SdkLibraryFactory) RegisterSdkLibraryBuildComponents(android.InitRegistrationContext)
android.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
javaSdkLibraries := javaSdkLibraries(ctx.Config()) javaSdkLibraries := javaSdkLibraries(ctx.Config())
@ -78,6 +77,11 @@ func init() {
}) })
} }
func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
}
type sdkLibraryProperties struct { type sdkLibraryProperties struct {
// List of Java libraries that will be in the classpath when building stubs // List of Java libraries that will be in the classpath when building stubs
Stub_only_libs []string `android:"arch_variant"` Stub_only_libs []string `android:"arch_variant"`

View File

@ -28,11 +28,15 @@ import (
// system modules in a runtime image using the jmod and jlink tools. // system modules in a runtime image using the jmod and jlink tools.
func init() { func init() {
android.RegisterModuleType("java_system_modules", SystemModulesFactory) RegisterSystemModulesBuildComponents(android.InitRegistrationContext)
pctx.SourcePathVariable("moduleInfoJavaPath", "build/soong/scripts/jars-to-module-info-java.sh") pctx.SourcePathVariable("moduleInfoJavaPath", "build/soong/scripts/jars-to-module-info-java.sh")
} }
func RegisterSystemModulesBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("java_system_modules", SystemModulesFactory)
}
var ( var (
jarsTosystemModules = pctx.AndroidStaticRule("jarsTosystemModules", blueprint.RuleParams{ jarsTosystemModules = pctx.AndroidStaticRule("jarsTosystemModules", blueprint.RuleParams{
Command: `rm -rf ${outDir} ${workDir} && mkdir -p ${workDir}/jmod && ` + Command: `rm -rf ${outDir} ${workDir} && mkdir -p ${workDir}/jmod && ` +

View File

@ -58,7 +58,8 @@ func testContext(config android.Config) *android.TestContext {
ctx := android.NewTestArchContext() ctx := android.NewTestArchContext()
java.RegisterJavaBuildComponents(ctx) java.RegisterJavaBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx) java.RegisterAppBuildComponents(ctx)
ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory) java.RegisterSystemModulesBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)