Separate creation of signature patterns from overlap checking
Previously, the signatures used to select the subset of the monolithic
flags were simply the signatures read from the modular flags file. This
change moves the creation of the signature list into a separate script
that outputs the signatures to a file and then passes the path through
Soong from the bootclasspath_fragment modules that create it to the
platform_bootclasspath module that uses it to compare the modular
flags against the monolithic flags.
Currently, the signatures are the full signatures but follow up changes
will replace them with patterns (hence the name) that avoids having to
include implementation details in the hidden API flags that are output
as part of a bootclasspath_fragment's snapshot.
This change moves the stub flags related code next to the all flags
related code as they are treated in a similar way.
Bug: 194063708
Test: atest --host verify_overlaps_test signature_patterns_test
m out/soong/hiddenapi/hiddenapi-flags.csv
- manually change files to cause difference in flags to check
that it detects the differences.
Change-Id: I2855bf6d05c91b8a09591664185750361c7e644f
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 107d34a..78b5f0c 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -579,6 +579,14 @@
common := ctx.Module().(commonBootclasspathFragment)
output := common.produceHiddenAPIOutput(ctx, contents, input)
+ // If the source or prebuilts module does not provide a signature patterns file then generate one
+ // from the flags.
+ // TODO(b/192868581): Remove once the source and prebuilts provide a signature patterns file of
+ // their own.
+ if output.SignaturePatternsPath == nil {
+ output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath)
+ }
+
// Initialize a HiddenAPIInfo structure.
hiddenAPIInfo := HiddenAPIInfo{
// The monolithic hidden API processing needs access to the flag files that override the default
@@ -744,9 +752,6 @@
// Flag files by *hiddenAPIFlagFileCategory
Flag_files_by_category FlagFilesByCategory
- // The path to the generated stub-flags.csv file.
- Stub_flags_path android.OptionalPath
-
// The path to the generated annotation-flags.csv file.
Annotation_flags_path android.OptionalPath
@@ -756,6 +761,9 @@
// The path to the generated index.csv file.
Index_path android.OptionalPath
+ // The path to the generated stub-flags.csv file.
+ Stub_flags_path android.OptionalPath
+
// The path to the generated all-flags.csv file.
All_flags_path android.OptionalPath
}
@@ -772,10 +780,11 @@
b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory
// Copy all the generated file paths.
- b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath)
b.Annotation_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AnnotationFlagsPath)
b.Metadata_path = android.OptionalPathForPath(hiddenAPIInfo.MetadataPath)
b.Index_path = android.OptionalPathForPath(hiddenAPIInfo.IndexPath)
+
+ b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath)
b.All_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AllFlagsPath)
// Copy stub_libs properties.
@@ -839,10 +848,10 @@
}
// Copy all the generated files, if available.
- copyOptionalPath(b.Stub_flags_path, "stub_flags")
copyOptionalPath(b.Annotation_flags_path, "annotation_flags")
copyOptionalPath(b.Metadata_path, "metadata")
copyOptionalPath(b.Index_path, "index")
+ copyOptionalPath(b.Stub_flags_path, "stub_flags")
copyOptionalPath(b.All_flags_path, "all_flags")
}
@@ -852,9 +861,6 @@
// specific properties.
type prebuiltBootclasspathFragmentProperties struct {
Hidden_api struct {
- // The path to the stub-flags.csv file created by the bootclasspath_fragment.
- Stub_flags *string `android:"path"`
-
// The path to the annotation-flags.csv file created by the bootclasspath_fragment.
Annotation_flags *string `android:"path"`
@@ -864,6 +870,9 @@
// The path to the index.csv file created by the bootclasspath_fragment.
Index *string `android:"path"`
+ // The path to the stub-flags.csv file created by the bootclasspath_fragment.
+ Stub_flags *string `android:"path"`
+
// The path to the all-flags.csv file created by the bootclasspath_fragment.
All_flags *string `android:"path"`
}