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|([A-Za-z]+\-))(?P<maj_ver>[0-9]+)(r|\-)(?P<min_ver>[0-9]+)(?:(p|\-)(?P<pat_ver>[0-9]+))?",version)
00012 majver = int(m.groupdict()['maj_ver'])
00013 minver = int(m.groupdict()['min_ver'])
00014
00015 outdir = os.path.dirname(outputfile)
00016 if not os.path.exists(outdir):
00017 print "Creating directory", outdir
00018 os.makedirs(outdir)
00019
00020 open(outputfile,"w").write(
00021 """#ifndef %(proj)s_VERSION
00022 /* Automatically generated file: do not modify! */
00023 #ifndef CALC_GAUDI_VERSION
00024 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
00025 #endif
00026 #define %(proj)s_MAJOR_VERSION %(maj)d
00027 #define %(proj)s_MINOR_VERSION %(min)d
00028 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
00029 #endif
00030 """%{ 'proj': project.upper(), 'min': minver, 'maj': majver })