00001 import sys, re 00002 if len(sys.argv) != 4: 00003 print "ERROR: Usage %s <project> <version> <outputfile>"%sys.argv[0] 00004 exit(1) 00005 00006 project, version, outputfile = sys.argv[1:] 00007 print "Creating %s for %s %s"%(outputfile, project, version) 00008 00009 m = re.match("v([0-9]+)r([0-9]+)(?:p[0-9])?",version) 00010 majver, minver = [ int(x) for x in m.groups() ] 00011 00012 open(outputfile,"w").write( 00013 """#ifndef %(proj)s_VERSION 00014 /* Automatically generated file: do not modify! */ 00015 #ifndef CALC_GAUDI_VERSION 00016 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min)) 00017 #endif 00018 #define %(proj)s_MAJOR_VERSION %(maj)d 00019 #define %(proj)s_MINOR_VERSION %(min)d 00020 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION) 00021 #endif 00022 """%{ 'proj': project.upper(), 'min': minver, 'maj': majver })