Merge "Do not create versioned subdirectories in -ref-dump-dir"
This commit is contained in:
@@ -15,37 +15,35 @@ from utils import (
|
|||||||
|
|
||||||
PRODUCTS_DEFAULT = ['aosp_arm', 'aosp_arm64', 'aosp_x86', 'aosp_x86_64']
|
PRODUCTS_DEFAULT = ['aosp_arm', 'aosp_arm64', 'aosp_x86', 'aosp_x86_64']
|
||||||
|
|
||||||
PREBUILTS_ABI_DUMPS_DEFAULT = 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')
|
||||||
|
|
||||||
SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
SOONG_DIR = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
||||||
|
|
||||||
|
|
||||||
class GetRefDumpDirStem:
|
class GetRefDumpDirStem:
|
||||||
def __init__(self, ref_dump_dir, chosen_vndk_version,
|
def __init__(self, ref_dump_dir):
|
||||||
chosen_platform_version, binder_bitness):
|
|
||||||
self.ref_dump_dir = ref_dump_dir
|
self.ref_dump_dir = ref_dump_dir
|
||||||
|
|
||||||
|
def __call__(self, subdir, arch):
|
||||||
|
return os.path.join(self.ref_dump_dir, arch)
|
||||||
|
|
||||||
|
|
||||||
|
class GetVersionedRefDumpDirStem:
|
||||||
|
def __init__(self, chosen_vndk_version, chosen_platform_version,
|
||||||
|
binder_bitness):
|
||||||
self.chosen_vndk_version = chosen_vndk_version
|
self.chosen_vndk_version = chosen_vndk_version
|
||||||
self.chosen_platform_version = chosen_platform_version
|
self.chosen_platform_version = chosen_platform_version
|
||||||
self.binder_bitness = binder_bitness
|
self.binder_bitness = binder_bitness
|
||||||
|
|
||||||
def __call__(self, category, arch):
|
def __call__(self, subdir, arch):
|
||||||
version_stem = (self.chosen_vndk_version
|
version_stem = (self.chosen_vndk_version
|
||||||
if category == 'vndk'
|
if subdir == 'vndk'
|
||||||
else self.chosen_platform_version)
|
else self.chosen_platform_version)
|
||||||
return os.path.join(self.ref_dump_dir, category, version_stem,
|
return os.path.join(PREBUILTS_ABI_DUMPS_DIR, subdir, version_stem,
|
||||||
self.binder_bitness, arch)
|
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
|
|
||||||
# directory in `build/soong/cc/library.go`.
|
|
||||||
version = platform_vndk_version
|
|
||||||
if board_vndk_version not in ('current', ''):
|
|
||||||
version = board_vndk_version
|
|
||||||
return version
|
|
||||||
|
|
||||||
|
|
||||||
def make_libs_for_product(libs, product, variant, vndk_version, targets):
|
def make_libs_for_product(libs, product, variant, vndk_version, targets):
|
||||||
print('making libs for', product + '-' + variant)
|
print('making libs for', product + '-' + variant)
|
||||||
if libs:
|
if libs:
|
||||||
@@ -66,19 +64,16 @@ def find_and_remove_path(root_path, file_name=None):
|
|||||||
shutil.rmtree(root_path)
|
shutil.rmtree(root_path)
|
||||||
|
|
||||||
|
|
||||||
def remove_references_for_all_arches(get_ref_dump_dir_stem, targets, libs):
|
def remove_reference_dumps(ref_dump_dir_stems, libs):
|
||||||
for target in targets:
|
for ref_dump_dir_stem in ref_dump_dir_stems:
|
||||||
for category in ('ndk', 'platform', 'vndk'):
|
if libs:
|
||||||
dir_to_remove = get_ref_dump_dir_stem(category,
|
for lib in libs:
|
||||||
target.get_arch_str())
|
find_and_remove_path(ref_dump_dir_stem,
|
||||||
if libs:
|
lib + SOURCE_ABI_DUMP_EXT)
|
||||||
for lib in libs:
|
find_and_remove_path(ref_dump_dir_stem,
|
||||||
find_and_remove_path(dir_to_remove,
|
lib + COMPRESSED_SOURCE_ABI_DUMP_EXT)
|
||||||
lib + SOURCE_ABI_DUMP_EXT)
|
else:
|
||||||
find_and_remove_path(dir_to_remove,
|
find_and_remove_path(ref_dump_dir_stem)
|
||||||
lib + COMPRESSED_SOURCE_ABI_DUMP_EXT)
|
|
||||||
else:
|
|
||||||
find_and_remove_path(dir_to_remove)
|
|
||||||
|
|
||||||
|
|
||||||
def tag_to_dir_name(tag):
|
def tag_to_dir_name(tag):
|
||||||
@@ -139,26 +134,41 @@ def create_source_abi_reference_dumps_for_all_products(args):
|
|||||||
else:
|
else:
|
||||||
binder_bitness = '64'
|
binder_bitness = '64'
|
||||||
|
|
||||||
chosen_vndk_version = choose_vndk_version(
|
# This logic must be in sync with the logic for reference ABI dumps
|
||||||
args.version, platform_vndk_version, board_vndk_version)
|
# directory in `build/soong/cc/library.go`.
|
||||||
# chosen_vndk_version is expected to be the finalized
|
# chosen_vndk_version is either the codename or the finalized
|
||||||
|
# PLATFORM_SDK_VERSION.
|
||||||
|
chosen_vndk_version = (platform_vndk_version
|
||||||
|
if board_vndk_version in ('current', '')
|
||||||
|
else board_vndk_version)
|
||||||
|
# chosen_platform_version is expected to be the finalized
|
||||||
# PLATFORM_SDK_VERSION if the codename is REL.
|
# PLATFORM_SDK_VERSION if the codename is REL.
|
||||||
chosen_platform_version = (platform_sdk_version
|
chosen_platform_version = (platform_sdk_version
|
||||||
if platform_version_codename == 'REL'
|
if platform_version_codename == 'REL'
|
||||||
else 'current')
|
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))
|
targets = [t for t in (Target(True, product), Target(False, product))
|
||||||
if t.arch]
|
if t.arch]
|
||||||
|
|
||||||
|
if args.ref_dump_dir:
|
||||||
|
get_ref_dump_dir_stem = GetRefDumpDirStem(args.ref_dump_dir)
|
||||||
|
ref_dump_dir_stems = [
|
||||||
|
get_ref_dump_dir_stem(None, target.get_arch_str())
|
||||||
|
for target in targets]
|
||||||
|
else:
|
||||||
|
get_ref_dump_dir_stem = GetVersionedRefDumpDirStem(
|
||||||
|
chosen_vndk_version,
|
||||||
|
chosen_platform_version,
|
||||||
|
binder_bitness)
|
||||||
|
ref_dump_dir_stems = [
|
||||||
|
get_ref_dump_dir_stem(subdir, target.get_arch_str())
|
||||||
|
for target in targets
|
||||||
|
for subdir in PREBUILTS_ABI_DUMPS_SUBDIRS]
|
||||||
|
|
||||||
# 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_references_for_all_arches(get_ref_dump_dir_stem, targets,
|
remove_reference_dumps(ref_dump_dir_stems, args.libs)
|
||||||
args.libs)
|
|
||||||
|
|
||||||
if not args.no_make_lib:
|
if not args.no_make_lib:
|
||||||
# Build all the specified libs, or build `findlsdumps` if no libs
|
# Build all the specified libs, or build `findlsdumps` if no libs
|
||||||
@@ -180,11 +190,9 @@ def _parse_args():
|
|||||||
"""Parse the command line arguments."""
|
"""Parse the command line arguments."""
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--version', help='VNDK version')
|
parser.add_argument('--version', help=argparse.SUPPRESS)
|
||||||
parser.add_argument('--no-make-lib', action='store_true',
|
parser.add_argument('--no-make-lib', action='store_true',
|
||||||
help='no m -j lib.vendor while creating reference')
|
help='no m -j lib.vendor while creating reference')
|
||||||
parser.add_argument('--llndk', action='store_true',
|
|
||||||
help='the flag is deprecated and has no effect')
|
|
||||||
parser.add_argument('-libs', action='append',
|
parser.add_argument('-libs', action='append',
|
||||||
help='libs to create references for')
|
help='libs to create references for')
|
||||||
parser.add_argument('-products', action='append',
|
parser.add_argument('-products', action='append',
|
||||||
@@ -194,17 +202,24 @@ def _parse_args():
|
|||||||
parser.add_argument('--compress', action='store_true',
|
parser.add_argument('--compress', action='store_true',
|
||||||
help='compress reference dump with gzip')
|
help='compress reference dump with gzip')
|
||||||
parser.add_argument('-ref-dump-dir',
|
parser.add_argument('-ref-dump-dir',
|
||||||
help='directory to copy reference abi dumps into',
|
help='directory to copy reference abi dumps into')
|
||||||
default=PREBUILTS_ABI_DUMPS_DEFAULT)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.version is not None:
|
||||||
|
parser.error('--version is deprecated. Please specify the version in '
|
||||||
|
'the reference dump directory path. e.g., '
|
||||||
|
'-ref-dump-dir prebuilts/abi-dumps/platform/current/64')
|
||||||
|
|
||||||
if args.libs:
|
if args.libs:
|
||||||
if any(lib_name.endswith(SOURCE_ABI_DUMP_EXT_END) or
|
if any(lib_name.endswith(SOURCE_ABI_DUMP_EXT_END) or
|
||||||
lib_name.endswith(SO_EXT) for lib_name in args.libs):
|
lib_name.endswith(SO_EXT) for lib_name in args.libs):
|
||||||
parser.error('-libs should be followed by a base name without '
|
parser.error('-libs should be followed by a base name without '
|
||||||
'file extension.')
|
'file extension.')
|
||||||
|
|
||||||
|
if args.ref_dump_dir and not args.libs:
|
||||||
|
parser.error('-libs must be given if -ref-dump-dir is given.')
|
||||||
|
|
||||||
if args.products is None:
|
if args.products is None:
|
||||||
# If `args.products` is unspecified, generate reference ABI dumps for
|
# If `args.products` is unspecified, generate reference ABI dumps for
|
||||||
# all products.
|
# all products.
|
||||||
|
|||||||
Reference in New Issue
Block a user