Make create_reference_dumps.py faster.
Since we now build and install all vndk libraries,regardless of
dependencies, we may just look for all files with the extension '.lsdump' for
TARGET_ARCH and TARGET_2ND_ARCH, and copy them to the given reference dump
directory.
Test: utils/create_reference_dumps.py --version current -ref-dump-dir
<dir> creates reference dumps at <dir>
Change-Id: Ic9db57b00614b3e8dc18d8e56eab4bd87df1723c
This commit is contained in:
@@ -5,12 +5,8 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from utils import make_library
|
from utils import (make_library, find_lib_lsdumps, get_build_var, AOSP_DIR,
|
||||||
from utils import find_lib_lsdump
|
read_output_content, copy_reference_dumps)
|
||||||
from utils import get_build_var
|
|
||||||
from utils import AOSP_DIR
|
|
||||||
from utils import read_output_content
|
|
||||||
from utils import copy_reference_dump
|
|
||||||
|
|
||||||
class Target(object):
|
class Target(object):
|
||||||
def __init__(self, has_2nd):
|
def __init__(self, has_2nd):
|
||||||
@@ -20,24 +16,16 @@ class Target(object):
|
|||||||
self.cpu_variant = \
|
self.cpu_variant = \
|
||||||
get_build_var('TARGET{}_CPU_VARIANT'.format(extra))
|
get_build_var('TARGET{}_CPU_VARIANT'.format(extra))
|
||||||
|
|
||||||
def get_vndk_libs(vndk_list_path):
|
def create_source_abi_reference_dumps(soong_dir, args):
|
||||||
with open(vndk_list_path, 'r') as f:
|
|
||||||
return f.read().splitlines()
|
|
||||||
|
|
||||||
def create_source_abi_reference_dumps(soong_dir, vndk_libs, args):
|
|
||||||
ref_dump_dir_stem = os.path.join(args.ref_dump_dir, args.version)
|
ref_dump_dir_stem = os.path.join(args.ref_dump_dir, args.version)
|
||||||
ref_dump_dir_insertion = 'source-based'
|
ref_dump_dir_insertion = 'source-based'
|
||||||
num_libs_copied = 0
|
num_libs_copied = 0
|
||||||
for vndk_lib in vndk_libs:
|
|
||||||
if args.make_libs:
|
|
||||||
make_library(vndk_lib)
|
|
||||||
for target in [Target(True), Target(False)]:
|
for target in [Target(True), Target(False)]:
|
||||||
arch_lsdump_path = find_lib_lsdump(vndk_lib, target.arch,
|
arch_lsdump_paths = find_lib_lsdumps(target.arch, target.arch_variant,
|
||||||
target.arch_variant,
|
target.cpu_variant, soong_dir)
|
||||||
target.cpu_variant)
|
|
||||||
# Copy the contents of the lsdump into it's corresponding
|
# Copy the contents of the lsdump into it's corresponding
|
||||||
# reference directory.
|
# reference directory.
|
||||||
num_libs_copied += copy_reference_dump(arch_lsdump_path,
|
num_libs_copied += copy_reference_dumps(arch_lsdump_paths,
|
||||||
ref_dump_dir_stem,
|
ref_dump_dir_stem,
|
||||||
ref_dump_dir_insertion,
|
ref_dump_dir_insertion,
|
||||||
target.arch)
|
target.arch)
|
||||||
@@ -48,17 +36,12 @@ def main():
|
|||||||
# Parse command line options.
|
# Parse command line options.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--version', help='VNDK version')
|
parser.add_argument('--version', help='VNDK version')
|
||||||
parser.add_argument('--vndk-list', help='file containing list of vndk \
|
|
||||||
libraries')
|
|
||||||
parser.add_argument('-ref-dump-dir', help='directory to copy reference abi \
|
parser.add_argument('-ref-dump-dir', help='directory to copy reference abi \
|
||||||
dumps into')
|
dumps into')
|
||||||
parser.add_argument('-make-libs', action ="store_true", default = False,
|
|
||||||
help='make libraries before copying dumps')
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
num_processed = 0
|
num_processed = 0
|
||||||
soong_dir = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
soong_dir = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
||||||
num_processed += create_source_abi_reference_dumps(soong_dir,\
|
num_processed += create_source_abi_reference_dumps(soong_dir, args)
|
||||||
get_vndk_libs(args.vndk_list), args)
|
|
||||||
print()
|
print()
|
||||||
print('msg: Processed', num_processed, 'libraries')
|
print('msg: Processed', num_processed, 'libraries')
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ EXPORTED_HEADERS_DIR = (
|
|||||||
'tests'),
|
'tests'),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_ABI_DUMP_EXT = ".so.lsdump"
|
SO_EXT = '.so'
|
||||||
|
SOURCE_ABI_DUMP_EXT_END = '.lsdump'
|
||||||
|
SOURCE_ABI_DUMP_EXT = SO_EXT + SOURCE_ABI_DUMP_EXT_END
|
||||||
|
|
||||||
TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64']
|
TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64']
|
||||||
|
|
||||||
@@ -29,13 +31,19 @@ def get_reference_dump_dir(reference_dump_dir_stem,
|
|||||||
reference_dump_dir_insertion)
|
reference_dump_dir_insertion)
|
||||||
return reference_dump_dir
|
return reference_dump_dir
|
||||||
|
|
||||||
def copy_reference_dump(lib_path, reference_dump_dir_stem,
|
|
||||||
|
def copy_reference_dumps(lib_paths, reference_dir_stem,
|
||||||
reference_dump_dir_insertion, lib_arch):
|
reference_dump_dir_insertion, lib_arch):
|
||||||
if lib_path is None:
|
reference_dump_dir = get_reference_dump_dir(reference_dir_stem,
|
||||||
return 0
|
|
||||||
reference_dump_dir = get_reference_dump_dir(reference_dump_dir_stem,
|
|
||||||
reference_dump_dir_insertion,
|
reference_dump_dir_insertion,
|
||||||
lib_arch)
|
lib_arch)
|
||||||
|
num_created = 0
|
||||||
|
for lib_path in lib_paths:
|
||||||
|
copy_reference_dump(lib_path, reference_dump_dir)
|
||||||
|
num_created += 1
|
||||||
|
return num_created
|
||||||
|
|
||||||
|
def copy_reference_dump(lib_path, reference_dump_dir):
|
||||||
reference_dump_path = os.path.join(reference_dump_dir,
|
reference_dump_path = os.path.join(reference_dump_dir,
|
||||||
os.path.basename(lib_path))
|
os.path.basename(lib_path))
|
||||||
os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
|
os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
|
||||||
@@ -104,14 +112,14 @@ def make_library(lib_name):
|
|||||||
make_cmd = ['make', '-j', lib_name]
|
make_cmd = ['make', '-j', lib_name]
|
||||||
subprocess.check_call(make_cmd, cwd=AOSP_DIR)
|
subprocess.check_call(make_cmd, cwd=AOSP_DIR)
|
||||||
|
|
||||||
def find_lib_lsdump(lib_name, target_arch, target_arch_variant,
|
def find_lib_lsdumps(target_arch, target_arch_variant,
|
||||||
target_cpu_variant):
|
target_cpu_variant, soong_dir):
|
||||||
""" Find the lsdump corresponding to lib_name for the given arch parameters
|
""" Find the lsdump corresponding to lib_name for the given arch parameters
|
||||||
if it exists"""
|
if it exists"""
|
||||||
assert 'ANDROID_PRODUCT_OUT' in os.environ
|
assert 'ANDROID_PRODUCT_OUT' in os.environ
|
||||||
cpu_variant = '_' + target_cpu_variant
|
cpu_variant = '_' + target_cpu_variant
|
||||||
arch_variant = '_' + target_arch_variant
|
arch_variant = '_' + target_arch_variant
|
||||||
|
lsdump_paths = []
|
||||||
if target_cpu_variant == 'generic' or target_cpu_variant is None or\
|
if target_cpu_variant == 'generic' or target_cpu_variant is None or\
|
||||||
target_cpu_variant == '':
|
target_cpu_variant == '':
|
||||||
cpu_variant = ''
|
cpu_variant = ''
|
||||||
@@ -120,16 +128,16 @@ def find_lib_lsdump(lib_name, target_arch, target_arch_variant,
|
|||||||
arch_variant = ''
|
arch_variant = ''
|
||||||
|
|
||||||
target_dir = 'android_' + target_arch + arch_variant +\
|
target_dir = 'android_' + target_arch + arch_variant +\
|
||||||
cpu_variant + '_shared_core'
|
cpu_variant + '_vendor_shared'
|
||||||
soong_dir = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates')
|
|
||||||
expected_lsdump_name = lib_name + SOURCE_ABI_DUMP_EXT
|
|
||||||
for base, dirnames, filenames in os.walk(soong_dir):
|
for base, dirnames, filenames in os.walk(soong_dir):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if filename == expected_lsdump_name:
|
name, ext = os.path.splitext(filename)
|
||||||
|
sofile, soext = os.path.splitext(name)
|
||||||
|
if ext == SOURCE_ABI_DUMP_EXT_END and soext == SO_EXT :
|
||||||
path = os.path.join(base, filename)
|
path = os.path.join(base, filename)
|
||||||
if target_dir in os.path.dirname(path):
|
if target_dir in os.path.dirname(path):
|
||||||
return path
|
lsdump_paths.append(path)
|
||||||
return None
|
return lsdump_paths
|
||||||
|
|
||||||
def run_abi_diff(old_test_dump_path, new_test_dump_path, arch, lib_name,
|
def run_abi_diff(old_test_dump_path, new_test_dump_path, arch, lib_name,
|
||||||
flags=[]):
|
flags=[]):
|
||||||
|
|||||||
Reference in New Issue
Block a user