Merge "Do not create ABI dumps in AOSP directories for vendor libraries"
This commit is contained in:
@@ -16,6 +16,7 @@ PRODUCTS_DEFAULT = ['aosp_arm', 'aosp_arm64', 'aosp_x86', 'aosp_x86_64']
|
|||||||
|
|
||||||
PREBUILTS_ABI_DUMPS_DIR = os.path.join(AOSP_DIR, 'prebuilts', 'abi-dumps')
|
PREBUILTS_ABI_DUMPS_DIR = os.path.join(AOSP_DIR, 'prebuilts', 'abi-dumps')
|
||||||
PREBUILTS_ABI_DUMPS_SUBDIRS = ('ndk', 'platform', 'vndk')
|
PREBUILTS_ABI_DUMPS_SUBDIRS = ('ndk', 'platform', 'vndk')
|
||||||
|
NON_AOSP_TAGS = {'VENDOR', 'PRODUCT', 'VNDK-ext', 'VNDK-SP-ext'}
|
||||||
|
|
||||||
SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
||||||
|
|
||||||
@@ -36,6 +37,9 @@ class GetVersionedRefDumpDirStem:
|
|||||||
self.binder_bitness = binder_bitness
|
self.binder_bitness = binder_bitness
|
||||||
|
|
||||||
def __call__(self, subdir, arch):
|
def __call__(self, subdir, arch):
|
||||||
|
if subdir not in PREBUILTS_ABI_DUMPS_SUBDIRS:
|
||||||
|
raise ValueError(f'"{subdir}" is not a valid dump directory under '
|
||||||
|
f'{PREBUILTS_ABI_DUMPS_DIR}.')
|
||||||
version_stem = (self.chosen_vndk_version
|
version_stem = (self.chosen_vndk_version
|
||||||
if subdir == 'vndk'
|
if subdir == 'vndk'
|
||||||
else self.chosen_platform_version)
|
else self.chosen_platform_version)
|
||||||
@@ -43,10 +47,12 @@ class GetVersionedRefDumpDirStem:
|
|||||||
self.binder_bitness, arch)
|
self.binder_bitness, arch)
|
||||||
|
|
||||||
|
|
||||||
def make_libs_for_product(libs, product, variant, vndk_version, targets):
|
def make_libs_for_product(libs, product, variant, vndk_version, targets,
|
||||||
|
exclude_tags):
|
||||||
print('making libs for', product + '-' + variant)
|
print('making libs for', product + '-' + variant)
|
||||||
if libs:
|
if libs:
|
||||||
make_libraries(product, variant, vndk_version, targets, libs)
|
make_libraries(product, variant, vndk_version, targets, libs,
|
||||||
|
exclude_tags)
|
||||||
else:
|
else:
|
||||||
make_tree(product, variant)
|
make_tree(product, variant)
|
||||||
|
|
||||||
@@ -66,19 +72,20 @@ def remove_reference_dumps(ref_dump_dir_stems, libs):
|
|||||||
|
|
||||||
|
|
||||||
def tag_to_dir_name(tag):
|
def tag_to_dir_name(tag):
|
||||||
|
if tag in NON_AOSP_TAGS:
|
||||||
|
return ''
|
||||||
if tag == 'NDK':
|
if tag == 'NDK':
|
||||||
return 'ndk'
|
return 'ndk'
|
||||||
if tag in ('PLATFORM', 'LLNDK'):
|
if tag in ('PLATFORM', 'LLNDK'):
|
||||||
return 'platform'
|
return 'platform'
|
||||||
if tag.startswith('VNDK'):
|
if tag.startswith('VNDK'):
|
||||||
return 'vndk'
|
return 'vndk'
|
||||||
raise ValueError(tag + 'is not a known tag.')
|
raise ValueError(tag + ' is not a known tag.')
|
||||||
|
|
||||||
|
|
||||||
def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs,
|
def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs,
|
||||||
lsdump_paths):
|
lsdump_paths):
|
||||||
arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target)
|
arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target)
|
||||||
|
|
||||||
num_created = 0
|
num_created = 0
|
||||||
for tag, path in arch_lsdump_paths:
|
for tag, path in arch_lsdump_paths:
|
||||||
ref_dump_dir_stem = get_ref_dump_dir_stem(tag_to_dir_name(tag),
|
ref_dump_dir_stem = get_ref_dump_dir_stem(tag_to_dir_name(tag),
|
||||||
@@ -143,6 +150,7 @@ def create_source_abi_reference_dumps_for_all_products(args):
|
|||||||
ref_dump_dir_stems = [
|
ref_dump_dir_stems = [
|
||||||
get_ref_dump_dir_stem(None, target.get_arch_str())
|
get_ref_dump_dir_stem(None, target.get_arch_str())
|
||||||
for target in targets]
|
for target in targets]
|
||||||
|
exclude_tags = ()
|
||||||
else:
|
else:
|
||||||
get_ref_dump_dir_stem = GetVersionedRefDumpDirStem(
|
get_ref_dump_dir_stem = GetVersionedRefDumpDirStem(
|
||||||
chosen_vndk_version,
|
chosen_vndk_version,
|
||||||
@@ -152,24 +160,34 @@ def create_source_abi_reference_dumps_for_all_products(args):
|
|||||||
get_ref_dump_dir_stem(subdir, target.get_arch_str())
|
get_ref_dump_dir_stem(subdir, target.get_arch_str())
|
||||||
for target in targets
|
for target in targets
|
||||||
for subdir in PREBUILTS_ABI_DUMPS_SUBDIRS]
|
for subdir in PREBUILTS_ABI_DUMPS_SUBDIRS]
|
||||||
|
exclude_tags = NON_AOSP_TAGS
|
||||||
|
|
||||||
# Remove reference ABI dumps specified in `args.libs` (or remove all of
|
# Remove reference ABI dumps specified in `args.libs` (or remove all of
|
||||||
# them if none of them are specified) so that we may build these
|
# them if none of them are specified) so that we may build these
|
||||||
# libraries successfully.
|
# libraries successfully.
|
||||||
remove_reference_dumps(ref_dump_dir_stems, args.libs)
|
remove_reference_dumps(ref_dump_dir_stems, args.libs)
|
||||||
|
|
||||||
if not args.no_make_lib:
|
try:
|
||||||
# Build all the specified libs, or build `findlsdumps` if no libs
|
if not args.no_make_lib:
|
||||||
# are specified.
|
# Build all the specified libs, or build `findlsdumps` if no
|
||||||
make_libs_for_product(args.libs, product, args.build_variant,
|
# libs are specified.
|
||||||
platform_vndk_version, targets)
|
make_libs_for_product(args.libs, product, args.build_variant,
|
||||||
|
platform_vndk_version, targets,
|
||||||
|
exclude_tags)
|
||||||
|
|
||||||
lsdump_paths = read_lsdump_paths(product, args.build_variant,
|
lsdump_paths = read_lsdump_paths(product, args.build_variant,
|
||||||
platform_vndk_version, targets,
|
platform_vndk_version, targets,
|
||||||
build=False)
|
exclude_tags, build=False)
|
||||||
|
|
||||||
num_processed += create_source_abi_reference_dumps(
|
num_processed += create_source_abi_reference_dumps(
|
||||||
args, get_ref_dump_dir_stem, lsdump_paths, targets)
|
args, get_ref_dump_dir_stem, lsdump_paths, targets)
|
||||||
|
except KeyError as e:
|
||||||
|
if args.libs or not args.ref_dump_dir:
|
||||||
|
raise RuntimeError('Please check the lib name or specify '
|
||||||
|
'-ref-dump-dir if you are updating '
|
||||||
|
'reference dumps for product or vendor '
|
||||||
|
'libraries.') from e
|
||||||
|
raise
|
||||||
|
|
||||||
return num_processed
|
return num_processed
|
||||||
|
|
||||||
|
|||||||
@@ -162,10 +162,11 @@ def make_tree(product, variant):
|
|||||||
return make_targets(product, variant, ['findlsdumps'])
|
return make_targets(product, variant, ['findlsdumps'])
|
||||||
|
|
||||||
|
|
||||||
def make_libraries(product, variant, vndk_version, targets, libs):
|
def make_libraries(product, variant, vndk_version, targets, libs,
|
||||||
|
exclude_tags):
|
||||||
"""Build lsdump files for specific libs."""
|
"""Build lsdump files for specific libs."""
|
||||||
lsdump_paths = read_lsdump_paths(product, variant, vndk_version, targets,
|
lsdump_paths = read_lsdump_paths(product, variant, vndk_version, targets,
|
||||||
build=True)
|
exclude_tags, build=True)
|
||||||
make_target_paths = []
|
make_target_paths = []
|
||||||
for name in libs:
|
for name in libs:
|
||||||
if not (name in lsdump_paths and lsdump_paths[name]):
|
if not (name in lsdump_paths and lsdump_paths[name]):
|
||||||
@@ -196,13 +197,16 @@ def _get_module_variant_dir_name(tag, vndk_version, arch_cpu_str):
|
|||||||
For example, android_x86_shared, android_vendor.R_arm_armv7-a-neon_shared.
|
For example, android_x86_shared, android_vendor.R_arm_armv7-a-neon_shared.
|
||||||
"""
|
"""
|
||||||
if tag in ('LLNDK', 'NDK', 'PLATFORM'):
|
if tag in ('LLNDK', 'NDK', 'PLATFORM'):
|
||||||
return 'android_%s_shared' % arch_cpu_str
|
return f'android_{arch_cpu_str}_shared'
|
||||||
if tag.startswith('VNDK'):
|
if tag.startswith('VNDK') or tag == 'VENDOR':
|
||||||
return 'android_vendor.%s_%s_shared' % (vndk_version, arch_cpu_str)
|
return f'android_vendor.{vndk_version}_{arch_cpu_str}_shared'
|
||||||
|
if tag == 'PRODUCT':
|
||||||
|
return f'android_product.{vndk_version}_{arch_cpu_str}_shared'
|
||||||
raise ValueError(tag + ' is not a known tag.')
|
raise ValueError(tag + ' is not a known tag.')
|
||||||
|
|
||||||
|
|
||||||
def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets):
|
def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets,
|
||||||
|
exclude_tags):
|
||||||
"""Read lsdump paths from lsdump_paths.txt for each libname and variant.
|
"""Read lsdump paths from lsdump_paths.txt for each libname and variant.
|
||||||
|
|
||||||
This function returns a dictionary, {lib_name: {arch_cpu: {tag: path}}}.
|
This function returns a dictionary, {lib_name: {arch_cpu: {tag: path}}}.
|
||||||
@@ -222,7 +226,7 @@ def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets):
|
|||||||
with open(lsdump_paths_file_path, 'r') as lsdump_paths_file:
|
with open(lsdump_paths_file_path, 'r') as lsdump_paths_file:
|
||||||
for line in lsdump_paths_file:
|
for line in lsdump_paths_file:
|
||||||
tag, path = (x.strip() for x in line.split(':', 1))
|
tag, path = (x.strip() for x in line.split(':', 1))
|
||||||
if not path:
|
if not path or tag in exclude_tags:
|
||||||
continue
|
continue
|
||||||
dirname, filename = os.path.split(path)
|
dirname, filename = os.path.split(path)
|
||||||
if not filename.endswith(SOURCE_ABI_DUMP_EXT):
|
if not filename.endswith(SOURCE_ABI_DUMP_EXT):
|
||||||
@@ -249,7 +253,8 @@ def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets):
|
|||||||
return lsdump_paths
|
return lsdump_paths
|
||||||
|
|
||||||
|
|
||||||
def read_lsdump_paths(product, variant, vndk_version, targets, build=True):
|
def read_lsdump_paths(product, variant, vndk_version, targets, exclude_tags,
|
||||||
|
build):
|
||||||
"""Build lsdump_paths.txt and read the paths."""
|
"""Build lsdump_paths.txt and read the paths."""
|
||||||
lsdump_paths_file_path = get_lsdump_paths_file_path(product, variant)
|
lsdump_paths_file_path = get_lsdump_paths_file_path(product, variant)
|
||||||
lsdump_paths_file_abspath = os.path.join(AOSP_DIR, lsdump_paths_file_path)
|
lsdump_paths_file_abspath = os.path.join(AOSP_DIR, lsdump_paths_file_path)
|
||||||
@@ -258,7 +263,7 @@ def read_lsdump_paths(product, variant, vndk_version, targets, build=True):
|
|||||||
os.unlink(lsdump_paths_file_abspath)
|
os.unlink(lsdump_paths_file_abspath)
|
||||||
make_targets(product, variant, [lsdump_paths_file_path])
|
make_targets(product, variant, [lsdump_paths_file_path])
|
||||||
return _read_lsdump_paths(lsdump_paths_file_abspath, vndk_version,
|
return _read_lsdump_paths(lsdump_paths_file_abspath, vndk_version,
|
||||||
targets)
|
targets, exclude_tags)
|
||||||
|
|
||||||
|
|
||||||
def find_lib_lsdumps(lsdump_paths, libs, target):
|
def find_lib_lsdumps(lsdump_paths, libs, target):
|
||||||
|
|||||||
Reference in New Issue
Block a user