build.gn自动添加 Makefile输出的src_files.txt文件

This commit is contained in:
2025-01-17 19:35:35 +08:00
parent f790b7f9d4
commit e202cbfdbe
18 changed files with 90 additions and 770 deletions

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
def read_srcs(base_dir:str,file_name:str,type:str="src"):
file_path=os.path.join(base_dir,file_name)
ret=[]
with open(file_path,mode='r',encoding='utf-8') as f:
d=f.read()
str_list=d.split()
for item in str_list:
if(type=="src"):
if(item.endswith(('.c','.S'))):
if(item[0]=='/'):
path=os.path.relpath(os.path.normpath(item),base_dir)
else:
path=os.path.normpath(item)
if not (path in ret):
ret.append(path)
elif(type=="inc"):
if not (item.endswith(('.c','.S'))):
if(item[0]=='/'):
path=os.path.relpath(os.path.normpath(item),base_dir)
else:
path=os.path.normpath(item)
if(os.path.exists(os.path.join(base_dir,path))):
if not (path in ret):
ret.append(path)
return ret
if __name__ == "__main__":
ret=read_srcs(sys.argv[1],sys.argv[2],sys.argv[3])
for item in ret:
print(item)