diff --git a/java/bootclasspath.go b/java/bootclasspath.go index b140a3080..6ca0f7533 100644 --- a/java/bootclasspath.go +++ b/java/bootclasspath.go @@ -24,6 +24,33 @@ import ( // Contains code that is common to both platform_bootclasspath and bootclasspath_fragment. +func init() { + registerBootclasspathBuildComponents(android.InitRegistrationContext) +} + +func registerBootclasspathBuildComponents(ctx android.RegistrationContext) { + ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) { + ctx.BottomUp("bootclasspath_deps", bootclasspathDepsMutator) + }) +} + +// BootclasspathDepsMutator is the interface that a module must implement if it wants to add +// dependencies onto APEX specific variants of bootclasspath fragments or bootclasspath contents. +type BootclasspathDepsMutator interface { + // BootclasspathDepsMutator implementations should add dependencies using + // addDependencyOntoApexModulePair and addDependencyOntoApexVariants. + BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) +} + +// bootclasspathDepsMutator is called during the final deps phase after all APEX variants have +// been created so can add dependencies onto specific APEX variants of modules. +func bootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { + m := ctx.Module() + if p, ok := m.(BootclasspathDepsMutator); ok { + p.BootclasspathDepsMutator(ctx) + } +} + // addDependencyOntoApexVariants adds dependencies onto the appropriate apex specific variants of // the module as specified in the ApexVariantReference list. func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyName string, refs []ApexVariantReference, tag blueprint.DependencyTag) { diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 38ce98525..b1a0ac43f 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -27,10 +27,6 @@ func init() { func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("platform_bootclasspath", platformBootclasspathFactory) - - ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) { - ctx.BottomUp("platform_bootclasspath_deps", platformBootclasspathDepsMutator) - }) } // The tag used for the dependency between the platform bootclasspath and any configured boot jars. @@ -126,25 +122,22 @@ func (b *platformBootclasspathModule) hiddenAPIDepsMutator(ctx android.BottomUpM hiddenAPIAddStubLibDependencies(ctx, sdkKindToStubLibModules) } -func platformBootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { - m := ctx.Module() - if p, ok := m.(*platformBootclasspathModule); ok { - // Add dependencies on all the modules configured in the "art" boot image. - artImageConfig := genBootImageConfigs(ctx)[artBootImageName] - addDependenciesOntoBootImageModules(ctx, artImageConfig.modules) +func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { + // Add dependencies on all the modules configured in the "art" boot image. + artImageConfig := genBootImageConfigs(ctx)[artBootImageName] + addDependenciesOntoBootImageModules(ctx, artImageConfig.modules) - // Add dependencies on all the modules configured in the "boot" boot image. That does not - // include modules configured in the "art" boot image. - bootImageConfig := p.getImageConfig(ctx) - addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules) + // Add dependencies on all the modules configured in the "boot" boot image. That does not + // include modules configured in the "art" boot image. + bootImageConfig := b.getImageConfig(ctx) + addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules) - // Add dependencies on all the updatable modules. - updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars - addDependenciesOntoBootImageModules(ctx, updatableModules) + // Add dependencies on all the updatable modules. + updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + addDependenciesOntoBootImageModules(ctx, updatableModules) - // Add dependencies on all the fragments. - p.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) - } + // Add dependencies on all the fragments. + b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) } func addDependenciesOntoBootImageModules(ctx android.BottomUpMutatorContext, modules android.ConfiguredJarList) { diff --git a/java/testing.go b/java/testing.go index 08a71b880..e9cdddc53 100644 --- a/java/testing.go +++ b/java/testing.go @@ -232,6 +232,7 @@ func registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) { RegisterAppBuildComponents(ctx) RegisterAppImportBuildComponents(ctx) RegisterAppSetBuildComponents(ctx) + registerBootclasspathBuildComponents(ctx) RegisterBootImageBuildComponents(ctx) RegisterDexpreoptBootJarsComponents(ctx) RegisterDocsBuildComponents(ctx)