Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
make_heptools.HepToolsGenerator Class Reference
Inheritance diagram for make_heptools.HepToolsGenerator:
Inheritance graph
[legend]
Collaboration diagram for make_heptools.HepToolsGenerator:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def __repr__
 
def versions
 
def __str__
 

Public Attributes

 lcgcmt_root
 

Private Member Functions

def _content
 

Static Private Attributes

string __header__
 
string __trailer__
 
tuple __AA_projects__ ("COOL", "CORAL", "RELAX", "ROOT")
 
dictionary __special_dirs__
 
dictionary __special_names__ {"qt": "Qt"}
 

Detailed Description

Class wrapping the details needed to generate the toolchain file from LCGCMT.

Definition at line 10 of file make_heptools.py.

Constructor & Destructor Documentation

def make_heptools.HepToolsGenerator.__init__ (   self,
  lcgcmt_root 
)
Prepare the instance.

@param lcgcmt_root: path to the root directory of a given LCGCMT version

Definition at line 44 of file make_heptools.py.

44 
45  def __init__(self, lcgcmt_root):
46  """
47  Prepare the instance.
48 
49  @param lcgcmt_root: path to the root directory of a given LCGCMT version
50  """
51  self.lcgcmt_root = lcgcmt_root

Member Function Documentation

def make_heptools.HepToolsGenerator.__repr__ (   self)
Representation of the instance.

Definition at line 52 of file make_heptools.py.

52 
53  def __repr__(self):
54  """
55  Representation of the instance.
56  """
57  return "HepToolsGenerator(%r)" % self.lcgcmt_root
def make_heptools.HepToolsGenerator.__str__ (   self)
Return the content of the toolchain file.

Definition at line 168 of file make_heptools.py.

169  def __str__(self):
170  """
171  Return the content of the toolchain file.
172  """
173  return "\n".join(self._content())
def make_heptools.HepToolsGenerator._content (   self)
private
Generator producing the content (in blocks) of the toolchain file.

Definition at line 121 of file make_heptools.py.

122  def _content(self):
123  """
124  Generator producing the content (in blocks) of the toolchain file.
125  """
126  versions = self.versions
127 
128  yield self.__header__ % versions.pop("LCG")
129 
130  yield "\n# Application Area Projects"
131  for name in self.__AA_projects__:
132  # the width of the first string is bound to the length of the names
133  # in self.__AA_projects__
134  yield "LCG_AA_project(%-5s %s)" % (name, versions.pop(name))
135 
136  yield "\n# Compilers"
137  # @FIXME: to be made cleaner and more flexible
138  for compiler in [("gcc43", "gcc", "4.3.5"),
139  ("gcc46", "gcc", "4.6.2"),
140  ("gcc47", "gcc", "4.7.2"),
141  ("clang30", "clang", "3.0"),
142  ("gccmax", "gcc", "4.7.2")]:
143  yield "LCG_compiler(%s %s %s)" % compiler
144 
145  yield "\n# Externals"
146  lengths = (max(map(len, versions.keys())),
147  max(map(len, versions.values())),
148  max(map(len, self.__special_dirs__.values()))
149  )
150  template = "LCG_external_package(%%-%ds %%-%ds %%-%ds)" % lengths
151 
152  def packageSorting(pkg):
153  "special package sorting keys"
154  key = pkg.lower()
155  if key == "javajni":
156  key = "javasdk_javajni"
157  return key
158  for name in sorted(versions.keys(), key=packageSorting):
159  # special case
160  if name == "uuid":
161  yield "if(NOT ${LCG_OS}${LCG_OS_VERS} STREQUAL slc6) # uuid is not distributed with SLC6"
162  # LCG_external_package(CLHEP 1.9.4.7 clhep)
163  yield template % (name, versions[name], self.__special_dirs__.get(name, ""))
164  if name == "uuid":
165  yield "endif()"
166 
167  yield self.__trailer__
def make_heptools.HepToolsGenerator.versions (   self)
Extract the external names and versions from an installed LCGCMT.

@return: dictionary mapping external names to versions

Definition at line 59 of file make_heptools.py.

