1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
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!')
|