From 2ed4052a06f4ba4b6fbe070d6b95c2249d483665 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Mon, 13 Jun 2022 14:46:14 +0800 Subject: [PATCH] Allow ABI dumps to contain ANDROID_BUILD_TOP that is not a path prefix Test: ./create_reference_dumps.py -products aosp_x86_64 -libs libm Bug: 235300136 Change-Id: I75fa175018d6ed0da7a0949ff133869fd874c667 --- vndk/tools/header-checker/utils/utils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index 521355622..b92ad45a9 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -83,9 +83,19 @@ class Target(object): def _validate_dump_content(dump_path): """Make sure that the dump contains relative source paths.""" with open(dump_path, 'r') as f: - if AOSP_DIR in f.read(): - raise ValueError( - dump_path + ' contains absolute path to $ANDROID_BUILD_TOP.') + for line_number, line in enumerate(f, 1): + start = 0 + while True: + start = line.find(AOSP_DIR, start) + if start < 0: + break + # The substring is not preceded by a common path character. + if start == 0 or not (line[start - 1].isalnum() or + line[start - 1] in '.-_/'): + raise ValueError(f'{dump_path} contains absolute path to ' + f'$ANDROID_BUILD_TOP at line ' + f'{line_number}:\n{line}') + start += len(AOSP_DIR) def copy_reference_dump(lib_path, reference_dump_dir, compress):