python根据SVN版本号生成version.h
python生成version.h#!/usr/bin/python# -*- coding: UTF-8 -*-import sysimport reimport osdef open_file(name, flag):try:f = open(name, flag)return fexcept BaseException:return Nonereturn Nonedef run():try
·
python生成version.h
原创文章禁止转载 同步发布
python生成version.h
代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import re
import os
def open_file(name, flag):
try:
f = open(name, flag)
return f
except BaseException:
return None
return None
def run():
try:
rd = os.popen("svn info | findstr Revision:")
revision = rd.read()
search = re.search("\d+", revision)
if not search:
return False
ver = search.group()
fver = open_file("version.h", 'w+')
fver.write("#ifndef __MMM__VERSION_H__\n")
fver.write("#define __MMM__VERSION_H__\n")
ver = "1.0.0."+ver
print("version "+ver)
fver.write("#define VERSION \""+ver+"\"\n")
fver.write("#endif //__MMM__VERSION_H__\n")
fver.close()
return True
except BaseException:
return False
return False
if __name__ == "__main__":
if not run():
print('make ver error!')
更多推荐
已为社区贡献2条内容
所有评论(0)