1 Star 3 Fork 1

yjihrp/qt-deploy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ldd.py 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
lxj 提交于 2021-11-11 19:56 . 添加程序
import os
import re
def depends(file: str):
if not os.path.exists(file):
return []
with os.popen('ldd {0}'.format(file)) as fd:
lines = fd.readlines()
if len(lines) == 0:
return []
files = []
for item in lines:
match = re.search(r'=>(?P<fd>.*?)\s+\(0x.*?\)', item)
if match is None:
continue
fd = match.group('fd')
fd = fd.replace('\n', '').replace('\t', '').replace(' ', '')
if fd == '':
continue
files.append(fd)
return files
def analyse(args: list):
# 依赖列表
data = []
# 已分析过的文件
ldd = []
def _analyse(fs: list):
for item in fs:
# 已分析过
if item in ldd:
continue
# 分析
files = depends(item)
# 添加到已分析列表中
ldd.append(item)
if len(files) == 0:
continue
# 添加到依赖列表中
for file in files:
if file in data:
continue
data.append(file)
# 递归分析
_analyse(files)
_analyse(args)
return data
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yjihrp/qt-deploy.git
git@gitee.com:yjihrp/qt-deploy.git
yjihrp
qt-deploy
qt-deploy
master

搜索帮助