diff options
| author | Logan Chien <loganchien@google.com> | 2019-03-05 03:04:24 -0800 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2019-03-05 03:04:24 -0800 |
| commit | 39421fe4df90d416f782b0510471520a17daf0b9 (patch) | |
| tree | 0bf106bbea749b60433b3b6a4b84e5dbe907f0dd /vndk | |
| parent | bf42bfd31e0782e9731bc151fee00e364c8eb67a (diff) | |
| parent | 1690b91abf3c6b47f83054e11fb34746fcc78615 (diff) | |
| download | android_development-39421fe4df90d416f782b0510471520a17daf0b9.tar.gz android_development-39421fe4df90d416f782b0510471520a17daf0b9.tar.bz2 android_development-39421fe4df90d416f782b0510471520a17daf0b9.zip | |
Merge changes I56d4f852,I8c81dc1f am: ce79190156 am: 8194a7ec21
am: 1690b91abf
Change-Id: Ib99d06025291345b309691629fd3190cc70de3d0
Diffstat (limited to 'vndk')
| -rwxr-xr-x | vndk/tools/header-checker/utils/create_reference_dumps.py | 40 | ||||
| -rw-r--r-- | vndk/tools/header-checker/utils/utils.py | 108 |
2 files changed, 93 insertions, 55 deletions
diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py index e25ec6135..19a21fb03 100755 --- a/vndk/tools/header-checker/utils/create_reference_dumps.py +++ b/vndk/tools/header-checker/utils/create_reference_dumps.py @@ -10,7 +10,7 @@ from utils import ( AOSP_DIR, COMPRESSED_SOURCE_ABI_DUMP_EXT, SOURCE_ABI_DUMP_EXT, SOURCE_ABI_DUMP_EXT_END, SO_EXT, copy_reference_dumps, find_lib_lsdumps, get_build_vars_for_product, get_module_variant_dir_name, make_libraries, - make_tree) + make_tree, read_lsdump_paths) PRODUCTS_DEFAULT = ['aosp_arm_ab', 'aosp_arm', 'aosp_arm64', 'aosp_x86_ab', @@ -35,26 +35,6 @@ class Target(object): self.cpu_variant = build_vars[3] -def get_lsdump_paths(product, libs): - if libs is None: - return get_lsdump_paths_from_out(product) - return search_for_lsdump_paths(SOONG_DIR, libs) - - -def get_lsdump_paths_from_out(product): - build_vars_to_fetch = ['OUT_DIR', 'TARGET_DEVICE'] - build_vars = get_build_vars_for_product(build_vars_to_fetch, product) - lsdump_paths_file = os.path.join( - AOSP_DIR, build_vars[0], 'target', 'product', build_vars[1], - 'lsdump_paths.txt') - assert os.path.exists(lsdump_paths_file) - lsdump_paths = collections.defaultdict(list) - with open(lsdump_paths_file) as f: - for path in f: - add_to_path_dict(path.rstrip(), lsdump_paths) - return lsdump_paths - - def get_lib_arch_str(target): assert target.primary_arch != '' target_arch_variant_str = '' @@ -103,10 +83,10 @@ def get_ref_dump_dir_stem(args, vndk_or_ndk, product, chosen_vndk_version): return ref_dump_dir_stem -def make_libs_for_product(libs, llndk_mode, product, variant): +def make_libs_for_product(libs, llndk_mode, product, variant, targets): print('making libs for', product + '-' + variant) if libs: - make_libraries(libs, product, variant, llndk_mode) + make_libraries(product, variant, targets, libs, llndk_mode) else: make_tree(product, variant) @@ -163,14 +143,6 @@ def add_to_path_dict(path, dictionary, libs=tuple()): dictionary[libname].append(path) -def search_for_lsdump_paths(soong_dir, libs): - lsdump_paths = collections.defaultdict(list) - for root, _, files in os.walk(soong_dir): - for file in files: - add_to_path_dict(os.path.join(root, file), lsdump_paths, libs) - return lsdump_paths - - def create_source_abi_reference_dumps(args, product, chosen_vndk_version, lsdump_paths, targets): @@ -224,9 +196,11 @@ def create_source_abi_reference_dumps_for_all_products(args): # Build all the specified libs (or build the 'vndk' target if none # of them are specified.) make_libs_for_product(args.libs, args.llndk, product, - args.build_variant) + args.build_variant, targets) + + lsdump_paths = read_lsdump_paths(product, args.build_variant, targets, + build=False) - lsdump_paths = get_lsdump_paths(product, args.libs) num_processed += create_source_abi_reference_dumps( args, product, chosen_vndk_version, lsdump_paths, targets) diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index db08558e1..741af4cea 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -5,6 +5,7 @@ import os import subprocess import sys import tempfile +import collections SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -138,30 +139,93 @@ def run_header_abi_linker(output_path, inputs, version_script, api, arch, return read_output_content(output_path, AOSP_DIR) -def make_tree(product, variant): - # To aid creation of reference dumps. - make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j', - 'vndk', 'findlsdumps', 'TARGET_PRODUCT=' + product, - 'TARGET_BUILD_VARIANT=' + variant] - subprocess.check_call(make_cmd, cwd=AOSP_DIR) - - -def make_targets(targets, product, variant): +def make_targets(product, variant, targets): make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j', 'TARGET_PRODUCT=' + product, 'TARGET_BUILD_VARIANT=' + variant] make_cmd += targets - subprocess.check_call(make_cmd, cwd=AOSP_DIR, stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT) + subprocess.check_call(make_cmd, cwd=AOSP_DIR) -def make_libraries(libs, product, variant, llndk_mode): - # To aid creation of reference dumps. Makes lib.vendor for the current - # configuration. - lib_targets = [] - for lib in libs: - lib = lib if llndk_mode else lib + VENDOR_SUFFIX - lib_targets.append(lib) - make_targets(lib_targets, product, variant) +def make_tree(product, variant): + """Build all lsdump files.""" + return make_targets(product, variant, ['findlsdumps']) + + +def make_libraries(product, variant, targets, libs, llndk_mode): + """Build lsdump files for specific libs.""" + lsdump_paths = read_lsdump_paths(product, variant, targets, build=True) + targets = [] + for name in libs: + targets.extend(lsdump_paths[name].values()) + make_targets(product, variant, targets) + + +def get_lsdump_paths_file_path(product, variant): + """Get the path to lsdump_paths.txt.""" + product_out = get_build_vars_for_product( + ['PRODUCT_OUT'], product, variant)[0] + return os.path.join(product_out, 'lsdump_paths.txt') + + +def _is_sanitizer_variation(variation): + """Check whether the variation is introduced by a sanitizer.""" + return variation in {'asan', 'hwasan', 'tsan', 'intOverflow', 'cfi', 'scs'} + + +def _are_sanitizer_variations(variations): + """Check whether these variations are introduced by sanitizers.""" + if isinstance(variations, str): + variations = [v for v in variations.split('_') if v] + return all(_is_sanitizer_variation(v) for v in variations) + + +def _read_lsdump_paths(lsdump_paths_file_path, targets): + """Read lsdump path from lsdump_paths.txt for each libname and variant.""" + lsdump_paths = collections.defaultdict(dict) + suffixes = collections.defaultdict(dict) + + prefixes = [] + prefixes.extend(get_module_variant_dir_name( + target.arch, target.arch_variant, target.cpu_variant, '_core_shared') + for target in targets) + prefixes.extend(get_module_variant_dir_name( + target.arch, target.arch_variant, target.cpu_variant, '_vendor_shared') + for target in targets) + + with open(lsdump_paths_file_path, 'r') as lsdump_paths_file: + for line in lsdump_paths_file: + path = line.strip() + if not path: + continue + dirname, filename = os.path.split(path) + if not filename.endswith(SOURCE_ABI_DUMP_EXT): + continue + libname = filename[:-len(SOURCE_ABI_DUMP_EXT)] + if not libname: + continue + variant = os.path.basename(dirname) + if not variant: + continue + for prefix in prefixes: + if not variant.startswith(prefix): + continue + new_suffix = variant[len(prefix):] + if not _are_sanitizer_variations(new_suffix): + continue + old_suffix = suffixes[libname].get(prefix) + if not old_suffix or new_suffix > old_suffix: + lsdump_paths[libname][prefix] = path + suffixes[libname][prefix] = new_suffix + return lsdump_paths + + +def read_lsdump_paths(product, variant, targets, build=True): + """Build lsdump_paths.txt and read the paths.""" + lsdump_paths_file_path = get_lsdump_paths_file_path(product, variant) + if build: + make_targets(product, variant, [lsdump_paths_file_path]) + lsdump_paths_file_abspath = os.path.join(AOSP_DIR, lsdump_paths_file_path) + return _read_lsdump_paths(lsdump_paths_file_abspath, targets) def get_module_variant_dir_name(arch, arch_variant, cpu_variant, @@ -187,11 +251,11 @@ def find_lib_lsdumps(module_variant_dir_name, lsdump_paths, libs): """Find the lsdump corresponding to lib_name for the given module variant if it exists.""" result = [] - for lib_name, paths in lsdump_paths.items(): + for lib_name, variations in lsdump_paths.items(): if libs and lib_name not in libs: continue - for path in paths: - if module_variant_dir_name in path.split(os.path.sep): + for variation, path in variations.items(): + if variation.startswith(module_variant_dir_name): result.append(os.path.join(AOSP_DIR, path.strip())) return result |
