15 parser = OptionParser(usage=
"ERROR: Usage %prog <project> <version> <outputfile>")
16 parser.add_option(
"-q",
"--quiet", action=
"store_true",
17 help=
"Do not print messages.")
18 opts, args = parser.parse_args()
20 parser.error(
"wrong number of arguments")
22 project, version, outputfile = args
24 print "Creating %s for %s %s" % (outputfile, project, version)
26 if version.startswith(
'HEAD'):
27 majver, minver, patver = 999, 999, 0
29 for style
in [lhcb_ver_style, atlas_ver_style, plain_ver_style ] :
30 m = re.match(style, version)
33 majver = int(m.groupdict()[
'maj_ver'])
34 minver = int(m.groupdict()[
'min_ver'])
35 patver = int(m.groupdict()[
'pat_ver']
or 0)
37 outdir = os.path.dirname(outputfile)
38 if not os.path.exists(outdir):
40 print "Creating directory", outdir
44 outputdata =
"""#ifndef %(proj)s_VERSION
45 /* Automatically generated file: do not modify! */
46 #ifndef CALC_GAUDI_VERSION
47 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
49 #define %(proj)s_MAJOR_VERSION %(maj)d
50 #define %(proj)s_MINOR_VERSION %(min)d
51 #define %(proj)s_PATCH_VERSION %(pat)d
52 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
54 """ % {
'proj': project.upper(),
'min': minver,
'maj': majver,
'pat': patver }
58 f = open(outputfile,
"r")
65 if outputdata != olddata:
66 open(outputfile,
"w").write(outputdata)