Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 8471b71

Browse files
hsinyichen-googleGerrit Code Review
authored andcommitted
Merge "Create reference dumps from .so.llndk.lsdump" into main
2 parents 16cc7a9 + ac51c24 commit 8471b71

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

vndk/tools/header-checker/utils/utils.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
SO_EXT = '.so'
3030
SOURCE_ABI_DUMP_EXT_END = '.lsdump'
3131
SOURCE_ABI_DUMP_EXT = SO_EXT + SOURCE_ABI_DUMP_EXT_END
32-
VENDOR_SUFFIX = '.vendor'
32+
LLNDK_ABI_DUMP_EXT = SO_EXT + '.llndk' + SOURCE_ABI_DUMP_EXT_END
3333

3434
DEFAULT_CPPFLAGS = ['-x', 'c++', '-std=c++11']
3535
DEFAULT_CFLAGS = ['-std=gnu99']
@@ -83,6 +83,14 @@ def get_arch_cpu_str(self):
8383
return self.arch + arch_variant + cpu_variant
8484

8585

86+
def _strip_dump_name_ext(filename):
87+
"""Remove .so*.lsdump from a file name."""
88+
for ext in (SOURCE_ABI_DUMP_EXT, LLNDK_ABI_DUMP_EXT):
89+
if filename.endswith(ext) and len(filename) > len(ext):
90+
return filename[:-len(ext)]
91+
raise ValueError(f'{filename} has an unknown file name extension.')
92+
93+
8694
def _validate_dump_content(dump_path):
8795
"""Make sure that the dump contains relative source paths."""
8896
with open(dump_path, 'r') as f:
@@ -102,13 +110,14 @@ def _validate_dump_content(dump_path):
102110

103111

104112
def copy_reference_dump(lib_path, reference_dump_dir):
105-
reference_dump_path = os.path.join(
106-
reference_dump_dir, os.path.basename(lib_path))
107-
os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
108113
_validate_dump_content(lib_path)
109-
shutil.copyfile(lib_path, reference_dump_path)
110-
print('Created abi dump at', reference_dump_path)
111-
return reference_dump_path
114+
ref_dump_name = (_strip_dump_name_ext(os.path.basename(lib_path)) +
115+
SOURCE_ABI_DUMP_EXT)
116+
ref_dump_path = os.path.join(reference_dump_dir, ref_dump_name)
117+
os.makedirs(reference_dump_dir, exist_ok=True)
118+
shutil.copyfile(lib_path, ref_dump_path)
119+
print(f'Created abi dump at {ref_dump_path}')
120+
return ref_dump_path
112121

113122

114123
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):
230239
continue
231240
tag, path = (x.strip() for x in line.split(':', 1))
232241
dir_path, filename = os.path.split(path)
233-
if not filename.endswith(SOURCE_ABI_DUMP_EXT):
234-
continue
235-
libname = filename[:-len(SOURCE_ABI_DUMP_EXT)]
236-
if not libname:
237-
continue
242+
libname = _strip_dump_name_ext(filename)
238243
if not lsdump_filter(tag, libname):
239244
continue
240245
# dir_path may contain soong config hash.

0 commit comments

Comments
 (0)