59 
60  def versions(self):
61  """
62  Extract the external names and versions from an installed LCGCMT.
63 
64  @return: dictionary mapping external names to versions
65  """
66  from itertools import imap
67  def statements(lines):
68  """
69  Generator of CMT statements from a list of lines.
70  """
71  statement = "" # we start with an empty statement
72  for l in imap(lambda l: l.rstrip(), lines): # CMT ignores spaces at the end of line when checking for '\'
73  # append the current line to the statement so far
74  statement += l
75  if statement.endswith("\\"):
76  # in this case we need to strip the '\' and continue the concatenation
77  statement = statement[:-1]
78  else:
79  # we can stop concatenating, but we return only non-trivial statements
80  statement = statement.strip()
81  if statement:
82  yield statement
83  statement = "" # we start collecting a new statement
84 
85  def tokens(statement):
86  """
87  Split a statement in tokens.
88 
89  Trivial implementation assuming the tokens do not contain spaces.
90  """
91  return statement.split()
92 
93  def macro(args):
94  """
95  Analyze the arguments of a macro command.
96 
97  @return: tuple (name, value, exceptionsDict)
98  """
99  unquote = lambda s: s.strip('"')
100  name = args[0]
101  value = unquote(args[1])
102  # make a dictionary of the even to odd remaining args (unquoting the values)
103  exceptions = dict(zip(args[2::2],
104  map(unquote, args[3::2])))
105  return name, value, exceptions
106 
107  # prepare the dictionary for the results
108  versions = {}
109  # We extract the statements from the requirements file of the LCG_Configuration package
110  req = open(os.path.join(self.lcgcmt_root, "LCG_Configuration", "cmt", "requirements"))
111  for toks in imap(tokens, statements(req)):
112  if toks.pop(0) == "macro": # get only the macros ...
113  name, value, exceptions = macro(toks)
114  if name.endswith("_config_version"): # that end with _config_version
115  name = name[:-len("_config_version")]
116  name = self.__special_names__.get(name, name)
117  for tag in ["target-slc"]: # we use the alternative for 'target-slc' if present
118  value = exceptions.get(tag, value)
119  versions[name] = value.replace('(', '{').replace(')', '}')
120  return versions

Member Data Documentation

tuple make_heptools.HepToolsGenerator.__AA_projects__ ("COOL", "CORAL", "RELAX", "ROOT")
staticprivate

Definition at line 30 of file make_heptools.py.

string make_heptools.HepToolsGenerator.__header__
staticprivate
Initial value:
1 """cmake_minimum_required(VERSION 2.8.5)
2 
3 # Declare the version of HEP Tools we use
4 # (must be done before including heptools-common to allow evolution of the
5 # structure)
6 set(heptools_version %s)
7 
8 include(${CMAKE_CURRENT_LIST_DIR}/heptools-common.cmake)
9 
10 # please keep alphabetic order and the structure (tabbing).
11 # it makes it much easier to edit/read this file!
12 """

Definition at line 14 of file make_heptools.py.

dictionary make_heptools.HepToolsGenerator.__special_dirs__
staticprivate
Initial value:
1 {"CLHEP": "clhep",
2  "fftw": "fftw3",
3  "Frontier_Client": "frontier_client",
4  "GCCXML": "gccxml",
5  "Qt": "qt",
6  "CASTOR": "castor",
7  "lfc": "Grid/LFC",
8  "TBB": "tbb",
9  }

Definition at line 32 of file make_heptools.py.

dictionary make_heptools.HepToolsGenerator.__special_names__ {"qt": "Qt"}
staticprivate

Definition at line 42 of file make_heptools.py.

string make_heptools.HepToolsGenerator.__trailer__
staticprivate
Initial value:
1 """
2 # Prepare the search paths according to the versions above
3 LCG_prepare_paths()"""

Definition at line 26 of file make_heptools.py.

make_heptools.HepToolsGenerator.lcgcmt_root

Definition at line 50 of file make_heptools.py.


The documentation for this class was generated from the following file:
Generated at Wed Jan 30 2013 17:13:52 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004