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