summaryrefslogtreecommitdiff
path: root/java/platform_bootclasspath.go
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2021-07-07 17:54:01 +0000
committerScott Lobdell <slobdell@google.com>2021-07-07 17:54:01 +0000
commit99f82c6f4a8511ded6de5e2b5e00565fad7f65de (patch)
treea1ecabe68c443bf3d596fe06417e98cc54dc7470 /java/platform_bootclasspath.go
parentc57cdd121a8d5a0883a689f6d9fbe6fc440e2202 (diff)
parent5abcf9267173b9e80dd14fca037b0f01cc2dbd3b (diff)
Merge SP1A.210624.001
Change-Id: I8507f8b65c47a5b425464bbbc8d932a6ca359fd3
Diffstat (limited to 'java/platform_bootclasspath.go')
-rw-r--r--java/platform_bootclasspath.go81
1 files changed, 53 insertions, 28 deletions
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index fba73d0c1..7b651baff 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -44,13 +44,9 @@ type platformBootclasspathModule struct {
properties platformBootclasspathProperties
// The apex:module pairs obtained from the configured modules.
- //
- // Currently only for testing.
configuredModules []android.Module
// The apex:module pairs obtained from the fragments.
- //
- // Currently only for testing.
fragments []android.Module
// Path to the monolithic hiddenapi-flags.csv file.
@@ -189,7 +185,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
b.generateClasspathProtoBuildActions(ctx)
- b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
+ bootDexJarByModule := b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
+ buildRuleForBootJarsPackageCheck(ctx, bootDexJarByModule)
// Nothing to do if skipping the dexpreopt of boot image jars.
if SkipDexpreoptBootJars(ctx) {
@@ -258,13 +255,15 @@ func (b *platformBootclasspathModule) getImageConfig(ctx android.EarlyModuleCont
}
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
-func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) {
+func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, modules []android.Module, fragments []android.Module) bootDexJarByModule {
// Save the paths to the monolithic files for retrieval via OutputFiles().
b.hiddenAPIFlagsCSV = hiddenAPISingletonPaths(ctx).flags
b.hiddenAPIIndexCSV = hiddenAPISingletonPaths(ctx).index
b.hiddenAPIMetadataCSV = hiddenAPISingletonPaths(ctx).metadata
+ bootDexJarByModule := extractBootDexJarsFromModules(ctx, modules)
+
// Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. This is a performance
// optimization that can be used to reduce the incremental build time but as its name suggests it
// can be unsafe to use, e.g. when the changes affect anything that goes on the bootclasspath.
@@ -276,10 +275,18 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
Output: path,
})
}
- return
+ return bootDexJarByModule
}
- monolithicInfo := b.createAndProvideMonolithicHiddenAPIInfo(ctx, fragments)
+ // Construct a list of ClasspathElement objects from the modules and fragments.
+ classpathElements := CreateClasspathElements(ctx, modules, fragments)
+
+ monolithicInfo := b.createAndProvideMonolithicHiddenAPIInfo(ctx, classpathElements)
+
+ // Extract the classes jars only from those libraries that do not have corresponding fragments as
+ // the fragments will have already provided the flags that are needed.
+ classesJars := monolithicInfo.ClassesJars
+
// Create the input to pass to ruleToGenerateHiddenAPIStubFlagsFile
input := newHiddenAPIFlagInput()
@@ -291,42 +298,60 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
input.FlagFilesByCategory = monolithicInfo.FlagsFilesByCategory
// Generate the monolithic stub-flags.csv file.
- bootDexJars := extractBootDexJarsFromModules(ctx, modules)
stubFlags := hiddenAPISingletonPaths(ctx).stubFlags
- rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, stubFlags, bootDexJars, input)
+ rule := ruleToGenerateHiddenAPIStubFlagsFile(ctx, stubFlags, bootDexJarByModule.bootDexJars(), input)
rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags")
- // Extract the classes jars from the contents.
- classesJars := extractClassesJarsFromModules(modules)
-
// Generate the annotation-flags.csv file from all the module annotations.
- annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags.csv")
- buildRuleToGenerateAnnotationFlags(ctx, "monolithic hiddenapi flags", classesJars, stubFlags, annotationFlags)
+ annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags-from-classes.csv")
+ buildRuleToGenerateAnnotationFlags(ctx, "intermediate hidden API flags", classesJars, stubFlags, annotationFlags)
- // Generate the monotlithic hiddenapi-flags.csv file.
+ // Generate the monolithic hiddenapi-flags.csv file.
+ //
+ // Use annotation flags generated directly from the classes jars as well as annotation flag files
+ // provided by prebuilts.
+ allAnnotationFlagFiles := android.Paths{annotationFlags}
+ allAnnotationFlagFiles = append(allAnnotationFlagFiles, monolithicInfo.AnnotationFlagsPaths...)
allFlags := hiddenAPISingletonPaths(ctx).flags
- buildRuleToGenerateHiddenApiFlags(ctx, "hiddenAPIFlagsFile", "hiddenapi flags", allFlags, stubFlags, annotationFlags, monolithicInfo.FlagsFilesByCategory, monolithicInfo.AllFlagsPaths, android.OptionalPath{})
+ buildRuleToGenerateHiddenApiFlags(ctx, "hiddenAPIFlagsFile", "monolithic hidden API flags", allFlags, stubFlags, allAnnotationFlagFiles, monolithicInfo.FlagsFilesByCategory, monolithicInfo.AllFlagsPaths, android.OptionalPath{})
// Generate an intermediate monolithic hiddenapi-metadata.csv file directly from the annotations
// in the source code.
- intermediateMetadataCSV := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "intermediate-metadata.csv")
- buildRuleToGenerateMetadata(ctx, "monolithic hidden API metadata", classesJars, stubFlags, intermediateMetadataCSV)
+ intermediateMetadataCSV := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "metadata-from-classes.csv")
+ buildRuleToGenerateMetadata(ctx, "intermediate hidden API metadata", classesJars, stubFlags, intermediateMetadataCSV)
- // Reformat the intermediate file to add | quotes just in case that is important for the tools
- // that consume the metadata file.
- // TODO(b/179354495): Investigate whether it is possible to remove this reformatting step.
+ // Generate the monolithic hiddenapi-metadata.csv file.
+ //
+ // Use metadata files generated directly from the classes jars as well as metadata files provided
+ // by prebuilts.
+ //
+ // This has the side effect of ensuring that the output file uses | quotes just in case that is
+ // important for the tools that consume the metadata file.
+ allMetadataFlagFiles := android.Paths{intermediateMetadataCSV}
+ allMetadataFlagFiles = append(allMetadataFlagFiles, monolithicInfo.MetadataPaths...)
metadataCSV := hiddenAPISingletonPaths(ctx).metadata
- b.buildRuleMergeCSV(ctx, "reformat monolithic hidden API metadata", android.Paths{intermediateMetadataCSV}, metadataCSV)
+ b.buildRuleMergeCSV(ctx, "monolithic hidden API metadata", allMetadataFlagFiles, metadataCSV)
- // Generate the monolithic hiddenapi-index.csv file directly from the CSV files in the classes
- // jars.
+ // Generate an intermediate monolithic hiddenapi-index.csv file directly from the CSV files in the
+ // classes jars.
+ intermediateIndexCSV := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "index-from-classes.csv")
+ buildRuleToGenerateIndex(ctx, "intermediate hidden API index", classesJars, intermediateIndexCSV)
+
+ // Generate the monolithic hiddenapi-index.csv file.
+ //
+ // Use index files generated directly from the classes jars as well as index files provided
+ // by prebuilts.
+ allIndexFlagFiles := android.Paths{intermediateIndexCSV}
+ allIndexFlagFiles = append(allIndexFlagFiles, monolithicInfo.IndexPaths...)
indexCSV := hiddenAPISingletonPaths(ctx).index
- buildRuleToGenerateIndex(ctx, "monolithic hidden API index", classesJars, indexCSV)
+ b.buildRuleMergeCSV(ctx, "monolithic hidden API index", allIndexFlagFiles, indexCSV)
+
+ return bootDexJarByModule
}
// createAndProvideMonolithicHiddenAPIInfo creates a MonolithicHiddenAPIInfo and provides it for
// testing.
-func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ctx android.ModuleContext, fragments []android.Module) MonolithicHiddenAPIInfo {
+func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ctx android.ModuleContext, classpathElements ClasspathElements) MonolithicHiddenAPIInfo {
// Create a temporary input structure in which to collate information provided directly by this
// module, either through properties or direct dependencies.
temporaryInput := newHiddenAPIFlagInput()
@@ -336,7 +361,7 @@ func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ct
// Create the monolithic info, by starting with the flag files specified on this and then merging
// in information from all the fragment dependencies of this.
- monolithicInfo := newMonolithicHiddenAPIInfo(ctx, temporaryInput.FlagFilesByCategory, fragments)
+ monolithicInfo := newMonolithicHiddenAPIInfo(ctx, temporaryInput.FlagFilesByCategory, classpathElements)
// Store the information for testing.
ctx.SetProvider(MonolithicHiddenAPIInfoProvider, monolithicInfo)