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

Commit a121158

Browse files
s094392Gerrit Code Review
authored and
Gerrit Code Review
committed
Merge changes If1ccc3d9,I198bf3e1,I0d903c16
* changes: Refactor GetRefDumpDirStem to avoid excessive arguments passing Generate dumps for non-VNDK into folder that matches Cross-Version ABI Check mechanism Generate LLNDK ABI dumps to platform/ instead of vndk/
2 parents b30de65 + aee4dbf commit a121158

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

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

+46-28
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
2121

2222

23+
class GetRefDumpDirStem:
24+
def __init__(self, ref_dump_dir, chosen_vndk_version,
25+
chosen_platform_version, binder_bitness):
26+
self.ref_dump_dir = ref_dump_dir
27+
self.chosen_vndk_version = chosen_vndk_version
28+
self.chosen_platform_version = chosen_platform_version
29+
self.binder_bitness = binder_bitness
30+
31+
def __call__(self, category, arch):
32+
version_stem = (self.chosen_vndk_version
33+
if category == 'vndk'
34+
else self.chosen_platform_version)
35+
return os.path.join(self.ref_dump_dir, category, version_stem,
36+
self.binder_bitness, arch)
37+
38+
2339
def choose_vndk_version(version, platform_vndk_version, board_vndk_version):
2440
if version is None:
2541
# This logic must be in sync with the logic for reference ABI dumps
@@ -38,12 +54,6 @@ def make_libs_for_product(libs, product, variant, vndk_version, targets):
3854
make_tree(product, variant)
3955

4056

41-
def get_ref_dump_dir_stem(ref_dump_dir, category, chosen_vndk_version,
42-
binder_bitness, arch):
43-
return os.path.join(ref_dump_dir, category, chosen_vndk_version,
44-
binder_bitness, arch)
45-
46-
4757
def find_and_remove_path(root_path, file_name=None):
4858
if file_name is not None:
4959
root_path = os.path.join(root_path, 'source-based', file_name)
@@ -56,13 +66,11 @@ def find_and_remove_path(root_path, file_name=None):
5666
shutil.rmtree(root_path)
5767

5868

59-
def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version,
60-
binder_bitness, targets, libs):
69+
def remove_references_for_all_arches(get_ref_dump_dir_stem, targets, libs):
6170
for target in targets:
6271
for category in ('ndk', 'platform', 'vndk'):
63-
dir_to_remove = get_ref_dump_dir_stem(
64-
ref_dump_dir, category, chosen_vndk_version, binder_bitness,
65-
target.get_arch_str())
72+
dir_to_remove = get_ref_dump_dir_stem(category,
73+
target.get_arch_str())
6674
if libs:
6775
for lib in libs:
6876
find_and_remove_path(dir_to_remove,
@@ -76,40 +84,38 @@ def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version,
7684
def tag_to_dir_name(tag):
7785
if tag == 'NDK':
7886
return 'ndk'
79-
if tag == 'PLATFORM':
87+
if tag in ('PLATFORM', 'LLNDK'):
8088
return 'platform'
81-
if tag.startswith('VNDK') or tag == 'LLNDK':
89+
if tag.startswith('VNDK'):
8290
return 'vndk'
8391
raise ValueError(tag + 'is not a known tag.')
8492

8593

86-
def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version,
87-
binder_bitness, target, libs, lsdump_paths,
88-
compress):
94+
def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs,
95+
lsdump_paths, compress):
8996
arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target)
9097

9198
num_created = 0
9299
for tag, path in arch_lsdump_paths:
93-
ref_dump_dir_stem = get_ref_dump_dir_stem(
94-
ref_dump_dir, tag_to_dir_name(tag), chosen_vndk_version,
95-
binder_bitness, target.get_arch_str())
100+
ref_dump_dir_stem = get_ref_dump_dir_stem(tag_to_dir_name(tag),
101+
target.get_arch_str())
96102
copy_reference_dump(
97103
path, os.path.join(ref_dump_dir_stem, 'source-based'), compress)
98104
num_created += 1
99105
return num_created
100106

101107

102-
def create_source_abi_reference_dumps(args, chosen_vndk_version,
103-
binder_bitness, lsdump_paths, targets):
108+
def create_source_abi_reference_dumps(args, get_ref_dump_dir_stem,
109+
lsdump_paths, targets):
104110
num_libs_copied = 0
105111
for target in targets:
106112
assert target.primary_arch != ''
107113
print(f'Creating dumps for arch: {target.arch}, '
108114
f'primary arch: {target.primary_arch}')
109115

110116
num_libs_copied += find_and_copy_lib_lsdumps(
111-
args.ref_dump_dir, chosen_vndk_version, binder_bitness, target,
112-
args.libs, lsdump_paths, args.compress)
117+
get_ref_dump_dir_stem, target, args.libs, lsdump_paths,
118+
args.compress)
113119
return num_libs_copied
114120

115121

@@ -120,27 +126,39 @@ def create_source_abi_reference_dumps_for_all_products(args):
120126

121127
for product in args.products:
122128
build_vars = get_build_vars_for_product(
123-
['PLATFORM_VNDK_VERSION', 'BOARD_VNDK_VERSION', 'BINDER32BIT'],
129+
['PLATFORM_VNDK_VERSION', 'BOARD_VNDK_VERSION', 'BINDER32BIT',
130+
'PLATFORM_VERSION_CODENAME', 'PLATFORM_SDK_VERSION'],
124131
product, args.build_variant)
125132

126133
platform_vndk_version = build_vars[0]
127134
board_vndk_version = build_vars[1]
135+
platform_version_codename = build_vars[3]
136+
platform_sdk_version = build_vars[4]
128137
if build_vars[2] == 'true':
129138
binder_bitness = '32'
130139
else:
131140
binder_bitness = '64'
132141

133142
chosen_vndk_version = choose_vndk_version(
134143
args.version, platform_vndk_version, board_vndk_version)
144+
# chosen_vndk_version is expected to be the finalized
145+
# PLATFORM_SDK_VERSION if the codename is REL.
146+
chosen_platform_version = (platform_sdk_version
147+
if platform_version_codename == 'REL'
148+
else 'current')
149+
150+
get_ref_dump_dir_stem = GetRefDumpDirStem(args.ref_dump_dir,
151+
chosen_vndk_version,
152+
chosen_platform_version,
153+
binder_bitness)
135154

136155
targets = [t for t in (Target(True, product), Target(False, product))
137156
if t.arch]
138157
# Remove reference ABI dumps specified in `args.libs` (or remove all of
139158
# them if none of them are specified) so that we may build these
140159
# libraries successfully.
141-
remove_references_for_all_arches(
142-
args.ref_dump_dir, chosen_vndk_version, binder_bitness, targets,
143-
args.libs)
160+
remove_references_for_all_arches(get_ref_dump_dir_stem, targets,
161+
args.libs)
144162

145163
if not args.no_make_lib:
146164
# Build all the specified libs, or build `findlsdumps` if no libs
@@ -153,7 +171,7 @@ def create_source_abi_reference_dumps_for_all_products(args):
153171
build=False)
154172

155173
num_processed += create_source_abi_reference_dumps(
156-
args, chosen_vndk_version, binder_bitness, lsdump_paths, targets)
174+
args, get_ref_dump_dir_stem, lsdump_paths, targets)
157175

158176
return num_processed
159177

0 commit comments

Comments
 (0)