3 Small tool to generate the heptools toolchain from a given LCGCMT.
5 __author__ =
"Marco Clemencic <marco.clemencic@cern.ch>"
12 Class wrapping the details needed to generate the toolchain file from LCGCMT.
14 __header__ =
"""cmake_minimum_required(VERSION 2.8.5)
16 # Declare the version of HEP Tools we use
17 # (must be done before including heptools-common to allow evolution of the
19 set(heptools_version %s)
21 include(${CMAKE_CURRENT_LIST_DIR}/heptools-common.cmake)
23 # please keep alphabetic order and the structure (tabbing).
24 # it makes it much easier to edit/read this file!
27 # Prepare the search paths according to the versions above
28 LCG_prepare_paths()"""
30 __AA_projects__ = (
"COOL",
"CORAL",
"RELAX",
"ROOT")
32 __special_dirs__ = {
"CLHEP":
"clhep",
34 "Frontier_Client":
"frontier_client",
42 __special_names__ = {
"qt":
"Qt"}
48 @param lcgcmt_root: path to the root directory of a given LCGCMT version
54 Representation of the instance.
61 Extract the external names and versions from an installed LCGCMT.
63 @return: dictionary mapping external names to versions
65 from itertools
import imap
66 def statements(lines):
68 Generator of CMT statements from a list of lines.
71 for l
in imap(
lambda l: l.rstrip(), lines):
74 if statement.endswith(
"\\"):
76 statement = statement[:-1]
79 statement = statement.strip()
84 def tokens(statement):
86 Split a statement in tokens.
88 Trivial implementation assuming the tokens do not contain spaces.
90 return statement.split()
94 Analyze the arguments of a macro command.
96 @return: tuple (name, value, exceptionsDict)
98 unquote =
lambda s: s.strip(
'"')
100 value = unquote(args[1])
102 exceptions = dict(zip(args[2::2],
103 map(unquote, args[3::2])))
104 return name, value, exceptions
109 req = open(os.path.join(self.
lcgcmt_root,
"LCG_Configuration",
"cmt",
"requirements"))
110 for toks
in imap(tokens, statements(req)):
111 if toks.pop(0) ==
"macro":
112 name, value, exceptions = macro(toks)
113 if name.endswith(
"_config_version"):
114 name = name[:-len(
"_config_version")]
115 name = self.__special_names__.get(name, name)
116 for tag
in [
"target-slc"]:
117 value = exceptions.get(tag, value)
118 versions[name] = value.replace(
'(',
'{').replace(
')',
'}')
123 Generator producing the content (in blocks) of the toolchain file.
129 yield "\n# Application Area Projects"
133 yield "LCG_AA_project(%-5s %s)" % (name, versions.pop(name))
135 yield "\n# Compilers"
137 for compiler
in [(
"gcc43",
"gcc",
"4.3.5"),
138 (
"gcc46",
"gcc",
"4.6.2"),
139 (
"gcc47",
"gcc",
"4.7.2"),
140 (
"clang30",
"clang",
"3.0"),
141 (
"gccmax",
"gcc",
"4.7.2")]:
142 yield "LCG_compiler(%s %s %s)" % compiler
144 yield "\n# Externals"
145 lengths = (max(map(len, versions.keys())),
146 max(map(len, versions.values())),
147 max(map(len, self.__special_dirs__.values()))
149 template =
"LCG_external_package(%%-%ds %%-%ds %%-%ds)" % lengths
151 def packageSorting(pkg):
152 "special package sorting keys"
155 key =
"javasdk_javajni"
157 for name
in sorted(versions.keys(), key=packageSorting):
160 yield "if(NOT ${LCG_OS}${LCG_OS_VERS} STREQUAL slc6) # uuid is not distributed with SLC6"
162 yield template % (name, versions[name], self.__special_dirs__.get(name,
""))
170 Return the content of the toolchain file.
174 if __name__ ==
'__main__':
176 if len(sys.argv) != 2
or not os.path.exists(sys.argv[1]):
177 print "Usage : %s <path to LCGCMT version>" % os.path.basename(sys.argv[0])