9 #_build_search = re.compile('^(Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)', re.MULTILINE)
10 _build_search = re.compile('</patch>', re.MULTILINE)
13 """Counts the number of patches that have been made and
14 returns that as the build number."""
16 p = subprocess.Popen(['darcs', 'changes', '--xml-output'], stdout=subprocess.PIPE)
17 data = p.stdout.read()
18 build_num = len(_build_search.findall(data))
21 def createVersionHeader(path):
22 """Create a header file contianing our version number.
24 header = ['#ifdef _AUTOGEN_VERSION_HPP_',
25 '#define _AUTOGEN_VERSION_HPP_',
26 'const char *app_version_id = "%s"' % (getBuildNumber()),
29 if os.path.exists(path):
30 # we need to see if its one of our headers
31 stream = open(path, 'r')
32 line = stream.readline().strip()
35 raise RuntimeError("%s is not our header file" % path)
36 open(path,'w').writelines(os.linesep.join(header))
39 """Basic command line driver script.
40 Call with something like sys.argv[1:]
42 opts, args = getopt.getopt(arg_list, "h:",
44 for option, argument in opts:
45 if option in ("-h", "--header"):
46 createVersionHeader(argument)
49 print "%s" % (getBuildNumber())
52 if __name__ == '__main__':
53 sys.exit(main(sys.argv[1:]))