Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012
Public Member Functions | Public Attributes | Private Attributes

cmt2cmake::Project Class Reference

List of all members.

Public Member Functions

def __init__
def packages
def container
def name
def version
def uses
def generate
def process

Public Attributes

 path
 requirements

Private Attributes

 _packages
 _container

Detailed Description

Definition at line 554 of file cmt2cmake.py.


Constructor & Destructor Documentation

def cmt2cmake::Project::__init__ (   self,
  path 
)
Crete a project instance from the root directory of the project.

Definition at line 555 of file cmt2cmake.py.

00556                             :
00557         """
00558         Crete a project instance from the root directory of the project.
00559         """
00560         self.path = os.path.realpath(path)
00561         if not isProject(self.path):
00562             raise ValueError("%s is not a project" % self.path)
00563         self.requirements = os.path.join(self.path, "cmt", "project.cmt")
00564         # Private variables for cached properties
00565         self._packages = None
00566         self._container = None


Member Function Documentation

def cmt2cmake::Project::container (   self )
Name of the container package of the project.

The name of the container is deduced using the usual LHCb convention
(instead of the content of project.cmt).

Definition at line 583 of file cmt2cmake.py.

00584                        :
00585         """
00586         Name of the container package of the project.
00587 
00588         The name of the container is deduced using the usual LHCb convention
00589         (instead of the content of project.cmt).
00590         """
00591         if self._container is None:
00592             for suffix in ["Release", "Sys"]:
00593                 try:
00594                     # gets the first package that ends with the suffix, and does
00595                     # not have a hat.. or raise StopIteration
00596                     c = (p for p in self.packages
00597                          if p.endswith(suffix) and "/" not in p).next()
00598                     self._container = self.packages[c]
00599                     break
00600                 except StopIteration:
00601                     pass
00602         return self._container

def cmt2cmake::Project::generate (   self )

Definition at line 619 of file cmt2cmake.py.

00620                       :
00621         # list containing the lines to write to the file
00622         data = ["CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)",
00623                 "",
00624                 "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/modules  ${CMAKE_MODULE_PATH})",
00625                 "",
00626                 "#---------------------------------------------------------------",
00627                 "# Load macros and functions for Gaudi-based projects",
00628                 "find_package(GaudiProject)",
00629                 "#---------------------------------------------------------------",
00630                 "",
00631                 "# Declare project name and version"]
00632         l = "gaudi_project(%s %s" % (self.name, self.version)
00633         use = "\n                  ".join(["%s %s" % u for u in self.uses()])
00634         if use:
00635             l += "\n              USE " + use
00636         l += ")"
00637         data.append(l)
00638         return "\n".join(data) + "\n"

def cmt2cmake::Project::name (   self )

Definition at line 604 of file cmt2cmake.py.

00605                   :
00606         # The name of the project is the same of the container without
00607         # the 'Release' or 'Sys' suffixes.
00608         return self.container.name.replace("Release", "").replace("Sys", "")

def cmt2cmake::Project::packages (   self )
Dictionary of packages contained in the project.

Definition at line 568 of file cmt2cmake.py.

00569                       :
00570         """
00571         Dictionary of packages contained in the project.
00572         """
00573         if self._packages is None:
00574             self._packages = {}
00575             for root, dirs, _files in os.walk(self.path):
00576                 if isPackage(root):
00577                     p = Package(root, self)
00578                     name = os.path.relpath(p.path, self.path)
00579                     self._packages[name] = p
00580                     dirs[:] = []
00581         return self._packages

def cmt2cmake::Project::process (   self,
  force = False 
)

Definition at line 639 of file cmt2cmake.py.

00640                                   :
00641         # Prepare the project configuration
00642         cml = os.path.join(self.path, "CMakeLists.txt")
00643         if force or not os.path.exists(cml):
00644             # write the file
00645             data = self.generate()
00646             f = open(cml, "w")
00647             f.write(data)
00648             f.close()
00649         else:
00650             logging.warning("file %s already exists", cml)
00651         # Recurse in the packages
00652         for p in sorted(self.packages):
00653             self.packages[p].process(force)
00654 

def cmt2cmake::Project::uses (   self )

Definition at line 613 of file cmt2cmake.py.

00614                   :
00615         for l in open(self.requirements):
00616             l = l.split()
00617             if l and l[0] == "use" and l[1] != "LCGCMT" and len(l) == 3:
00618                 yield (projectCase(l[1]), l[2].rsplit('_', 1)[-1])

def cmt2cmake::Project::version (   self )

Definition at line 610 of file cmt2cmake.py.

00611                      :
00612         return self.container.version


Member Data Documentation

Definition at line 557 of file cmt2cmake.py.

Definition at line 557 of file cmt2cmake.py.

Definition at line 557 of file cmt2cmake.py.

Definition at line 557 of file cmt2cmake.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 Mon Sep 17 2012 13:49:53 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004