From 74431d57c6bc0a470e974832aa812d88000e3cfa Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 21 Apr 2021 14:10:42 +0100 Subject: Move monolithic stub flags generation to platform_bootclasspath As part of that this change: * Moves code that will be common to platform_bootclasspath and bootclasspath_fragment from hiddenapi_singleton.go into hiddenapi_modular.go. * Fixes the tests in hiddenapi_singleton_test.go but intentionally does not rename them or move them into a more appropriate place so as to make it easier to see the differences. A TODO has been added and these will be cleaned up in a follow up change. Bug: 179354495 Test: verified that the monolithic out/soong/hiddenapi/... files are unchanged by this change Change-Id: I680e4dab2e6bdf4a655fa9f255c195175904667e --- java/platform_bootclasspath.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'java/platform_bootclasspath.go') diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index ba758ddfb..568f5e406 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -140,6 +140,8 @@ func (b *platformBootclasspathModule) OutputFiles(tag string) (android.Paths, er } func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) { + b.hiddenAPIDepsMutator(ctx) + if SkipDexpreoptBootJars(ctx) { return } @@ -149,6 +151,16 @@ func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorCon dexpreopt.RegisterToolDeps(ctx) } +func (b *platformBootclasspathModule) hiddenAPIDepsMutator(ctx android.BottomUpMutatorContext) { + if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { + return + } + + // Add dependencies onto the stub lib modules. + sdkKindToStubLibModules := hiddenAPIComputeMonolithicStubLibModules(ctx.Config()) + hiddenAPIAddStubLibDependencies(ctx, sdkKindToStubLibModules) +} + func platformBootclasspathDepsMutator(ctx android.BottomUpMutatorContext) { m := ctx.Module() if p, ok := m.(*platformBootclasspathModule); ok { @@ -353,10 +365,24 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android. baseFlagsPath := hiddenAPISingletonPaths(ctx).stubFlags ruleToGenerateHiddenApiFlags(ctx, outputPath, baseFlagsPath, moduleSpecificFlagsPaths, flagFileInfo) + b.generateHiddenAPIStubFlagsRules(ctx, hiddenAPISupportingModules) b.generateHiddenAPIIndexRules(ctx, hiddenAPISupportingModules) b.generatedHiddenAPIMetadataRules(ctx, hiddenAPISupportingModules) } +func (b *platformBootclasspathModule) generateHiddenAPIStubFlagsRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { + bootDexJars := android.Paths{} + for _, module := range modules { + bootDexJars = append(bootDexJars, module.bootDexJar()) + } + + sdkKindToStubPaths := hiddenAPIGatherStubLibDexJarPaths(ctx) + + outputPath := hiddenAPISingletonPaths(ctx).stubFlags + rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, outputPath, bootDexJars, sdkKindToStubPaths) + rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags") +} + func (b *platformBootclasspathModule) generateHiddenAPIIndexRules(ctx android.ModuleContext, modules []hiddenAPISupportingModule) { indexes := android.Paths{} for _, module := range modules { -- cgit v1.2.3-59-g8ed1b