Go to the documentation of this file.00001 def main():
00002 import os, sys, re
00003 if len(sys.argv) != 4:
00004 print "ERROR: Usage %s <project> <version> <outputfile>"%sys.argv[0]
00005 exit(1)
00006
00007 project, version, outputfile = sys.argv[1:]
00008 print "Creating %s for %s %s"%(outputfile, project, version)
00009
00010 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)
00011 majver = int(m.groupdict()['maj_ver'])
00012 minver = int(m.groupdict()['min_ver'])
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 })
00030
00031 if __name__ == "__main__":
00032 main()