summaryrefslogtreecommitdiffstats
path: root/vndk
diff options
context:
space:
mode:
authorLogan Chien <loganchien@google.com>2019-02-27 22:03:00 +0800
committerLogan Chien <loganchien@google.com>2019-03-05 14:32:46 +0800
commit575f2bf31efa23446e0c17099d6f1bd889755402 (patch)
treec0c07f916c81f3fc2583906a122458d2228fe04f /vndk
parent5428fe5f1e647661b3b2dfa6466e7d8d99501660 (diff)
downloadandroid_development-575f2bf31efa23446e0c17099d6f1bd889755402.tar.gz
android_development-575f2bf31efa23446e0c17099d6f1bd889755402.tar.bz2
android_development-575f2bf31efa23446e0c17099d6f1bd889755402.zip
Find make goals from lsdump_paths.txt
This commmit finds the make goals by reading lsdump_paths.txt. This fixes following problems: 1. Cannot build libraries that has been replaced by APEX stubs (e.g. "libc" has been renamed to "libc.bootstrap") 2. Cannot lsdump with sanitizer variation suffixes (e.g. "_cfi") Bug: 124829578 Test: create_reference_dumps.py --llndk -l libc Test: create_reference_dumps.py --llndk -l libmediandk Change-Id: I56d4f852f2e0dfe490e55f572bf3878f50464681
Diffstat (limited to 'vndk')
-rwxr-xr-xvndk/tools/header-checker/utils/create_reference_dumps.py26
-rw-r--r--vndk/tools/header-checker/utils/utils.py108
2 files changed, 93 insertions, 41 deletions
diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py
index c39718d4c..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,20 +35,6 @@ class Target(object):
self.cpu_variant = build_vars[3]
-def get_lsdump_paths(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 = ''
@@ -97,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)
@@ -210,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)
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 c63cb7dd5..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.
+def make_targets(product, variant, targets):
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):
- make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j', 'findlsdumps',
'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