diff options
author | Hsin-Yi Chen <hsinyichen@google.com> | 2018-03-20 18:30:20 +0800 |
---|---|---|
committer | Hsin-Yi Chen <hsinyichen@google.com> | 2018-03-31 02:51:24 +0000 |
commit | c9e20ef329ed5d410c88f67629c145e5523f2584 (patch) | |
tree | eafc829216e992f5ac993a6714ef377fe7fa3b45 | |
parent | 01ca20e4624d7cb3aaf93bdb2df755ba9b23001c (diff) | |
download | vndk-c9e20ef329ed5d410c88f67629c145e5523f2584.tar.gz |
Make dump_abi.py load library names from eligible list
Test: ./dump_abi.py \
$ANDROID_BUILD_TOP/development/vndk/tools/definition-tool/datasets/eligible-list-p-release.csv
Bug: 73329012
Change-Id: Ia8674e5298ce5a8257db3d451af883abbb792a02
Merged-In: Ia8674e5298ce5a8257db3d451af883abbb792a02
(cherry picked from commit 29065e94e0784d4dca9b42795566e5de037ab8a0)
-rwxr-xr-x | golden/dump_abi.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/golden/dump_abi.py b/golden/dump_abi.py index 8ca30e8..cbfc04b 100755 --- a/golden/dump_abi.py +++ b/golden/dump_abi.py @@ -16,6 +16,7 @@ # import argparse +import csv import importlib import os import subprocess @@ -193,23 +194,54 @@ def DumpVtables(lib_path, dump_path, dumper_dir, include_symbols): return dump_string +def _LoadLibraryNamesFromCsv(csv_file): + """Loads VNDK and VNDK-SP library names from an eligible list. + + Args: + csv_file: A file object of eligible-list.csv. + + Returns: + A list of strings, the VNDK and VNDK-SP library names with vndk/vndk-sp + directory prefixes. + """ + lib_names = [] + # Skip header + next(csv_file) + reader = csv.reader(csv_file) + for cells in reader: + if cells[1] not in ("VNDK", "VNDK-SP"): + continue + lib_name = os.path.normpath(cells[0]).replace("/system/${LIB}/", "", 1) + if not (lib_name.startswith("vndk") or lib_name.startswith("vndk-sp")): + continue + lib_name = lib_name.replace("${VNDK_VER}", "{VNDK_VER}") + lib_names.append(lib_name) + return lib_names + + def _LoadLibraryNames(file_names): """Loads library names from files. - Each element in the input list can be a .so file or a text file which - contains list of library names. The returned list consists of the .so file - names in the input list, and the non-empty lines in the text files. + Each element in the input list can be a .so file, a text file, or a .csv + file. The returned list consists of: + - The .so file names in the input list. + - The non-empty lines in the text files. + - The libraries tagged with VNDK or VNDK-SP in the CSV. Args: file_names: A list of strings, the library or text file names. Returns: - A list of strings, the library names. + A list of strings, the library names (probably with vndk/vndk-sp + directory prefixes). """ lib_names = [] for file_name in file_names: if file_name.endswith(".so"): lib_names.append(file_name) + elif file_name.endswith(".csv"): + with open(file_name, "r") as csv_file: + lib_names.extend(_LoadLibraryNamesFromCsv(csv_file)) else: with open(file_name, "r") as lib_list: lib_names.extend(line.strip() for line in lib_list @@ -270,8 +302,13 @@ def main(): # Parse arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument("file", nargs="*", - help="the library to dump. Can be .so file or a" - "text file containing list of libraries.") + help="the libraries to dump. Each file can be " + ".so, text, or .csv. The text file contains " + "a list of paths. The CSV file follows the" + "format of eligible list output from VNDK" + "definition tool. {VNDK_VER} in the library" + "paths is replaced with " + "\"-\" + PLATFORM_VNDK_VERSION.") arg_parser.add_argument("--dumper-dir", "-d", action="store", help="the path to the directory containing " "bin/vndk-vtable-dumper.") |