| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

git_tag_packages.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 Small script to create the git tags for a release of Gaudi.
4 """
5 __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
6
7 import os
8 import re
9 from subprocess import Popen, PIPE, STDOUT
10
11 def cmakelists(path):
12 """
13 Generator yielding the paths of the requirements files in a tree.
14 """
15 for dirpath, dirnames, filenames in os.walk(path):
16 if 'CMakeLists.txt' in filenames and dirpath != path:
17 dirnames[:] = [] # no need to recurse if we have a 'CMakeLists.txt'
18 yield os.path.join(dirpath, 'CMakeLists.txt')
19 else:
20 # some directories should be ignored
21 dirnames[:] = [dirname for dirname in dirnames
22 if not dirname.startswith('build.') and
23 dirname != 'cmake']
24
25 def getSubdirVer(cmakelists):
26 """
27 Extract subdir name and version from a CMakeLists.txt file.
28 """
29 pattern = re.compile(r"^\s*gaudi_subdir\s*\(\s*(\S+)\s+(\S+)\s*\)\s*$")
30 for l in open(cmakelists):
31 m = pattern.match(l.strip())
32 if m:
33 return m.groups()
34 return (None, None)
35
36 def main():
37 #from optparse import OptionParser
38 root = os.path.realpath(__file__)
39 root = os.path.dirname(root)
40 root = os.path.dirname(root)
41 root = os.path.dirname(root)
42 for p, v in map(getSubdirVer, cmakelists(root)):
43 if p and v:
44 cmd = ["git", "tag", "%s/%s" % (p, v)]
45 print " ".join(cmd) + ":",
46 git = Popen(cmd, stdout=PIPE, stderr=PIPE)
47 out, err = git.communicate()
48 if git.returncode == 0:
49 print "done"
50 else:
51 print "failed"
52 elif p:
53 print "WARNING: no version in subdir", p
54 elif v:
55 print "WARNING: found CMakeLists.txt with version (%s), but no subdir name" % v
56
57 if __name__ == "__main__":
58 main()
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
git_tag_packages.cmakelists
def cmakelists(path)
Definition: git_tag_packages.py:11
git_tag_packages.getSubdirVer
def getSubdirVer(cmakelists)
Definition: git_tag_packages.py:25
git_tag_packages.main
def main()
Definition: git_tag_packages.py:36