From d7a1ac93a63a7fe45ab79ce39ee4b6b6aa342529 Mon Sep 17 00:00:00 2001 From: liangxinyan Date: Sat, 12 Jul 2025 16:42:34 +0800 Subject: [PATCH] IssueNo: https://gitee.com/openharmony/developtools_integration_verification/issues/ICLUSB Signed-off-by: liangxinyan --- tools/deps_guard/elf_file_mgr/elf_file.py | 26 ++++++------------- tools/deps_guard/elf_file_mgr/utils.py | 8 ++++++ .../rules/NO-Depends-On-NAPI/whitelist.json | 3 ++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/deps_guard/elf_file_mgr/elf_file.py b/tools/deps_guard/elf_file_mgr/elf_file.py index 40709e1..f119ed1 100755 --- a/tools/deps_guard/elf_file_mgr/elf_file.py +++ b/tools/deps_guard/elf_file_mgr/elf_file.py @@ -19,7 +19,7 @@ import os from stat import ST_SIZE -from .utils import command +from .utils import command, command_without_error class ElfFile(dict): @@ -53,24 +53,14 @@ class ElfFile(dict): def library_depends(self): if not os.access(self._f, os.F_OK): raise Exception("Cannot find lib: " + self._f) - dynamics = command("readelf", "--dynamic", self._f_safe) + file_name = self._f_safe.split("/")[-1].strip("'") + dynamics = command_without_error("strings", self._f_safe, f"|grep -E lib_.so|grep -v {file_name}") res = [] - for line in dynamics: - pos = line.find("(NEEDED)") - if pos <= 0: - continue - line = line[pos + 8:] - line = line.strip() - if not line.startswith("Shared library:"): - continue - line = line[15:] - line = line.strip() - if line.startswith("["): - line = line[1:] - if line.endswith("]"): - line = line[:-1] - line = line.strip() - res.append(line) + if dynamics: + for line in dynamics: + if line.startswith("lib") and line.endswith(".so"): + res.append(line) + return res def __extract_soname(self): diff --git a/tools/deps_guard/elf_file_mgr/utils.py b/tools/deps_guard/elf_file_mgr/utils.py index 1894a3a..087c551 100755 --- a/tools/deps_guard/elf_file_mgr/utils.py +++ b/tools/deps_guard/elf_file_mgr/utils.py @@ -44,3 +44,11 @@ def command(command, *args): print("With output:", output) sys.exit(1) return [i for i in output.split('\n') if i] + +# return a list of lines of output of the command without reminding errors +def command_without_error(command, *args): + debug(DEBUG_SPAM, "calling", command, ' '.join(args)) + pipe = os.popen(command + ' ' + ' '.join(args), 'r') + output = pipe.read().strip() + status = pipe.close() + return [i for i in output.split('\n') if i] diff --git a/tools/deps_guard/rules/NO-Depends-On-NAPI/whitelist.json b/tools/deps_guard/rules/NO-Depends-On-NAPI/whitelist.json index 1020050..91ea33b 100644 --- a/tools/deps_guard/rules/NO-Depends-On-NAPI/whitelist.json +++ b/tools/deps_guard/rules/NO-Depends-On-NAPI/whitelist.json @@ -2,5 +2,6 @@ "accessibility", "remote_file_share_native", "medialibrary", - "utils" + "utils", + "usbmanager" ] -- Gitee