添加 'install.py'

This commit is contained in:
xiaoyuluoke 2021-11-15 06:13:49 +00:00
parent a79620d141
commit 1c094aa322
1 changed files with 49 additions and 0 deletions

49
install.py Normal file
View File

@ -0,0 +1,49 @@
import string
class MyTemplate (string.Template):
delimiter ='@'
def getPyVenv():
tmplFileName = "D:\\project\\tools\\pyvenv.tmpl.cfg"
fileName = "D:\\project\\tools\\pyvenv.cfg"
with open(tmplFileName,"r",encoding = 'utf-8') as fr:
fileStr = MyTemplate(fr.read())
dataStr = fileStr.substitute(Python_Path = "D:\\\\project\\\\tools\\\\python")
with open (fileName,"w",encoding = "utf-8") as fw:
fw.write(dataStr)
fw.close()
fr.close()
def getCmakeTools():
tmplFileName = "D:\\project\\tools\\cmake-tools-kits.tmpl.json"
fileName = "D:\\project\\tools\\cmake-tools-kits.json"
with open(tmplFileName,"r",encoding = 'utf-8') as fr:
fileStr = MyTemplate(fr.read())
dataStr = fileStr.substitute(Install_Path = "D:\\\\project\\\\explab")
with open (fileName,"w",encoding = "utf-8") as fw:
fw.write(dataStr)
fw.close()
fr.close()
def getCSrcFile(cSrc_name):
tmplCFileName = "D:\\project\\tools\\src_c_.tmpl.c"
fileCName = "D:\\project\\tools\\" + cSrc_name + ".c"
tmplIncFileName = "D:\\project\\tools\\inc_c_.tmpl.h"
fileIncName = "D:\\project\\tools\\" + cSrc_name + ".h"
with open(tmplCFileName,"r",encoding = 'utf-8') as fr:
fileStr = MyTemplate(fr.read())
dataStr = fileStr.substitute(fileName = cSrc_name,include_str="",macro_str ="",type_str="",variable_str="",function_str ="")
with open (fileCName,"w",encoding = "utf-8") as fw:
fw.write(dataStr)
fw.close()
fr.close()
with open(tmplIncFileName,"r",encoding = 'utf-8') as fr:
fileStr = MyTemplate(fr.read())
dataStr = fileStr.substitute(macroName = cSrc_name.upper(),fileName = cSrc_name,include_str="",macro_str ="",type_str="",variable_str="",function_str ="")
with open (fileIncName,"w",encoding = "utf-8") as fw:
fw.write(dataStr)
fw.close()
fr.close()
if __name__ == "__main__":
# getCmakeTools();
getCSrcFile("buzz")