Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
createProjVersHeader Namespace Reference

Functions

def main
 

Function Documentation

def createProjVersHeader.main ( )

Definition at line 7 of file createProjVersHeader.py.

7 
8 def main():
9  parser = OptionParser(usage="ERROR: Usage %prog <project> <version> <outputfile>")
10  parser.add_option("-q", "--quiet", action="store_true",
11  help="Do not print messages.")
12  opts, args = parser.parse_args()
13  if len(args) != 3:
14  parser.error("wrong number of arguments")
15 
16  project, version, outputfile = args
17  if not opts.quiet:
18  print "Creating %s for %s %s" % (outputfile, project, version)
19 
20  if version.startswith('HEAD'):
21  majver, minver, patver = 999, 999, 0 # special handling
22  else:
23  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)
24  majver = int(m.groupdict()['maj_ver'])
25  minver = int(m.groupdict()['min_ver'])
26  patver = int(m.groupdict()['pat_ver'] or 0)
27 
28  outdir = os.path.dirname(outputfile)
29  if not os.path.exists(outdir):
30  if not opts.quiet:
31  print "Creating directory", outdir
32  os.makedirs(outdir)
33 
34  # Prepare data to be written
35  outputdata = """#ifndef %(proj)s_VERSION
36 /* Automatically generated file: do not modify! */
37 #ifndef CALC_GAUDI_VERSION
38 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
39 #endif
40 #define %(proj)s_MAJOR_VERSION %(maj)d
41 #define %(proj)s_MINOR_VERSION %(min)d
42 #define %(proj)s_PATCH_VERSION %(pat)d
43 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
44 #endif
45 """ % { 'proj': project.upper(), 'min': minver, 'maj': majver, 'pat': patver }
46 
47  # Get the current content of the destination file (if any)
48  try:
49  f = open(outputfile, "r")
50  olddata = f.read()
51  f.close()
52  except IOError:
53  olddata = None
54 
55  # Overwrite the file only if there are changes
56  if outputdata != olddata:
57  open(outputfile, "w").write(outputdata)

Generated at Wed Jan 30 2013 17:13:49 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004