59 lines
1.0 KiB
Python
59 lines
1.0 KiB
Python
import os
|
|
import sys
|
|
import shutil
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
def get_out_path(sub:str):
|
|
with open('ohos_config.json') as f:
|
|
j=json.loads(f.read())
|
|
return os.path.join(j["out_path"],sub)
|
|
|
|
|
|
# 找到指定后缀的文件
|
|
def find_type(path:str,fix:str):
|
|
dlist=os.listdir(path)
|
|
file_list=[]
|
|
for i in dlist:
|
|
ps=os.path.join(path, i)
|
|
if os.path.isdir(ps):
|
|
# file_list+=find_type(ps,fix)
|
|
pass
|
|
else:
|
|
if(ps[-len(fix):]==fix):
|
|
file_list.append(ps)
|
|
return file_list
|
|
|
|
|
|
|
|
|
|
# 读取map文件
|
|
def read_map():
|
|
file_list=find_type(get_out_path(''),".map")
|
|
# print(file_list)
|
|
obj_list=[]
|
|
key="obj/kernel"
|
|
for item in file_list:
|
|
with open(item) as f:
|
|
lines=f.readlines()
|
|
for line in lines:
|
|
off=line.find(key)
|
|
if(off>=0):
|
|
l=line[off:].split()[0]
|
|
if(l not in obj_list and l.endswith(".o")):
|
|
obj_list.append(l)
|
|
break
|
|
obj_list.sort()
|
|
return obj_list
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
obj_list=read_map()
|
|
for item in obj_list:
|
|
print(item+"(.*)")
|
|
|