From 8fb8023bfccdaf5ab3ef3ce1526472b108262cbd Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Sat, 22 May 2021 02:04:12 +0800 Subject: [PATCH] Select apex variants from lsdump paths Bug: 188870336 Test: ./create_reference_dumps.py Change-Id: I15a1f6a7c5c4952d2deb403aa9e9d58a0733561b Merged-In: I15a1f6a7c5c4952d2deb403aa9e9d58a0733561b (cherry picked from commit ebea84643ab8f62f5a6b7e62714835fa81582ef8) --- vndk/tools/header-checker/utils/utils.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index 9256e1800..e0fd5cf42 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -2,6 +2,7 @@ import gzip import os +import re import shutil import subprocess import sys @@ -177,9 +178,12 @@ def get_lsdump_paths_file_path(product, variant): 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 _get_module_variant_sort_key(suffix): + for variant in suffix.split('_'): + match = re.match(r'apex(\d+)$', variant) + if match: + return (int(match.group(1)), suffix) + return (-1, suffix) def _get_module_variant_dir_name(tag, vndk_version, arch_cpu_str): @@ -232,13 +236,10 @@ def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets): if not variant.startswith(prefix): continue new_suffix = variant[len(prefix):] - # Skip if the suffix contains APEX variations. - new_variations = [x for x in new_suffix.split('_') if x] - if new_variations and not all(_is_sanitizer_variation(x) - for x in new_variations): - continue old_suffix = suffixes[libname].get(arch_cpu) - if not old_suffix or new_suffix > old_suffix: + if (not old_suffix or + _get_module_variant_sort_key(new_suffix) > + _get_module_variant_sort_key(old_suffix)): lsdump_paths[libname][arch_cpu][tag] = path suffixes[libname][arch_cpu] = new_suffix return lsdump_paths