使用多线程编译,优化praper_vscode.py
This commit is contained in:
@@ -3,8 +3,38 @@ import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
|
||||
这个文件用于编译时输出编译符号,在makefile.cfg中调用
|
||||
自动更新vscode的c/c++配置
|
||||
|
||||
2024.9.28
|
||||
根据脚本位置来确定位置文件路径
|
||||
使用非冗余的路径
|
||||
使用宏定义字符转义
|
||||
|
||||
'''
|
||||
|
||||
|
||||
|
||||
def unescape(line:str):
|
||||
table=[("\\\"","\""),("\\<","<"),("\\>",">"),("\\$","$"),("\\(","("),("\\)",")")]
|
||||
for item in table:
|
||||
line=line.replace(item[0],item[1])
|
||||
# 删除多余的 $ 符号
|
||||
line=line.replace('$','')
|
||||
return line
|
||||
|
||||
|
||||
|
||||
def main(flag_file:str,target:str):
|
||||
make_flags=flag_file
|
||||
top_path=os.path.split(sys.argv[0])[0]
|
||||
current_path=os.path.abspath('.')
|
||||
if(make_flags!='clear'):
|
||||
with open(make_flags,encoding='utf-8') as f:
|
||||
@@ -14,7 +44,7 @@ def main(flag_file:str,target:str):
|
||||
else:
|
||||
flags=""
|
||||
print(time.strftime("%Y-%m-%d %H:%M:%S"),"clear vscode setting.")
|
||||
cfgs_file_path='/mnt/disk/work/kunlun/.vscode/c_cpp_properties.json'
|
||||
cfgs_file_path=f'{top_path}/.vscode/c_cpp_properties.json'
|
||||
with open(cfgs_file_path,encoding='utf-8') as f:
|
||||
cfgs=f.read()
|
||||
|
||||
@@ -24,11 +54,12 @@ def main(flag_file:str,target:str):
|
||||
def_list=[]
|
||||
for item in flags_list:
|
||||
if(item[:2]=='-D'):
|
||||
def_list.append(item[2:])
|
||||
def_list.append(unescape(item[2:]))
|
||||
elif(item[:2]=='-I'):
|
||||
p=item[2:]
|
||||
if(p[0]!='/'):
|
||||
p=os.path.join(current_path,p)
|
||||
p=os.path.normpath(p)
|
||||
if(os.path.exists(p)):
|
||||
inc_list.append(p)
|
||||
else:
|
||||
@@ -40,6 +71,7 @@ def main(flag_file:str,target:str):
|
||||
if(make_flags!='clear'):
|
||||
predef_info["name"]="myname"
|
||||
for item in inc_list:
|
||||
# 只有路径列表中不存在时才添加
|
||||
if(item not in predef_info["includePath"]):
|
||||
predef_info["includePath"].append(item)
|
||||
for item in def_list:
|
||||
|
Reference in New Issue
Block a user