#!/usr/bin/python
+import getopt
+import os
import re
import subprocess
import sys
build_num = len(_build_search.findall(data))
return build_num
-if __name__ == '__main__':
+def createVersionHeader(path):
+ """Create a header file contianing our version number.
+ """
+ header = ['#ifdef _AUTOGEN_VERSION_HPP_',
+ '#define _AUTOGEN_VERSION_HPP_',
+ 'const char *app_version_id = "%s"' % (getBuildNumber()),
+ '#endif',
+ '']
+ if os.path.exists(path):
+ # we need to see if its one of our headers
+ stream = open(path, 'r')
+ line = stream.readline().strip()
+ stream.close()
+ if line != header[0]:
+ raise RuntimeError("%s is not our header file" % path)
+ open(path,'w').writelines(os.linesep.join(header))
+
+def main(arg_list):
+ """Basic command line driver script.
+ Call with something like sys.argv[1:]
+ """
+ opts, args = getopt.getopt(arg_list, "h:",
+ ["header="])
+ for option, argument in opts:
+ if option in ("-h", "--header"):
+ createVersionHeader(argument)
+ return 0
+
print "%s" % (getBuildNumber())
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
\ No newline at end of file