From 1a4fb95440a7310a199a4bc5e8b2a893140b042d Mon Sep 17 00:00:00 2001 From: Mu-Le Lee Date: Thu, 7 Jul 2022 14:25:11 +0000 Subject: [PATCH 1/3] Generate LLNDK ABI dumps to platform/ instead of vndk/ Since vndk libraries don't need to maintain Cross-Version abi compatibility. The newly proposed Cross-Version ABi checking mechanism is applied to only ndk/ and platform/. The dumps of LLNDK libraries should be generated to platform/ to be benefited from this checking mechanism. Test: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py \ --llndk -l libvndksupport Bug: 238383972 Change-Id: I0d903c16eecfd57001a539c14bd4d6945c148e3c --- vndk/tools/header-checker/utils/create_reference_dumps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py index 4b7876b80..261bc7e03 100755 --- a/vndk/tools/header-checker/utils/create_reference_dumps.py +++ b/vndk/tools/header-checker/utils/create_reference_dumps.py @@ -76,9 +76,9 @@ def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version, def tag_to_dir_name(tag): if tag == 'NDK': return 'ndk' - if tag == 'PLATFORM': + if tag in ('PLATFORM', 'LLNDK'): return 'platform' - if tag.startswith('VNDK') or tag == 'LLNDK': + if tag.startswith('VNDK'): return 'vndk' raise ValueError(tag + 'is not a known tag.') From ec1859280286f3ef9b5cdce57e77bed952e22ad9 Mon Sep 17 00:00:00 2001 From: Mu-Le Lee Date: Mon, 11 Jul 2022 06:57:35 +0000 Subject: [PATCH 2/3] Generate dumps for non-VNDK into folder that matches Cross-Version ABI Check mechanism The dumps of non-VNDK was generated to PLATFORM_SDK_VERSION. To enable the Cross-Version ABI Check, before finalization (when PLATFORM_VERSION_CODENAME is not REL), dumps should be generate to current/ no matter what PLATFORM_SDK_VERSION is; After finalization, dumps should be generate to PLATFORM_SDK_VERSION/. Test: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py \ --llndk -l libvndksupport -l libbinder_ndk -l libprocinfo Bug: 238573414 Change-Id: I198bf3e1fb1382a9378dcde16deb9262f0eb9f64 --- .../utils/create_reference_dumps.py | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py index 261bc7e03..a774aadac 100755 --- a/vndk/tools/header-checker/utils/create_reference_dumps.py +++ b/vndk/tools/header-checker/utils/create_reference_dumps.py @@ -39,9 +39,9 @@ def make_libs_for_product(libs, product, variant, vndk_version, targets): def get_ref_dump_dir_stem(ref_dump_dir, category, chosen_vndk_version, - binder_bitness, arch): - return os.path.join(ref_dump_dir, category, chosen_vndk_version, - binder_bitness, arch) + chosen_platform_version, binder_bitness, arch): + version = chosen_vndk_version if category == 'vndk' else chosen_platform_version + return os.path.join(ref_dump_dir, category, version, binder_bitness, arch) def find_and_remove_path(root_path, file_name=None): @@ -57,12 +57,13 @@ def find_and_remove_path(root_path, file_name=None): def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version, - binder_bitness, targets, libs): + chosen_platform_version, binder_bitness, + targets, libs): for target in targets: for category in ('ndk', 'platform', 'vndk'): dir_to_remove = get_ref_dump_dir_stem( - ref_dump_dir, category, chosen_vndk_version, binder_bitness, - target.get_arch_str()) + ref_dump_dir, category, chosen_vndk_version, chosen_platform_version, + binder_bitness, target.get_arch_str()) if libs: for lib in libs: find_and_remove_path(dir_to_remove, @@ -83,7 +84,7 @@ def tag_to_dir_name(tag): raise ValueError(tag + 'is not a known tag.') -def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version, +def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version, chosen_platform_version, binder_bitness, target, libs, lsdump_paths, compress): arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target) @@ -91,7 +92,7 @@ def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version, num_created = 0 for tag, path in arch_lsdump_paths: ref_dump_dir_stem = get_ref_dump_dir_stem( - ref_dump_dir, tag_to_dir_name(tag), chosen_vndk_version, + ref_dump_dir, tag_to_dir_name(tag), chosen_vndk_version, chosen_platform_version, binder_bitness, target.get_arch_str()) copy_reference_dump( path, os.path.join(ref_dump_dir_stem, 'source-based'), compress) @@ -99,7 +100,7 @@ def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version, return num_created -def create_source_abi_reference_dumps(args, chosen_vndk_version, +def create_source_abi_reference_dumps(args, chosen_vndk_version, chosen_platform_version, binder_bitness, lsdump_paths, targets): num_libs_copied = 0 for target in targets: @@ -108,8 +109,8 @@ def create_source_abi_reference_dumps(args, chosen_vndk_version, f'primary arch: {target.primary_arch}') num_libs_copied += find_and_copy_lib_lsdumps( - args.ref_dump_dir, chosen_vndk_version, binder_bitness, target, - args.libs, lsdump_paths, args.compress) + args.ref_dump_dir, chosen_vndk_version, chosen_platform_version, binder_bitness, + target, args.libs, lsdump_paths, args.compress) return num_libs_copied @@ -120,11 +121,14 @@ def create_source_abi_reference_dumps_for_all_products(args): for product in args.products: build_vars = get_build_vars_for_product( - ['PLATFORM_VNDK_VERSION', 'BOARD_VNDK_VERSION', 'BINDER32BIT'], + ['PLATFORM_VNDK_VERSION', 'BOARD_VNDK_VERSION', 'BINDER32BIT', + 'PLATFORM_VERSION_CODENAME', 'PLATFORM_SDK_VERSION'], product, args.build_variant) platform_vndk_version = build_vars[0] board_vndk_version = build_vars[1] + platform_version_codename = build_vars[3] + platform_sdk_version = build_vars[4] if build_vars[2] == 'true': binder_bitness = '32' else: @@ -132,6 +136,11 @@ def create_source_abi_reference_dumps_for_all_products(args): chosen_vndk_version = choose_vndk_version( args.version, platform_vndk_version, board_vndk_version) + # chosen_vndk_version is expected to be the finalized PLATFORM_SDK_VERSION + # if the codename is REL. + chosen_platform_version = (platform_sdk_version + if platform_version_codename == 'REL' + else 'current') targets = [t for t in (Target(True, product), Target(False, product)) if t.arch] @@ -139,8 +148,8 @@ def create_source_abi_reference_dumps_for_all_products(args): # them if none of them are specified) so that we may build these # libraries successfully. remove_references_for_all_arches( - args.ref_dump_dir, chosen_vndk_version, binder_bitness, targets, - args.libs) + args.ref_dump_dir, chosen_vndk_version, chosen_platform_version, binder_bitness, + targets, args.libs) if not args.no_make_lib: # Build all the specified libs, or build `findlsdumps` if no libs @@ -153,7 +162,8 @@ def create_source_abi_reference_dumps_for_all_products(args): build=False) num_processed += create_source_abi_reference_dumps( - args, chosen_vndk_version, binder_bitness, lsdump_paths, targets) + args, chosen_vndk_version, chosen_platform_version, binder_bitness, lsdump_paths, + targets) return num_processed From aee4dbfae409f9b9812dce1e496563a447dee0ff Mon Sep 17 00:00:00 2001 From: Mu-Le Lee Date: Tue, 12 Jul 2022 09:45:56 +0000 Subject: [PATCH 3/3] Refactor GetRefDumpDirStem to avoid excessive arguments passing The arguments required by function get_ref_dump_dir_stem() would be carried all the way to get_ref_dump_dir_stem(). In this CL, the logic of get_ref_dump_dir_stem() would be wrapped into a class so that the other functions can be cleaner. Test: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py --llndk -l libvndksupport -l libbinder_ndk -l libprocinfo Bug: 238828401 Change-Id: If1ccc3d9de0408c5e1ef252412630df341d38e14 --- .../utils/create_reference_dumps.py | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py index a774aadac..a658090b0 100755 --- a/vndk/tools/header-checker/utils/create_reference_dumps.py +++ b/vndk/tools/header-checker/utils/create_reference_dumps.py @@ -20,6 +20,22 @@ PREBUILTS_ABI_DUMPS_DEFAULT = os.path.join(AOSP_DIR, 'prebuilts', 'abi-dumps') SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates') +class GetRefDumpDirStem: + def __init__(self, ref_dump_dir, chosen_vndk_version, + chosen_platform_version, binder_bitness): + self.ref_dump_dir = ref_dump_dir + self.chosen_vndk_version = chosen_vndk_version + self.chosen_platform_version = chosen_platform_version + self.binder_bitness = binder_bitness + + def __call__(self, category, arch): + version_stem = (self.chosen_vndk_version + if category == 'vndk' + else self.chosen_platform_version) + return os.path.join(self.ref_dump_dir, category, version_stem, + self.binder_bitness, arch) + + def choose_vndk_version(version, platform_vndk_version, board_vndk_version): if version is None: # 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): make_tree(product, variant) -def get_ref_dump_dir_stem(ref_dump_dir, category, chosen_vndk_version, - chosen_platform_version, binder_bitness, arch): - version = chosen_vndk_version if category == 'vndk' else chosen_platform_version - return os.path.join(ref_dump_dir, category, version, binder_bitness, arch) - - def find_and_remove_path(root_path, file_name=None): if file_name is not None: root_path = os.path.join(root_path, 'source-based', file_name) @@ -56,14 +66,11 @@ def find_and_remove_path(root_path, file_name=None): shutil.rmtree(root_path) -def remove_references_for_all_arches(ref_dump_dir, chosen_vndk_version, - chosen_platform_version, binder_bitness, - targets, libs): +def remove_references_for_all_arches(get_ref_dump_dir_stem, targets, libs): for target in targets: for category in ('ndk', 'platform', 'vndk'): - dir_to_remove = get_ref_dump_dir_stem( - ref_dump_dir, category, chosen_vndk_version, chosen_platform_version, - binder_bitness, target.get_arch_str()) + dir_to_remove = get_ref_dump_dir_stem(category, + target.get_arch_str()) if libs: for lib in libs: find_and_remove_path(dir_to_remove, @@ -84,24 +91,22 @@ def tag_to_dir_name(tag): raise ValueError(tag + 'is not a known tag.') -def find_and_copy_lib_lsdumps(ref_dump_dir, chosen_vndk_version, chosen_platform_version, - binder_bitness, target, libs, lsdump_paths, - compress): +def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs, + lsdump_paths, compress): arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target) num_created = 0 for tag, path in arch_lsdump_paths: - ref_dump_dir_stem = get_ref_dump_dir_stem( - ref_dump_dir, tag_to_dir_name(tag), chosen_vndk_version, chosen_platform_version, - binder_bitness, target.get_arch_str()) + ref_dump_dir_stem = get_ref_dump_dir_stem(tag_to_dir_name(tag), + target.get_arch_str()) copy_reference_dump( path, os.path.join(ref_dump_dir_stem, 'source-based'), compress) num_created += 1 return num_created -def create_source_abi_reference_dumps(args, chosen_vndk_version, chosen_platform_version, - binder_bitness, lsdump_paths, targets): +def create_source_abi_reference_dumps(args, get_ref_dump_dir_stem, + lsdump_paths, targets): num_libs_copied = 0 for target in targets: assert target.primary_arch != '' @@ -109,8 +114,8 @@ def create_source_abi_reference_dumps(args, chosen_vndk_version, chosen_platform f'primary arch: {target.primary_arch}') num_libs_copied += find_and_copy_lib_lsdumps( - args.ref_dump_dir, chosen_vndk_version, chosen_platform_version, binder_bitness, - target, args.libs, lsdump_paths, args.compress) + get_ref_dump_dir_stem, target, args.libs, lsdump_paths, + args.compress) return num_libs_copied @@ -136,20 +141,24 @@ def create_source_abi_reference_dumps_for_all_products(args): chosen_vndk_version = choose_vndk_version( args.version, platform_vndk_version, board_vndk_version) - # chosen_vndk_version is expected to be the finalized PLATFORM_SDK_VERSION - # if the codename is REL. + # chosen_vndk_version is expected to be the finalized + # PLATFORM_SDK_VERSION if the codename is REL. chosen_platform_version = (platform_sdk_version if platform_version_codename == 'REL' else 'current') + get_ref_dump_dir_stem = GetRefDumpDirStem(args.ref_dump_dir, + chosen_vndk_version, + chosen_platform_version, + binder_bitness) + targets = [t for t in (Target(True, product), Target(False, product)) if t.arch] # 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 # libraries successfully. - remove_references_for_all_arches( - args.ref_dump_dir, chosen_vndk_version, chosen_platform_version, binder_bitness, - targets, args.libs) + remove_references_for_all_arches(get_ref_dump_dir_stem, targets, + args.libs) if not args.no_make_lib: # Build all the specified libs, or build `findlsdumps` if no libs @@ -162,8 +171,7 @@ def create_source_abi_reference_dumps_for_all_products(args): build=False) num_processed += create_source_abi_reference_dumps( - args, chosen_vndk_version, chosen_platform_version, binder_bitness, lsdump_paths, - targets) + args, get_ref_dump_dir_stem, lsdump_paths, targets) return num_processed