diff options
-rw-r--r-- | golden/vndk_data.py | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/golden/vndk_data.py b/golden/vndk_data.py index 3dbcd22..bb1a8d7 100644 --- a/golden/vndk_data.py +++ b/golden/vndk_data.py @@ -137,32 +137,51 @@ def GetAbiDumpPathsFromResources(version, binder_bitness, abi_name, abi_bitness) return dump_paths -def _LoadVndkLibraryListsFile(vndk_lists, tags, vndk_lib_list_file): +def _LoadVndkLibraryListsFile(vndk_lists, tags, vndk_lib_list_file, + change_history_file=None): """Load VNDK libraries from the file to the specified tuple. Args: vndk_lists: The output tuple of lists containing library names. tags: Strings, the tags of the libraries to find. vndk_lib_list_file: The file object containing the VNDK library list. + change_history_file: The file object containing the VNDK list change + history. It adds the vndk files that are removed. """ - - lib_sets = collections.defaultdict(set) - - # Load VNDK tags from the list. - for line in vndk_lib_list_file: + def ReadTagAndFile(line): # Ignore comments. if line.startswith('#'): - continue + return None, None # Split columns. cells = line.split(': ', 1) if len(cells) < 2: - continue - tag = cells[0] - lib_name = cells[1].strip() + return None, None + return cells[0].strip(), cells[1].strip() + lib_sets = collections.defaultdict(set) + + # Load VNDK tags from the list. + for line in vndk_lib_list_file: + tag, lib_name = ReadTagAndFile(line) + if not tag: + continue lib_sets[tag].add(lib_name) + if change_history_file: + for line in change_history_file: + tag, lib_name = ReadTagAndFile(line) + if not tag: + continue + + # In the history file, tag has '+' prefix if the file is added and + # '-' prefix if removed. + # To relax the test, include the removed files to the list. + if tag[0] != '-': + continue + tag = tag[1:] + lib_sets[tag].add(lib_name) + # Compute VNDK-core-private and VNDK-SP-private. private = lib_sets.get('VNDK-private', set()) @@ -204,6 +223,9 @@ def LoadVndkLibraryListsFromResources(version, *tags): vndk_lib_list_name = version_str + ".txt" vndk_lib_list = resources.files(_RESOURCE_PACKAGE).joinpath( vndk_lib_list_name) + vndk_lib_list_history_name = version_str + "_history.txt" + vndk_lib_list_history = resources.files(_RESOURCE_PACKAGE).joinpath( + vndk_lib_list_history_name) vndk_lib_extra_list_name = "vndk-lib-extra-list-" + version_str + ".txt" vndk_lib_extra_list = resources.files(_RESOURCE_PACKAGE).joinpath( vndk_lib_extra_list_name) @@ -219,7 +241,11 @@ def LoadVndkLibraryListsFromResources(version, *tags): vndk_lists = tuple([] for x in tags) with vndk_lib_list.open("r") as f: - _LoadVndkLibraryListsFile(vndk_lists, tags, f) + if vndk_lib_list_history.is_file(): + with vndk_lib_list_history.open("r") as history: + _LoadVndkLibraryListsFile(vndk_lists, tags, f, history) + else: + _LoadVndkLibraryListsFile(vndk_lists, tags, f) with vndk_lib_extra_list.open("r") as f: _LoadVndkLibraryListsFile(vndk_lists, tags, f) return vndk_lists |