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/scripts/hiddenapi/verify_overlaps.py b/scripts/hiddenapi/verify_overlaps.py
index fe4e359..8579321 100755
--- a/scripts/hiddenapi/verify_overlaps.py
+++ b/scripts/hiddenapi/verify_overlaps.py
@@ -24,16 +24,30 @@
def dict_reader(input):
return csv.DictReader(input, delimiter=',', quotechar='|', fieldnames=['signature'])
-def extract_subset_from_monolithic_flags_as_dict(monolithicFlagsDict, signatures):
+def extract_subset_from_monolithic_flags_as_dict_from_file(monolithicFlagsDict, patternsFile):
"""
Extract a subset of flags from the dict containing all the monolithic flags.
:param monolithicFlagsDict: the dict containing all the monolithic flags.
- :param signatures: a list of signature that define the subset.
+ :param patternsFile: a file containing a list of signature patterns that
+ define the subset.
+ :return: the dict from signature to row.
+ """
+ with open(patternsFile, 'r') as stream:
+ return extract_subset_from_monolithic_flags_as_dict_from_stream(monolithicFlagsDict, stream)
+
+def extract_subset_from_monolithic_flags_as_dict_from_stream(monolithicFlagsDict, stream):
+ """
+ Extract a subset of flags from the dict containing all the monolithic flags.
+
+ :param monolithicFlagsDict: the dict containing all the monolithic flags.
+ :param stream: a stream containing a list of signature patterns that define
+ the subset.
:return: the dict from signature to row.
"""
dict = {}
- for signature in signatures:
+ for signature in stream:
+ signature = signature.rstrip()
dict[signature] = monolithicFlagsDict.get(signature, {})
return dict
@@ -102,9 +116,12 @@
# provided by the subset and the corresponding flags from the complete set of
# flags and compare them.
failed = False
- for modularFlagsPath in args.modularFlags:
+ for modularPair in args.modularFlags:
+ parts = modularPair.split(":")
+ modularFlagsPath = parts[0]
+ modularPatternsPath = parts[1]
modularFlagsDict = read_signature_csv_from_file_as_dict(modularFlagsPath)
- monolithicFlagsSubsetDict = extract_subset_from_monolithic_flags_as_dict(monolithicFlagsDict, modularFlagsDict.keys())
+ monolithicFlagsSubsetDict = extract_subset_from_monolithic_flags_as_dict_from_file(monolithicFlagsDict, modularPatternsPath)
mismatchingSignatures = compare_signature_flags(monolithicFlagsSubsetDict, modularFlagsDict)
if mismatchingSignatures:
failed = True