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",
39 "cgsigsoap":
"Grid/cgsi-gsoap",
42 "globus":
"Grid/globus",
43 "gridftp_ifce":
"Grid/gridftp-ifce",
44 "is_ifce":
"Grid/is-ifce",
45 "lcgdmcommon":
"Grid/lcg-dm-common",
47 "srm_ifce":
"Grid/srm-ifce",
48 "vomsapic":
"Grid/voms-api-c",
52 __special_names__ = {
"qt":
"Qt"}
58 @param lcgcmt_root: path to the root directory of a given LCGCMT version
64 Representation of the instance.
71 Extract the external names and versions from an installed LCGCMT.
73 @return: dictionary mapping external names to versions
75 from itertools
import imap
76 def statements(lines):
78 Generator of CMT statements from a list of lines.
81 for l
in imap(
lambda l: l.rstrip(), lines):
84 if statement.endswith(
"\\"):
86 statement = statement[:-1]
89 statement = statement.strip()
94 def tokens(statement):
96 Split a statement in tokens.
98 Trivial implementation assuming the tokens do not contain spaces.
100 return statement.split()
104 Analyze the arguments of a macro command.
106 @return: tuple (name, value, exceptionsDict)
108 unquote =
lambda s: s.strip(
'"')
110 value = unquote(args[1])
112 exceptions = dict(zip(args[2::2],
113 map(unquote, args[3::2])))
114 return name, value, exceptions
119 req = open(os.path.join(self.
lcgcmt_root,
"LCG_Configuration",
"cmt",
"requirements"))
120 for toks
in imap(tokens, statements(req)):
121 if toks.pop(0) ==
"macro":
122 name, value, exceptions = macro(toks)
123 if name.endswith(
"_config_version"):
124 name = name[:-len(
"_config_version")]
125 name = self.__special_names__.get(name, name)
126 for tag
in [
"target-slc"]:
127 value = exceptions.get(tag, value)
128 versions[name] = value.replace(
'(',
'{').replace(
')',
'}')
133 Generator producing the content (in blocks) of the toolchain file.
139 yield "\n# Application Area Projects"
143 yield "LCG_AA_project(%-5s %s)" % (name, versions.pop(name))
145 yield "\n# Compilers"
147 for compiler
in [(
"gcc43",
"gcc",
"4.3.5"),
148 (
"gcc46",
"gcc",
"4.6.2"),
149 (
"gcc47",
"gcc",
"4.7.2"),
150 (
"clang30",
"clang",
"3.0"),
151 (
"gccmax",
"gcc",
"4.7.2")]:
152 yield "LCG_compiler(%s %s %s)" % compiler
154 yield "\n# Externals"
155 lengths = (max(
map(len, versions.keys())),
156 max(
map(len, versions.values())),
157 max(
map(len, self.__special_dirs__.values()))
159 template =
"LCG_external_package(%%-%ds %%-%ds %%-%ds)" % lengths
161 def packageSorting(pkg):
162 "special package sorting keys"
165 key =
"javasdk_javajni"
167 for name
in sorted(versions.keys(), key=packageSorting):
170 yield "if(NOT ${LCG_OS}${LCG_OS_VERS} STREQUAL slc6) # uuid is not distributed with SLC6"
172 yield template % (name, versions[name], self.__special_dirs__.get(name,
""))
180 Return the content of the toolchain file.
184 if __name__ ==
'__main__':
186 if len(sys.argv) != 2
or not os.path.exists(sys.argv[1]):
187 print "Usage : %s <path to LCGCMT version>" % os.path.basename(sys.argv[0])