summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2024-04-01 12:05:32 +0800
committerHsin-Yi Chen <hsinyichen@google.com>2024-04-01 13:05:02 +0800
commitac51c24c3b16a5a911cf65a3f464c31e325b1767 (patch)
tree4265d753f3b3996be97bea7c2c4f39faac96b51b
parentf9133cdaf7b3584eb69f1c0e9ec11b352170067e (diff)
downloaddevelopment-ac51c24c3b16a5a911cf65a3f464c31e325b1767.tar.gz
Create reference dumps from .so.llndk.lsdump
LLNDK ABI dumps are separated from the implementation libraries' ABI dumps. A library has two types of ABI dumps. Their file name extensions are .so.lsdump and .so.llndk.lsdump. Test: ./create_reference_dumps.py Bug: 314010764 Change-Id: I6b77d24ebd59246f1ba5b6d93ca53852369c51ca
-rw-r--r--vndk/tools/header-checker/utils/utils.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py
index 8d8a9b635..0d032c2ef 100644
--- a/vndk/tools/header-checker/utils/utils.py
+++ b/vndk/tools/header-checker/utils/utils.py
@@ -29,7 +29,7 @@ BUILTIN_HEADERS_DIR = (
SO_EXT = '.so'
SOURCE_ABI_DUMP_EXT_END = '.lsdump'
SOURCE_ABI_DUMP_EXT = SO_EXT + SOURCE_ABI_DUMP_EXT_END
-VENDOR_SUFFIX = '.vendor'
+LLNDK_ABI_DUMP_EXT = SO_EXT + '.llndk' + SOURCE_ABI_DUMP_EXT_END
DEFAULT_CPPFLAGS = ['-x', 'c++', '-std=c++11']
DEFAULT_CFLAGS = ['-std=gnu99']
@@ -83,6 +83,14 @@ class Arch(object):
return self.arch + arch_variant + cpu_variant
+def _strip_dump_name_ext(filename):
+ """Remove .so*.lsdump from a file name."""
+ for ext in (SOURCE_ABI_DUMP_EXT, LLNDK_ABI_DUMP_EXT):
+ if filename.endswith(ext) and len(filename) > len(ext):
+ return filename[:-len(ext)]
+ raise ValueError(f'{filename} has an unknown file name extension.')
+
+
def _validate_dump_content(dump_path):
"""Make sure that the dump contains relative source paths."""
with open(dump_path, 'r') as f:
@@ -102,13 +110,14 @@ def _validate_dump_content(dump_path):
def copy_reference_dump(lib_path, reference_dump_dir):
- reference_dump_path = os.path.join(
- reference_dump_dir, os.path.basename(lib_path))
- os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
_validate_dump_content(lib_path)
- shutil.copyfile(lib_path, reference_dump_path)
- print('Created abi dump at', reference_dump_path)
- return reference_dump_path
+ ref_dump_name = (_strip_dump_name_ext(os.path.basename(lib_path)) +
+ SOURCE_ABI_DUMP_EXT)
+ ref_dump_path = os.path.join(reference_dump_dir, ref_dump_name)
+ os.makedirs(reference_dump_dir, exist_ok=True)
+ shutil.copyfile(lib_path, ref_dump_path)
+ print(f'Created abi dump at {ref_dump_path}')
+ return ref_dump_path
def run_header_abi_dumper(input_path, output_path, cflags=tuple(),
@@ -230,11 +239,7 @@ def _read_lsdump_paths(lsdump_paths_file_path, arches, lsdump_filter):
continue
tag, path = (x.strip() for x in line.split(':', 1))
dir_path, filename = os.path.split(path)
- if not filename.endswith(SOURCE_ABI_DUMP_EXT):
- continue
- libname = filename[:-len(SOURCE_ABI_DUMP_EXT)]
- if not libname:
- continue
+ libname = _strip_dump_name_ext(filename)
if not lsdump_filter(tag, libname):
continue
# dir_path may contain soong config hash.