From d061d40eb6ffbc9d7cece2945b7276fe2f6759d1 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 7 Jun 2021 21:36:01 +0100 Subject: Fix monolithic hidden API processing with prebuilts Prebuilt modules do not provide classesJars containing annotations. Previously, the monolithic hidden API processing just used classesJars from all the modules that provided them so when building against prebuilts would have fewer classesJars than when building against sources and so would produce different hidden API flags. This change will generate the monolithic files from both classesJars and files previously generated from hidden API processing. A fragment that has performed hidden API processing will contribute its generated files whereas standalone libraries and fragments which have not performed hidden API processing will contribute classesJars. Bug: 177892522 Test: m out/soong/hiddenapi/hiddenapi-flags.csv m SOONG_CONFIG_art_module_source_build=false out/soong/hiddenapi/hiddenapi-flags.csv - verify that the files are identical whether built from source or prebuilts. Change-Id: I06f3c7df49626bec21a452bc9abf1bb9e7545e5c --- java/platform_bootclasspath.go | 52 +++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'java/platform_bootclasspath.go') diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 3f5c94067..cd00c19a2 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -302,28 +302,48 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android. rule.Build("platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags") // 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) - - // Generate the monotlithic hiddenapi-flags.csv file. + annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags-from-classes.csv") + buildRuleToGenerateAnnotationFlags(ctx, "intermediate hidden API flags", classesJars, stubFlags, annotationFlags) + + // 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) - - // 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. + intermediateMetadataCSV := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "metadata-from-classes.csv") + buildRuleToGenerateMetadata(ctx, "intermediate hidden API metadata", classesJars, stubFlags, intermediateMetadataCSV) + + // 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) - - // Generate the monolithic hiddenapi-index.csv file directly from the CSV files in the classes - // jars. + b.buildRuleMergeCSV(ctx, "monolithic hidden API metadata", allMetadataFlagFiles, metadataCSV) + + // 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 } -- cgit v1.2.3-59-g8ed1b