Gaudi Framework, version v23r3

Home   Generated: Thu Jun 28 2012
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes

make_heptools::HepToolsGenerator Class Reference

Collaboration diagram for make_heptools::HepToolsGenerator:
Collaboration graph
[legend]

List of all members.

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 40 of file make_heptools.py.

00041                                    :
00042         """
00043         Prepare the instance.
00044 
00045         @param lcgcmt_root: path to the root directory of a given LCGCMT version
00046         """
00047         self.lcgcmt_root = lcgcmt_root


Member Function Documentation

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

Definition at line 48 of file make_heptools.py.

00049                       :
00050         """
00051         Representation of the instance.
00052         """
00053         return "HepToolsGenerator(%r)" % self.lcgcmt_root

def make_heptools::HepToolsGenerator::__str__ (   self )
Return the content of the toolchain file.

Definition at line 164 of file make_heptools.py.

00165                      :
00166         """
00167         Return the content of the toolchain file.
00168         """
00169         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 117 of file make_heptools.py.

00118                       :
00119         """
00120         Generator producing the content (in blocks) of the toolchain file.
00121         """
00122         versions = self.versions
00123 
00124         yield self.__header__ % versions.pop("LCG")
00125 
00126         yield "\n# Application Area Projects"
00127         for name in self.__AA_projects__:
00128             # the width of the first string is bound to the length of the names
00129             # in self.__AA_projects__
00130             yield "LCG_AA_project(%-5s %s)" % (name, versions.pop(name))
00131 
00132         yield "\n# Compilers"
00133         # @FIXME: to be made cleaner and more flexible
00134         for compiler in [("gcc43", "gcc", "4.3.5"),
00135                          ("gcc46", "gcc", "4.6.2"),
00136                          ("gcc47", "gcc", "4.7.0"),
00137                          ("clang30", "clang", "3.0"),
00138                          ("gccmax", "gcc", "4.7.0")]:
00139             yield "LCG_compiler(%s %s %s)" % compiler
00140 
00141         yield "\n# Externals"
00142         lengths = (max(map(len, versions.keys())),
00143                    max(map(len, versions.values())),
00144                    max(map(len, self.__special_dirs__.values()))
00145                    )
00146         template = "LCG_external_package(%%-%ds %%-%ds %%-%ds)" % lengths
00147 
00148         def packageSorting(pkg):
00149             "special package sorting keys"
00150             key = pkg.lower()
00151             if key == "javajni":
00152                 key = "javasdk_javajni"
00153             return key
00154         for name in sorted(versions.keys(), key=packageSorting):
00155             # special case
00156             if name == "uuid":
00157                 yield "if(NOT ${os} STREQUAL slc6) # uuid is not distributed with SLC6"
00158             # LCG_external_package(CLHEP            1.9.4.7             clhep)
00159             yield template % (name, versions[name], self.__special_dirs__.get(name, ""))
00160             if name == "uuid":
00161                 yield "endif()"
00162 
00163         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 55 of file make_heptools.py.

00056                       :
00057         """
00058         Extract the external names and versions from an installed LCGCMT.
00059 
00060         @return: dictionary mapping external names to versions
00061         """
00062         from itertools import imap
00063         def statements(lines):
00064             """
00065             Generator of CMT statements from a list of lines.
00066             """
00067             statement = "" # we start with an empty statement
00068             for l in imap(lambda l: l.rstrip(), lines): # CMT ignores spaces at the end of line when checking for '\'
00069                 # append the current line to the statement so far
00070                 statement += l
00071                 if statement.endswith("\\"):
00072                     # in this case we need  to strip the '\' and continue the concatenation
00073                     statement = statement[:-1]
00074                 else:
00075                     # we can stop concatenating, but we return only non-trivial statements
00076                     statement = statement.strip()
00077                     if statement:
00078                         yield statement
00079                         statement = "" # we start collecting a new statement
00080 
00081         def tokens(statement):
00082             """
00083             Split a statement in tokens.
00084 
00085             Trivial implementation assuming the tokens do not contain spaces.
00086             """
00087             return statement.split()
00088 
00089         def macro(args):
00090             """
00091             Analyze the arguments of a macro command.
00092 
00093             @return: tuple (name, value, exceptionsDict)
00094             """
00095             unquote = lambda s: s.strip('"')
00096             name = args[0]
00097             value = unquote(args[1])
00098             # make a dictionary of the even to odd remaining args (unquoting the values)
00099             exceptions = dict(zip(args[2::2],
00100                                   map(unquote, args[3::2])))
00101             return name, value, exceptions
00102 
00103         # prepare the dictionary for the results
00104         versions = {}
00105         # We extract the statements from the requirements file of the LCG_Configuration package
00106         req = open(os.path.join(self.lcgcmt_root, "LCG_Configuration", "cmt", "requirements"))
00107         for toks in imap(tokens, statements(req)):
00108             if toks.pop(0) == "macro": # get only the macros ...
00109                 name, value, exceptions = macro(toks)
00110                 if name.endswith("_config_version"): # that end with _config_version
00111                     name = name[:-len("_config_version")]
00112                     name = self.__special_names__.get(name, name)
00113                     for tag in ["target-slc"]: # we use the alternative for 'target-slc' if present
00114                         value = exceptions.get(tag, value)
00115                     versions[name] = value.replace('(', '{').replace(')', '}')
00116         return versions


Member Data Documentation

tuple make_heptools::HepToolsGenerator::__AA_projects__ = ("COOL", "CORAL", "RELAX", "ROOT") [static, private]

Definition at line 30 of file make_heptools.py.

Initial value:
"""cmake_minimum_required(VERSION 2.8.5)

# Declare the version of HEP Tools we use
# (must be done before including heptools-common to allow evolution of the
# structure)
set(heptools_version  %s)

include(${CMAKE_CURRENT_LIST_DIR}/heptools-common.cmake)

# please keep alphabetic order and the structure (tabbing).
# it makes it much easier to edit/read this file!
"""

Definition at line 14 of file make_heptools.py.

Initial value:
{"CLHEP": "clhep",
                        "fftw": "fftw3",
                        "Frontier_Client": "frontier_client",
                        "GCCXML":  "gccxml",
                        }

Definition at line 32 of file make_heptools.py.

dictionary make_heptools::HepToolsGenerator::__special_names__ = {"qt": "Qt"} [static, private]

Definition at line 38 of file make_heptools.py.

Initial value:
"""
# Prepare the search paths according to the versions above
LCG_prepare_paths()"""

Definition at line 26 of file make_heptools.py.

Definition at line 44 of file make_heptools.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 12:30:25 for Gaudi Framework, version v23r3 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004