author | timothy.murphy@nokia.com |
Sun, 17 Jan 2010 20:52:46 +0000 | |
branch | wip |
changeset 124 | e898967975af |
parent 115 | 5869e06bf2ac |
child 133 | 8184bb802ee1 |
permissions | -rw-r--r-- |
3 | 1 |
# |
2 |
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
14 |
# Description: |
3 | 15 |
# raptor module |
16 |
# This module represents the running Raptor program. Raptor is started |
|
17 |
# either by calling the Main() function, which creates an instance of |
|
18 |
# the raptor.Raptor class and calls its methods to perform a build based |
|
19 |
# on command-line parameters, or by explicitly creating a raptor.Raptor |
|
20 |
# instance and calling its methods to set-up and perform a build. |
|
21 |
# |
|
22 |
||
23 |
name = "sbs" # the public name for the raptor build tool |
|
24 |
env = "SBS_HOME" # the environment variable that locates us |
|
25 |
xml = "sbs_init.xml" # the primary initialisation file |
|
26 |
env2 = "HOME" # the environment variable that locates the user |
|
27 |
xml2 = ".sbs_init.xml" # the override initialisation file |
|
28 |
||
29 |
import generic_path |
|
30 |
import os |
|
31 |
import raptor_cache |
|
32 |
import raptor_cli |
|
33 |
import raptor_data |
|
34 |
import raptor_make |
|
5 | 35 |
import raptor_makefile |
3 | 36 |
import raptor_meta |
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
37 |
import raptor_timing |
3 | 38 |
import raptor_utilities |
39 |
import raptor_version |
|
40 |
import raptor_xml |
|
41 |
import filter_list |
|
42 |
import sys |
|
43 |
import types |
|
44 |
import time |
|
45 |
import re |
|
46 |
import traceback |
|
47 |
import pluginbox |
|
48 |
from xml.sax.saxutils import escape |
|
49 |
||
50 |
||
51 |
if not "HOSTPLATFORM" in os.environ or not "HOSTPLATFORM_DIR" in os.environ: |
|
52 |
print "Error: HOSTPLATFORM and HOSTPLATFORM_DIR must be set in the environment (this is usually done automatically by the startup script)." |
|
53 |
sys.exit(1) |
|
54 |
||
55 |
hostplatform = os.environ["HOSTPLATFORM"].split(" ") |
|
56 |
hostplatform_dir = os.environ["HOSTPLATFORM_DIR"] |
|
57 |
||
58 |
# defaults can use EPOCROOT |
|
5 | 59 |
|
3 | 60 |
if "EPOCROOT" in os.environ: |
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
61 |
incoming_epocroot = os.environ["EPOCROOT"] |
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
62 |
epocroot = incoming_epocroot.replace("\\","/") |
3 | 63 |
else: |
64 |
if 'linux' in hostplatform: |
|
65 |
epocroot=os.environ['HOME'] + os.sep + "epocroot" |
|
66 |
os.environ["EPOCROOT"] = epocroot |
|
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
67 |
incoming_epocroot = epocroot |
3 | 68 |
else: |
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
69 |
incoming_epocroot = "\\" |
3 | 70 |
epocroot = "/" |
71 |
os.environ["EPOCROOT"] = os.sep |
|
72 |
||
73 |
if "SBS_BUILD_DIR" in os.environ: |
|
74 |
sbs_build_dir = os.environ["SBS_BUILD_DIR"] |
|
75 |
else: |
|
76 |
sbs_build_dir = (epocroot + "/epoc32/build").replace("//","/") |
|
77 |
||
78 |
||
79 |
# only use default XML from the epoc32 tree if it exists |
|
80 |
defaultSystemConfig = "lib/config" |
|
81 |
epoc32UserConfigDir = generic_path.Join(epocroot, "epoc32/sbs_config") |
|
82 |
if epoc32UserConfigDir.isDir(): |
|
83 |
defaultSystemConfig = str(epoc32UserConfigDir) + os.pathsep + defaultSystemConfig |
|
84 |
||
85 |
# parameters that can be overriden by the sbs_init.xml file |
|
86 |
# or by the command-line. |
|
87 |
defaults = { |
|
88 |
"allowCommandLineOverrides" : True, |
|
89 |
"CLI" : "raptor_cli", |
|
90 |
"buildInformation" : generic_path.Path("bld.inf"), |
|
91 |
"defaultConfig" : "default", |
|
92 |
"jobs": 4, |
|
93 |
"keepGoing": False, |
|
94 |
"logFileName" : generic_path.Join(sbs_build_dir,"Makefile.%TIME.log"), |
|
95 |
"makeEngine" : "make", |
|
96 |
"preferBuildInfoToSystemDefinition" : False, |
|
97 |
"pruneDuplicateMakefiles": True, |
|
98 |
"quiet" : False, |
|
99 |
"systemConfig" : defaultSystemConfig, |
|
100 |
"systemDefinition" : generic_path.Path("System_Definition.xml"), |
|
101 |
"systemDefinitionBase" : generic_path.Path("."), |
|
102 |
"systemFLM" : generic_path.Path("lib/flm"), |
|
103 |
"systemPlugins" : generic_path.Path("python/plugins"), |
|
104 |
"topMakefile" : generic_path.Join(sbs_build_dir,"Makefile"), |
|
105 |
"tries": 1, |
|
106 |
"writeSingleMakefile": True, |
|
107 |
"ignoreOsDetection": False, |
|
108 |
"toolcheck": "on", |
|
109 |
"filterList": "filterterminal,filterlogfile" |
|
110 |
} |
|
111 |
||
112 |
||
5 | 113 |
|
114 |
class ModelNode(object): |
|
115 |
""" Represents any node in a a tree of build information |
|
116 |
e.g. a tree of bld.infs, mmps and finally things like resource blocks and string table blocks. |
|
117 |
This is before they are produced into "build" specs. |
|
118 |
""" |
|
119 |
||
120 |
def __init__(self, id, parent = None): |
|
121 |
self.id = id |
|
122 |
self.type = type |
|
123 |
self.specs = [] |
|
124 |
self.deps = [] |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
125 |
self.children = set() |
5 | 126 |
self.unfurled = False |
127 |
self.parent = parent |
|
128 |
||
129 |
# Allow one to make a set |
|
130 |
def __hash__(self): |
|
131 |
return hash(self.id) |
|
132 |
||
133 |
def __cmp__(self,other): |
|
134 |
return cmp(self.id, other) |
|
3 | 135 |
|
136 |
def __iter__(self): |
|
5 | 137 |
return iter(self.children) |
3 | 138 |
|
139 |
def __getitem__(self,x): |
|
140 |
if isinstance(x, slice): |
|
5 | 141 |
return self.children[x.start:x.stop] |
142 |
return self.children[x] |
|
3 | 143 |
|
144 |
def __setitem__(self,k, v): |
|
5 | 145 |
self.children[k] = v |
3 | 146 |
|
147 |
def __len__(self): |
|
5 | 148 |
return len(self.children) |
3 | 149 |
|
5 | 150 |
def add(self, item): |
151 |
return self.children.add(item) |
|
152 |
||
153 |
def isunfurled(self, c): |
|
154 |
return self.unfurled == False |
|
3 | 155 |
|
5 | 156 |
def unfurl(self, build): |
157 |
"""Find any children of this node by processing it, produces specs""" |
|
158 |
pass |
|
3 | 159 |
|
5 | 160 |
def unfurl_all(self, build): |
161 |
"""Unfurl self and all children - preparatory e.g for realisation""" |
|
162 |
if not self.unfurled: |
|
163 |
self.unfurl(build) |
|
3 | 164 |
|
5 | 165 |
self.realise_exports(build) # permit communication of dependencies between children |
3 | 166 |
|
5 | 167 |
for c in self.children: |
168 |
c.unfurl_all(build) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
169 |
|
3 | 170 |
|
5 | 171 |
def realise_exports(self, build): |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
172 |
"""Do the things that are needed such that we can fully unfurl all |
5 | 173 |
sibling nodes. i.e. this step is here to "take care" of the dependencies |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
174 |
between siblings. |
5 | 175 |
""" |
176 |
pass |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
177 |
|
5 | 178 |
def realise_makefile(self, build, specs): |
179 |
makefilename_base = build.topMakefile |
|
180 |
if self.name is not None: |
|
3 | 181 |
makefile = generic_path.Path(str(makefilename_base) + "_" + raptor_utilities.sanitise(self.name)) |
182 |
else: |
|
183 |
makefile = generic_path.Path(str(makefilename_base)) |
|
184 |
||
185 |
# insert the start time into the Makefile name? |
|
186 |
makefile.path = makefile.path.replace("%TIME", build.timestring) |
|
187 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
188 |
build.InfoDiscovery(object_type = "layers", count = 1) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
189 |
build.InfoStartTime(object_type = "layer", task = "parse", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
190 |
key = str(makefile.path)) |
5 | 191 |
makefileset = build.maker.Write(makefile, specs, build.buildUnitsToBuild) |
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
192 |
build.InfoEndTime(object_type = "layer", task = "parse", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
193 |
key = str(makefile.path)) |
5 | 194 |
|
195 |
return makefileset |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
196 |
|
5 | 197 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
198 |
|
5 | 199 |
def realise(self, build): |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
200 |
"""Give the spec trees to the make engine and actually |
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
201 |
"build" the product represented by this model node""" |
5 | 202 |
# Must ensure that all children are unfurled at this point |
203 |
self.unfurl_all(build) |
|
204 |
||
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
205 |
sp = self.specs |
5 | 206 |
|
207 |
build.AssertBuildOK() |
|
208 |
||
209 |
m = self.realise_makefile(build, sp) |
|
210 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
211 |
build.InfoStartTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
212 |
key = (str(m.directory) + "/" + str(m.filenamebase))) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
213 |
result = build.Make(m) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
214 |
build.InfoEndTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
215 |
key = (str(m.directory) + "/" + str(m.filenamebase))) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
216 |
|
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
217 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
218 |
return result |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
219 |
|
5 | 220 |
|
3 | 221 |
|
5 | 222 |
class Project(ModelNode): |
223 |
"""A project or, in symbian-speak, an MMP |
|
224 |
""" |
|
225 |
def __init__(self, filename, parent = None): |
|
226 |
super(Project,self).__init__(filename, parent = parent) |
|
227 |
# Assume that components are specified in mmp files for now |
|
228 |
# One day that tyranny might end. |
|
229 |
self.mmp_name = str(generic_path.Path.Absolute(filename)) |
|
230 |
self.id = self.mmp_name |
|
231 |
self.unfurled = False |
|
232 |
||
233 |
def makefile(self, makefilename_base, engine, named = False): |
|
234 |
"""Makefiles for individual mmps not feasible at the moment""" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
235 |
pass # Cannot, currently, "unfurl an mmp" directly but do want |
5 | 236 |
# to be able to simulate the overall recursive unfurling of a build. |
237 |
||
238 |
class Component(ModelNode): |
|
239 |
"""A group of projects or, in symbian-speak, a bld.inf. |
|
240 |
""" |
|
241 |
def __init__(self, filename): |
|
242 |
super(Component,self).__init__(filename) |
|
243 |
# Assume that components are specified in bld.inf files for now |
|
244 |
# One day that tyranny might end. |
|
245 |
self.bldinf = None # Slot for a bldinf object if we spot one later |
|
246 |
self.bldinf_filename = generic_path.Path.Absolute(filename) |
|
247 |
||
248 |
self.id = str(self.bldinf_filename) |
|
249 |
self.exportspecs = [] |
|
250 |
self.depfiles = [] |
|
251 |
self.unfurled = False # We can parse this |
|
252 |
||
253 |
def AddMMP(self, filename): |
|
254 |
self.children.add(Project(filename)) |
|
3 | 255 |
|
256 |
||
5 | 257 |
class Layer(ModelNode): |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
258 |
""" Some components that should be built togther |
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
259 |
e.g. a Layer in the system definition. |
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
260 |
""" |
5 | 261 |
def __init__(self, name, componentlist=[]): |
262 |
super(Layer,self).__init__(name) |
|
263 |
self.name = name |
|
264 |
||
265 |
for c in componentlist: |
|
266 |
self.children.add(Component(c)) |
|
267 |
||
268 |
def unfurl(self, build): |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
269 |
"""Discover the children of this layer. This involves parsing the component MetaData (bld.infs, mmps). |
5 | 270 |
Takes a raptor object as a parameter (build), together with a list of Configurations. |
271 |
||
272 |
We currently have parsers that work on collections of components/bld.infs and that cannot |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
273 |
parse at a "finer" level. So one can't 'unfurl' an mmp at the moment. |
5 | 274 |
|
275 |
Returns True if the object was successfully unfurled. |
|
276 |
""" |
|
277 |
||
278 |
# setup all our components |
|
279 |
for c in self.children: |
|
280 |
c.specs = [] |
|
281 |
||
282 |
self.configs = build.buildUnitsToBuild |
|
283 |
||
284 |
||
285 |
metaReader = None |
|
286 |
if len (self.children): |
|
287 |
try: |
|
288 |
# create a MetaReader that is aware of the list of |
|
289 |
# configurations that we are trying to build. |
|
290 |
metaReader = raptor_meta.MetaReader(build, build.buildUnitsToBuild) |
|
291 |
||
292 |
# convert the list of bld.inf files into a specification |
|
293 |
# hierarchy suitable for all the configurations we are using. |
|
294 |
self.specs = list(build.generic_specs) |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
295 |
self.specs.extend(metaReader.ReadBldInfFiles(self.children, doexport = build.doExport, dobuild = not build.doExportOnly)) |
5 | 296 |
|
297 |
except raptor_meta.MetaDataError, e: |
|
298 |
build.Error(e.Text) |
|
299 |
||
300 |
self.unfurled = True |
|
301 |
||
302 |
||
303 |
def meta_realise(self, build): |
|
304 |
"""Generate specs that can be used to "take care of" finding out more |
|
305 |
about this metaunit - i.e. one doesn't want to parse it immediately |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
306 |
but to create a makefile that will parse it. |
5 | 307 |
In this case it allows bld.infs to be parsed in parallel by make.""" |
308 |
||
3 | 309 |
# insert the start time into the Makefile name? |
310 |
||
5 | 311 |
buildconfig = build.GetConfig("build").GenerateBuildUnits(build.cache) |
312 |
self.configs = build.buildUnitsToBuild |
|
3 | 313 |
|
314 |
# Pass certain CLI flags through to the makefile-generating sbs calls |
|
315 |
cli_options = "" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
316 |
|
3 | 317 |
if build.debugOutput == True: |
318 |
cli_options += " -d" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
319 |
|
3 | 320 |
if build.ignoreOsDetection == True: |
321 |
cli_options += " -i" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
322 |
|
3 | 323 |
if build.keepGoing == True: |
324 |
cli_options += " -k" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
325 |
|
3 | 326 |
if build.quiet == True: |
327 |
cli_options += " -q" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
328 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
329 |
if build.timing == True: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
330 |
cli_options += " --timing" |
3 | 331 |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
332 |
|
5 | 333 |
nc = len(self.children) |
334 |
number_blocks = build.jobs |
|
3 | 335 |
block_size = (nc / number_blocks) + 1 |
336 |
component_blocks = [] |
|
337 |
spec_nodes = [] |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
338 |
|
3 | 339 |
b = 0 |
5 | 340 |
childlist = list(self.children) |
3 | 341 |
while b < nc: |
5 | 342 |
component_blocks.append(childlist[b:b+block_size]) |
3 | 343 |
b += block_size |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
344 |
|
5 | 345 |
while len(component_blocks[-1]) <= 0: |
3 | 346 |
component_blocks.pop() |
5 | 347 |
number_blocks -= 1 |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
348 |
|
5 | 349 |
build.Info("Parallel Parsing: bld.infs split into %d blocks\n", number_blocks) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
350 |
# Cause the binding makefiles to have the toplevel makefile's |
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
351 |
# name. The bindee's have __pp appended. |
5 | 352 |
tm = build.topMakefile.Absolute() |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
353 |
binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File())) |
5 | 354 |
build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp") |
355 |
||
3 | 356 |
loop_number = 0 |
357 |
for block in component_blocks: |
|
358 |
loop_number += 1 |
|
359 |
specNode = raptor_data.Specification("metadata_" + self.name) |
|
360 |
||
5 | 361 |
componentList = " ".join([str(c.bldinf_filename) for c in block]) |
362 |
||
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
363 |
|
5 | 364 |
configList = " ".join([c.name for c in self.configs if c.name != "build" ]) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
365 |
|
3 | 366 |
makefile_path = str(build.topMakefile) + "_" + str(loop_number) |
367 |
try: |
|
368 |
os.unlink(makefile_path) # until we have dependencies working properly |
|
369 |
except Exception,e: |
|
370 |
# print "couldn't unlink %s: %s" %(componentMakefileName, str(e)) |
|
371 |
pass |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
372 |
|
3 | 373 |
# add some basic data in a component-wide variant |
374 |
var = raptor_data.Variant() |
|
375 |
var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList)) |
|
376 |
var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path)) |
|
377 |
var.AddOperation(raptor_data.Set("CONFIGS", configList)) |
|
378 |
var.AddOperation(raptor_data.Set("CLI_OPTIONS", cli_options)) |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
379 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
380 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
381 |
# Allow the flm to skip exports. Note: this parameter |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
382 |
doexport_str = '1' |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
383 |
if not build.doExport: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
384 |
doexport_str = '' |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
385 |
var.AddOperation(raptor_data.Set("DOEXPORT", doexport_str )) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
386 |
|
3 | 387 |
# Pass on '-n' (if specified) to the makefile-generating sbs calls |
388 |
if build.noBuild: |
|
389 |
var.AddOperation(raptor_data.Set("NO_BUILD", "1")) |
|
390 |
specNode.AddVariant(var) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
391 |
|
3 | 392 |
try: |
393 |
interface = build.cache.FindNamedInterface("build.makefiles") |
|
394 |
specNode.SetInterface(interface) |
|
395 |
except KeyError: |
|
396 |
build.Error("Can't find flm interface 'build.makefiles' ") |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
397 |
|
3 | 398 |
spec_nodes.append(specNode) |
5 | 399 |
binding_makefiles.addInclude(str(makefile_path)+"_all") |
400 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
401 |
build.InfoDiscovery(object_type = "layers", count = 1) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
402 |
build.InfoStartTime(object_type = "layer", task = "parse", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
403 |
key = str(build.topMakefile)) |
5 | 404 |
m = self.realise_makefile(build, spec_nodes) |
405 |
m.close() |
|
406 |
gen_result = build.Make(m) |
|
3 | 407 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
408 |
build.InfoEndTime(object_type = "layer", task = "parse", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
409 |
key = str(build.topMakefile)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
410 |
build.InfoStartTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
411 |
key = str(build.topMakefile)) |
5 | 412 |
build.Debug("Binding Makefile base name is %s ", binding_makefiles.filenamebase) |
413 |
binding_makefiles.close() |
|
414 |
b = build.Make(binding_makefiles) |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
415 |
build.InfoEndTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
416 |
key = str(build.topMakefile)) |
5 | 417 |
return b |
3 | 418 |
|
419 |
||
5 | 420 |
|
421 |
||
422 |
class BuildCannotProgressException(Exception): |
|
3 | 423 |
pass |
424 |
||
425 |
# raptor module classes |
|
426 |
||
427 |
class Raptor(object): |
|
428 |
"""An instance of a running Raptor program. |
|
429 |
||
430 |
When operated from the command-line there is a single Raptor object |
|
431 |
created by the Main function. When operated by an IDE several Raptor |
|
432 |
objects may be created and operated at the same time.""" |
|
433 |
||
434 |
||
435 |
M_BUILD = 1 |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
436 |
M_VERSION = 2 |
3 | 437 |
|
438 |
def __init__(self, home = None): |
|
439 |
||
440 |
self.DefaultSetUp(home) |
|
441 |
||
442 |
||
443 |
def DefaultSetUp(self, home = None): |
|
444 |
"revert to the default set-up state" |
|
445 |
self.errorCode = 0 |
|
446 |
self.skipAll = False |
|
447 |
self.summary = True |
|
448 |
self.out = sys.stdout # Just until filters get started. |
|
449 |
||
450 |
# Create a bootstrap output system. |
|
451 |
self.out = filter_list.FilterList() |
|
452 |
||
453 |
if home == None: |
|
454 |
try: |
|
455 |
home = os.environ[env] |
|
456 |
except KeyError: |
|
457 |
home = os.getcwd() |
|
458 |
||
459 |
# make sure the home directory exists |
|
460 |
self.home = generic_path.Path(home).Absolute() |
|
461 |
||
462 |
if not self.home.isDir(): |
|
463 |
self.Error("%s '%s' is not a directory", env, self.home) |
|
464 |
return |
|
465 |
||
466 |
# the set-up file location. |
|
467 |
# use the override "env2/xml2" if it exists |
|
468 |
# else use the primary "env/xml" if it exists |
|
469 |
# else keep the hard-coded defaults. |
|
470 |
self.raptorXML = self.home.Append(xml) |
|
471 |
||
472 |
if env2 in os.environ: |
|
473 |
sbs_init = generic_path.Join(os.environ[env2], xml2) |
|
474 |
if sbs_init.isFile(): |
|
475 |
self.raptorXML = sbs_init |
|
476 |
||
477 |
# things that can be overridden by the set-up file |
|
478 |
for key, value in defaults.items(): |
|
479 |
self.__dict__[key] = value |
|
480 |
||
481 |
# things to initialise |
|
482 |
self.args = [] |
|
483 |
||
5 | 484 |
self.layers = [] |
485 |
self.orderLayers = False |
|
3 | 486 |
self.commandlineComponents = [] |
487 |
||
488 |
self.systemModel = None |
|
489 |
self.systemDefinitionFile = None |
|
490 |
self.systemDefinitionRequestedLayers = [] |
|
491 |
self.systemDefinitionOrderLayers = False |
|
492 |
||
493 |
self.specGroups = {} |
|
494 |
||
495 |
self.configNames = [] |
|
496 |
self.configsToBuild = set() |
|
497 |
self.makeOptions = [] |
|
498 |
self.maker = None |
|
499 |
self.debugOutput = False |
|
500 |
self.doExportOnly = False |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
501 |
self.doExport = True |
3 | 502 |
self.noBuild = False |
503 |
self.noDependInclude = False |
|
504 |
self.projects = set() |
|
505 |
||
506 |
self.cache = raptor_cache.Cache(self) |
|
507 |
self.override = {env: str(self.home)} |
|
508 |
self.targets = [] |
|
509 |
self.defaultTargets = [] |
|
510 |
||
511 |
self.doCheck = False |
|
512 |
self.doWhat = False |
|
513 |
self.doParallelParsing = False |
|
514 |
self.mission = Raptor.M_BUILD |
|
515 |
||
516 |
# what platform and filesystem are we running on? |
|
517 |
self.filesystem = raptor_utilities.getOSFileSystem() |
|
518 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
519 |
self.timing = False |
3 | 520 |
self.toolset = None |
521 |
||
522 |
self.starttime = time.time() |
|
523 |
self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S") |
|
524 |
||
525 |
self.fatalErrorState = False |
|
526 |
||
527 |
def AddConfigList(self, configPathList): |
|
528 |
# this function converts cmd line option into a list |
|
529 |
# and prepends it to default config. |
|
530 |
self.configPath = generic_path.NormalisePathList(configPathList.split(os.pathsep)) + self.configPath |
|
531 |
return True |
|
532 |
||
533 |
def AddConfigName(self, name): |
|
5 | 534 |
if name == "build": |
535 |
traceback.print_stack((sys.stdout)) |
|
536 |
sys.exit(1) |
|
3 | 537 |
self.configNames.append(name) |
538 |
return True |
|
539 |
||
540 |
def RunQuietly(self, TrueOrFalse): |
|
541 |
self.quiet = TrueOrFalse |
|
542 |
return True |
|
543 |
||
544 |
def SetCheck(self, TrueOrFalse): |
|
545 |
self.doCheck = TrueOrFalse |
|
546 |
return True |
|
547 |
||
548 |
def SetWhat(self, TrueOrFalse): |
|
549 |
self.doWhat = TrueOrFalse |
|
550 |
return True |
|
551 |
||
552 |
def SetEnv(self, name, value): |
|
553 |
self.override[name] = value |
|
554 |
||
555 |
def AddTarget(self, target): |
|
556 |
if self.doCheck or self.doWhat: |
|
557 |
self.Warn("ignoring target %s because --what or --check is specified.\n", target) |
|
558 |
else: |
|
559 |
self.targets.append(target) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
560 |
|
3 | 561 |
def AddSourceTarget(self, filename): |
562 |
# source targets are sanitised and then added as if they were a "normal" makefile target |
|
563 |
# in addition they have a default, empty, top-level target assigned in order that they can |
|
564 |
# be presented to any generated makefile without error |
|
565 |
sourceTarget = generic_path.Path(filename).Absolute() |
|
566 |
sourceTarget = 'SOURCETARGET_' + raptor_utilities.sanitise(str(sourceTarget)) |
|
567 |
self.AddTarget(sourceTarget) |
|
568 |
self.defaultTargets.append(sourceTarget) |
|
569 |
return True |
|
570 |
||
571 |
def SetSysDefFile(self, filename): |
|
572 |
self.systemDefinitionFile = generic_path.Path(filename) |
|
573 |
return True |
|
574 |
||
575 |
def SetSysDefBase(self, path): |
|
576 |
self.systemDefinitionBase = generic_path.Path(path) |
|
577 |
return True |
|
578 |
||
579 |
def AddSysDefLayer(self, layer): |
|
580 |
self.systemDefinitionRequestedLayers.append(layer) |
|
581 |
return True |
|
582 |
||
583 |
def SetSysDefOrderLayers(self, TrueOrFalse): |
|
584 |
self.systemDefinitionOrderLayers = TrueOrFalse |
|
585 |
return True |
|
586 |
||
587 |
def AddBuildInfoFile(self, filename): |
|
588 |
bldinf = generic_path.Path(filename).Absolute() |
|
589 |
self.commandlineComponents.append(bldinf) |
|
590 |
return True |
|
591 |
||
592 |
def SetTopMakefile(self, filename): |
|
593 |
self.topMakefile = generic_path.Path(filename) |
|
594 |
return True |
|
595 |
||
596 |
def SetDebugOutput(self, TrueOrFalse): |
|
597 |
self.debugOutput = TrueOrFalse |
|
598 |
return True |
|
599 |
||
600 |
def SetExportOnly(self, TrueOrFalse): |
|
601 |
self.doExportOnly = TrueOrFalse |
|
21
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
602 |
if not self.doExport: |
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
603 |
self.Error("The --noexport and --export-only options are incompatible - won't to do anything useful") |
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
604 |
return False |
3 | 605 |
return True |
606 |
||
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
607 |
def SetNoExport(self, TrueOrFalse): |
14 | 608 |
self.doExport = not TrueOrFalse |
21
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
609 |
if self.doExportOnly: |
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
610 |
self.Error("The --noexport and --export-only options are incompatible - won't to do anything useful") |
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
611 |
return False |
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
612 |
return True |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
613 |
|
3 | 614 |
def SetNoBuild(self, TrueOrFalse): |
615 |
self.noBuild = TrueOrFalse |
|
616 |
return True |
|
617 |
||
618 |
def SetNoDependInclude(self, TrueOrFalse): |
|
619 |
self.noDependInclude = TrueOrFalse |
|
620 |
return True |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
621 |
|
3 | 622 |
def SetKeepGoing(self, TrueOrFalse): |
623 |
self.keepGoing = TrueOrFalse |
|
624 |
return True |
|
625 |
||
626 |
def SetLogFileName(self, logfile): |
|
627 |
if logfile == "-": |
|
628 |
self.logFileName = None # stdout |
|
629 |
else: |
|
630 |
self.logFileName = generic_path.Path(logfile) |
|
631 |
return True |
|
632 |
||
633 |
def SetMakeEngine(self, makeEngine): |
|
634 |
self.makeEngine = makeEngine |
|
635 |
return True |
|
636 |
||
637 |
def AddMakeOption(self, makeOption): |
|
638 |
self.makeOptions.append(makeOption) |
|
639 |
return True |
|
640 |
||
641 |
def SetJobs(self, numberOfJobs): |
|
642 |
try: |
|
643 |
self.jobs = int(numberOfJobs) |
|
644 |
except ValueError: |
|
645 |
self.jobs = 0 |
|
646 |
||
647 |
if self.jobs < 1: |
|
648 |
self.Warn("The number of jobs (%s) must be a positive integer\n", numberOfJobs) |
|
649 |
self.jobs = 1 |
|
650 |
return False |
|
651 |
return True |
|
652 |
||
653 |
def SetTries(self, numberOfTries): |
|
654 |
try: |
|
655 |
self.tries = int(numberOfTries) |
|
656 |
except ValueError: |
|
657 |
self.tries = 0 |
|
658 |
||
659 |
if self.tries < 1: |
|
660 |
self.Warn("The number of tries (%s) must be a positive integer\n", numberOfTries) |
|
661 |
self.tries = 1 |
|
662 |
return False |
|
663 |
return True |
|
664 |
||
665 |
def SetToolCheck(self, type): |
|
666 |
type = type.lower() |
|
667 |
toolcheck_types= [ "forced", "on", "off" ] |
|
668 |
if type in toolcheck_types: |
|
669 |
self.toolcheck=type |
|
670 |
else: |
|
671 |
self.Warn("toolcheck option must be one of: %s" % toolcheck_types) |
|
672 |
return False |
|
673 |
||
674 |
return True |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
675 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
676 |
def SetTiming(self, TrueOrFalse): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
677 |
self.timing = TrueOrFalse |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
678 |
return True |
3 | 679 |
|
680 |
def SetParallelParsing(self, type): |
|
681 |
type = type.lower() |
|
682 |
if type == "on": |
|
683 |
self.doParallelParsing = True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
684 |
elif type == "slave": |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
685 |
self.isParallelParsingSlave = True |
3 | 686 |
elif type == "off": |
687 |
self.doParallelParsing = False |
|
688 |
else: |
|
689 |
self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)" % type) |
|
690 |
return False |
|
691 |
||
692 |
return True |
|
693 |
||
694 |
def AddProject(self, projectName): |
|
695 |
self.projects.add(projectName.lower()) |
|
696 |
return True |
|
697 |
||
698 |
def FilterList(self, value): |
|
699 |
self.filterList = value |
|
700 |
return True |
|
701 |
||
702 |
def IgnoreOsDetection(self, value): |
|
703 |
self.ignoreOsDetection = value |
|
704 |
return True |
|
705 |
||
706 |
def PrintVersion(self,dummy): |
|
707 |
global name |
|
5 | 708 |
print name, "version", raptor_version.fullversion() |
3 | 709 |
self.mission = Raptor.M_VERSION |
710 |
return False |
|
711 |
||
712 |
# worker methods |
|
713 |
||
714 |
def Introduction(self): |
|
715 |
"""Print a header of useful information about Raptor""" |
|
716 |
||
5 | 717 |
self.Info("%s: version %s\n", name, raptor_version.fullversion()) |
3 | 718 |
|
719 |
self.Info("%s %s", env, str(self.home)) |
|
720 |
self.Info("Set-up %s", str(self.raptorXML)) |
|
721 |
self.Info("Command-line-arguments %s", " ".join(self.args)) |
|
722 |
self.Info("Current working directory %s", os.getcwd()) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
723 |
|
3 | 724 |
# the inherited environment |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
725 |
for e, value in sorted( os.environ.items() ): |
5 | 726 |
self.Info("Environment %s=%s", e, value.replace("]]>", "]]>")) |
3 | 727 |
|
728 |
# and some general debug stuff |
|
729 |
self.Debug("Platform %s", "-".join(hostplatform)) |
|
730 |
self.Debug("Filesystem %s", self.filesystem) |
|
731 |
self.Debug("Python %d.%d.%d", *sys.version_info[:3]) |
|
732 |
self.Debug("Command-line-parser %s", self.CLI) |
|
733 |
||
734 |
for e,value in self.override.items(): |
|
735 |
self.Debug("Override %s = %s", e, value) |
|
736 |
||
737 |
for t in self.targets: |
|
738 |
self.Debug("Target %s", t) |
|
739 |
||
740 |
||
741 |
def ConfigFile(self): |
|
742 |
if not self.raptorXML.isFile(): |
|
743 |
return |
|
744 |
||
745 |
self.cache.Load(self.raptorXML) |
|
746 |
||
747 |
# find the 'defaults.raptor' variant and extract the values |
|
748 |
try: |
|
749 |
var = self.cache.FindNamedVariant("defaults.init") |
|
750 |
evaluator = self.GetEvaluator( None, raptor_data.BuildUnit(var.name,[var]) ) |
|
751 |
||
752 |
for key, value in defaults.items(): |
|
753 |
newValue = evaluator.Resolve(key) |
|
754 |
||
755 |
if newValue != None: |
|
756 |
# got a string for the value |
|
757 |
if type(value) == types.BooleanType: |
|
758 |
newValue = (newValue.lower() != "false") |
|
759 |
elif type(value) == types.IntType: |
|
760 |
newValue = int(newValue) |
|
761 |
elif isinstance(value, generic_path.Path): |
|
762 |
newValue = generic_path.Path(newValue) |
|
763 |
||
764 |
self.__dict__[key] = newValue |
|
765 |
||
766 |
except KeyError: |
|
767 |
# it is OK to not have this but useful to say it wasn't there |
|
768 |
self.Info("No 'defaults.init' configuration found in " + str(self.raptorXML)) |
|
769 |
||
770 |
||
771 |
def CommandLine(self, args): |
|
772 |
# remember the arguments for the log |
|
773 |
self.args = args |
|
774 |
||
775 |
# assuming self.CLI = "raptor_cli" |
|
776 |
more_to_do = raptor_cli.GetArgs(self, args) |
|
777 |
||
778 |
# resolve inter-argument dependencies. |
|
779 |
# --what or --check implies the WHAT target and FilterWhat Filter |
|
780 |
if self.doWhat or self.doCheck: |
|
781 |
self.targets = ["WHAT"] |
|
782 |
self.filterList = "filterwhat" |
|
783 |
||
784 |
else: |
|
785 |
# 1. CLEAN/CLEANEXPORT/REALLYCLEAN needs the FilterClean filter. |
|
786 |
# 2. Targets that clean should not be combined with other targets. |
|
787 |
||
788 |
targets = [x.lower() for x in self.targets] |
|
789 |
||
790 |
CL = "clean" |
|
791 |
CE = "cleanexport" |
|
792 |
RC = "reallyclean" |
|
793 |
||
794 |
is_clean = 0 |
|
795 |
is_suspicious_clean = 0 |
|
796 |
||
797 |
if CL in targets and CE in targets: |
|
798 |
is_clean = 1 |
|
799 |
if len(targets) > 2: |
|
800 |
is_suspicious_clean = 1 |
|
801 |
elif RC in targets or CL in targets or CE in targets: |
|
802 |
is_clean = 1 |
|
803 |
if len(targets) > 1: |
|
804 |
is_suspicious_clean = 1 |
|
805 |
||
806 |
if is_clean: |
|
807 |
self.filterList += ",filterclean" |
|
808 |
if is_suspicious_clean: |
|
809 |
self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.') |
|
810 |
||
811 |
if not more_to_do: |
|
812 |
self.skipAll = True # nothing else to do |
|
813 |
||
814 |
def ProcessConfig(self): |
|
815 |
# this function will perform additional processing of config |
|
816 |
||
817 |
# create list of generic paths |
|
818 |
self.configPath = generic_path.NormalisePathList(self.systemConfig.split(os.pathsep)) |
|
819 |
||
820 |
def LoadCache(self): |
|
821 |
def mkAbsolute(aGenericPath): |
|
822 |
""" internal function to make a generic_path.Path |
|
823 |
absolute if required""" |
|
824 |
if not aGenericPath.isAbsolute(): |
|
825 |
return self.home.Append(aGenericPath) |
|
826 |
else: |
|
827 |
return aGenericPath |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
828 |
|
3 | 829 |
# make generic paths absolute (if required) |
830 |
self.configPath = map(mkAbsolute, self.configPath) |
|
831 |
self.cache.Load(self.configPath) |
|
832 |
||
833 |
if not self.systemFLM.isAbsolute(): |
|
834 |
self.systemFLM = self.home.Append(self.systemFLM) |
|
835 |
||
836 |
self.cache.Load(self.systemFLM) |
|
837 |
||
838 |
def GetConfig(self, configname): |
|
839 |
names = configname.split(".") |
|
840 |
||
841 |
cache = self.cache |
|
842 |
||
843 |
base = names[0] |
|
844 |
mods = names[1:] |
|
845 |
||
846 |
if base in cache.groups: |
|
847 |
x = cache.FindNamedGroup(base) |
|
848 |
elif base in cache.aliases: |
|
849 |
x = cache.FindNamedAlias(base) |
|
850 |
elif base in cache.variants: |
|
851 |
x = cache.FindNamedVariant(base) |
|
852 |
else: |
|
853 |
raise Exception("Unknown build configuration '%s'" % configname) |
|
854 |
||
855 |
x.ClearModifiers() |
|
856 |
||
857 |
||
858 |
try: |
|
859 |
for m in mods: x.AddModifier( cache.FindNamedVariant(m) ) |
|
860 |
except KeyError: |
|
861 |
raise Exception("Unknown build configuration '%s'" % configname) |
|
862 |
return x |
|
863 |
||
864 |
def GetBuildUnitsToBuild(self, configNames): |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
865 |
"""Return a list of the configuration objects that correspond to the |
3 | 866 |
list of configuration names in the configNames parameter. |
867 |
||
868 |
raptor.GetBuildUnitsToBuild(["armv5", "winscw"]) |
|
869 |
>>> [ config1, config2, ... , configN ] |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
870 |
""" |
3 | 871 |
|
872 |
if len(configNames) == 0: |
|
873 |
# use default config |
|
874 |
if len(self.defaultConfig) == 0: |
|
875 |
self.Warn("No default configuration name") |
|
876 |
else: |
|
877 |
configNames.append(self.defaultConfig) |
|
878 |
||
879 |
buildUnitsToBuild = set() |
|
880 |
||
881 |
||
882 |
for c in set(configNames): |
|
5 | 883 |
self.Debug("BuildUnit: %s", c) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
884 |
try: |
3 | 885 |
x = self.GetConfig(c) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
886 |
gb = x.GenerateBuildUnits(self.cache) |
5 | 887 |
buildUnitsToBuild.update( gb ) |
3 | 888 |
except Exception, e: |
889 |
self.FatalError(str(e)) |
|
890 |
||
891 |
for b in buildUnitsToBuild: |
|
892 |
self.Info("Buildable configuration '%s'", b.name) |
|
893 |
||
894 |
if len(buildUnitsToBuild) == 0: |
|
895 |
self.Error("No build configurations given") |
|
896 |
||
897 |
return buildUnitsToBuild |
|
898 |
||
899 |
def CheckToolset(self, evaluator, configname): |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
900 |
"""Check the toolset for a particular config, allow other objects access |
3 | 901 |
to the toolset for this build (e.g. the raptor_make class).""" |
902 |
if self.toolset is None: |
|
903 |
if self.toolcheck == 'on': |
|
904 |
self.toolset = raptor_data.ToolSet(log=self) |
|
905 |
elif self.toolcheck == 'forced' : |
|
906 |
self.toolset = raptor_data.ToolSet(log=self, forced=True) |
|
907 |
else: |
|
908 |
return True |
|
909 |
||
910 |
return self.toolset.check(evaluator, configname) |
|
911 |
||
912 |
||
913 |
def CheckConfigs(self, configs): |
|
914 |
""" Tool checking for all the buildable configurations |
|
915 |
NB. We are allowed to use different tool versions for different |
|
916 |
configurations.""" |
|
917 |
||
918 |
tools_ok = True |
|
919 |
for b in configs: |
|
920 |
self.Debug("Tool check for %s", b.name) |
|
921 |
evaluator = self.GetEvaluator(None, b, gathertools=True) |
|
922 |
tools_ok = tools_ok and self.CheckToolset(evaluator, b.name) |
|
923 |
||
924 |
return tools_ok |
|
925 |
||
926 |
||
927 |
||
928 |
def GatherSysModelLayers(self, systemModel, systemDefinitionRequestedLayers): |
|
929 |
"""Return a list of lists of components to be built. |
|
930 |
||
931 |
components = GatherSysModelLayers(self, configurations) |
|
932 |
>>> set("abc/group/bld.inf","def/group/bld.inf, ....") |
|
933 |
""" |
|
934 |
layersToBuild = [] |
|
935 |
||
936 |
if systemModel: |
|
937 |
# We either process all available layers in the system model, or a subset of |
|
938 |
# layers specified on the command line. In both cases, the processing is the same, |
|
939 |
# and can be subject to ordering if explicitly requested. |
|
940 |
systemModel.DumpInfo() |
|
941 |
||
942 |
if systemDefinitionRequestedLayers: |
|
943 |
layersToProcess = systemDefinitionRequestedLayers |
|
944 |
else: |
|
945 |
layersToProcess = systemModel.GetLayerNames() |
|
946 |
||
947 |
for layer in layersToProcess: |
|
948 |
systemModel.DumpLayerInfo(layer) |
|
949 |
||
950 |
if systemModel.IsLayerBuildable(layer): |
|
5 | 951 |
layersToBuild.append(Layer(layer, |
3 | 952 |
systemModel.GetLayerComponents(layer))) |
953 |
||
954 |
return layersToBuild |
|
955 |
||
956 |
||
5 | 957 |
# Add bld.inf or system definition xml to command line layers (depending on preference) |
3 | 958 |
def FindSysDefIn(self, aDir = None): |
959 |
# Find a system definition file |
|
960 |
||
961 |
if aDir is None: |
|
962 |
dir = generic_path.CurrentDir() |
|
963 |
else: |
|
964 |
dir = generic_path.Path(aDir) |
|
965 |
||
966 |
sysDef = dir.Append(self.systemDefinition) |
|
967 |
if not sysDef.isFile(): |
|
968 |
return None |
|
969 |
||
970 |
return sysDef |
|
971 |
||
972 |
||
973 |
def FindComponentIn(self, aDir = None): |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
974 |
# look for a bld.inf |
3 | 975 |
|
976 |
if aDir is None: |
|
977 |
dir = generic_path.CurrentDir() |
|
978 |
else: |
|
979 |
dir = generic_path.Path(aDir) |
|
980 |
||
981 |
bldInf = dir.Append(self.buildInformation) |
|
982 |
componentgroup = [] |
|
983 |
||
984 |
if bldInf.isFile(): |
|
985 |
return bldInf |
|
986 |
||
987 |
return None |
|
988 |
||
989 |
def GenerateGenericSpecs(self, configsToBuild): |
|
990 |
# if a Configuration has any config-wide interfaces |
|
991 |
# then add a Specification node to call each of them. |
|
992 |
configWide = {} |
|
993 |
genericSpecs = [] |
|
994 |
for c in configsToBuild: |
|
995 |
evaluator = self.GetEvaluator(None, c) |
|
996 |
iface = evaluator.Get("INTERFACE.config") |
|
997 |
if iface: |
|
998 |
if iface in configWide: |
|
999 |
# seen it already, so reuse the node |
|
1000 |
filter = configWide[iface] |
|
1001 |
filter.AddConfigCondition(c.name) |
|
1002 |
else: |
|
1003 |
# create a new node |
|
5 | 1004 |
filter = raptor_data.Filter(name = "config_wide") |
3 | 1005 |
filter.AddConfigCondition(c.name) |
1006 |
for i in iface.split(): |
|
1007 |
spec = raptor_data.Specification(i) |
|
1008 |
spec.SetInterface(i) |
|
1009 |
filter.AddChildSpecification(spec) |
|
1010 |
# remember it, use it |
|
1011 |
configWide[iface] = filter |
|
1012 |
genericSpecs.append(filter) |
|
1013 |
||
1014 |
return genericSpecs |
|
1015 |
||
1016 |
||
1017 |
def GetEvaluator(self, specification, configuration, gathertools=False): |
|
1018 |
""" this will perform some caching later """ |
|
5 | 1019 |
return raptor_data.Evaluator(specification, configuration, gathertools=gathertools, cache = self.cache) |
3 | 1020 |
|
1021 |
||
5 | 1022 |
def Make(self, makefileset): |
1023 |
if not self.noBuild and makefileset is not None: |
|
1024 |
if self.maker.Make(makefileset): |
|
1025 |
self.Info("The make-engine exited successfully.") |
|
1026 |
return True |
|
1027 |
else: |
|
1028 |
self.Error("The make-engine exited with errors.") |
|
1029 |
return False |
|
1030 |
else: |
|
1031 |
self.Info("No build performed") |
|
3 | 1032 |
|
1033 |
||
1034 |
||
1035 |
def Report(self): |
|
1036 |
if self.quiet: |
|
1037 |
return |
|
1038 |
||
1039 |
self.endtime = time.time() |
|
1040 |
self.runtime = int(0.5 + self.endtime - self.starttime) |
|
1041 |
self.raptor_params.runtime = self.runtime |
|
1042 |
self.Info("Run time %s seconds" % self.runtime) |
|
1043 |
||
1044 |
def AssertBuildOK(self): |
|
5 | 1045 |
"""Raise a BuildCannotProgressException if no further processing is required |
3 | 1046 |
""" |
1047 |
if self.Skip(): |
|
5 | 1048 |
raise BuildCannotProgressException("") |
3 | 1049 |
|
1050 |
return True |
|
1051 |
||
1052 |
def Skip(self): |
|
1053 |
"""Indicate not to perform operation if: |
|
1054 |
fatalErrorState is set |
|
1055 |
an error code is set but we're not in keepgoing mode |
|
1056 |
""" |
|
1057 |
return self.fatalErrorState or ((self.errorCode != 0) and (not self.keepGoing)) |
|
1058 |
||
1059 |
||
1060 |
# log file open/close |
|
1061 |
||
1062 |
def OpenLog(self): |
|
1063 |
"""Open a log file for the various I/O methods to write to.""" |
|
1064 |
||
1065 |
try: |
|
1066 |
# Find all the raptor plugins and put them into a pluginbox. |
|
1067 |
if not self.systemPlugins.isAbsolute(): |
|
1068 |
self.systemPlugins = self.home.Append(self.systemPlugins) |
|
1069 |
||
1070 |
self.pbox = pluginbox.PluginBox(str(self.systemPlugins)) |
|
1071 |
||
1072 |
self.raptor_params = BuildStats(self) |
|
1073 |
||
1074 |
# Open the requested plugins using the pluginbox |
|
1075 |
self.out.open(self.raptor_params, self.filterList.split(','), self.pbox) |
|
1076 |
||
1077 |
# log header |
|
1078 |
self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n") |
|
1079 |
||
1080 |
namespace = "http://symbian.com/xml/build/log" |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1081 |
progress_namespace = "http://symbian.com/xml/build/log/progress" |
3 | 1082 |
schema = "http://symbian.com/xml/build/log/1_0.xsd" |
1083 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1084 |
self.out.write("<buildlog sbs_version=\"%s\" xmlns=\"%s\" xmlns:progress=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"%s %s\">\n" |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1085 |
% (raptor_version.fullversion(), namespace, progress_namespace, namespace, schema)) |
3 | 1086 |
self.logOpen = True |
1087 |
except Exception,e: |
|
1088 |
self.out = sys.stdout # make sure that we can actually get errors out. |
|
1089 |
self.logOpen = False |
|
9 | 1090 |
self.FatalError("Unable to open the output logs: %s" % str(e)) |
3 | 1091 |
|
1092 |
def CloseLog(self): |
|
1093 |
if self.logOpen: |
|
1094 |
self.out.summary() |
|
1095 |
self.out.write("</buildlog>\n") |
|
1096 |
||
1097 |
if not self.out.close(): |
|
1098 |
self.errorCode = 1 |
|
1099 |
||
1100 |
||
1101 |
def Cleanup(self): |
|
1102 |
# ensure that the toolset cache is flushed. |
|
1103 |
if self.toolset is not None: |
|
1104 |
self.toolset.write() |
|
1105 |
||
1106 |
# I/O methods |
|
1107 |
||
1108 |
@staticmethod |
|
1109 |
def attributeString(dictionary): |
|
1110 |
"turn a dictionary into a string of XML attributes" |
|
1111 |
atts = "" |
|
1112 |
for a,v in dictionary.items(): |
|
1113 |
atts += " " + a + "='" + v + "'" |
|
1114 |
return atts |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1115 |
|
3 | 1116 |
def Info(self, format, *extras, **attributes): |
1117 |
"""Send an information message to the configured channel |
|
1118 |
(XML control characters will be escaped) |
|
1119 |
""" |
|
1120 |
self.out.write("<info" + self.attributeString(attributes) + ">" + |
|
1121 |
escape(format % extras) + "</info>\n") |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1122 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1123 |
def InfoDiscovery(self, object_type, count): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1124 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1125 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1126 |
self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type, |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1127 |
count = count)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1128 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1129 |
Error(exception.Text, function = "InfoDiscoveryTime") |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1130 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1131 |
def InfoStartTime(self, object_type, task, key): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1132 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1133 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1134 |
self.out.write(raptor_timing.Timing.start_string(object_type = object_type, |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1135 |
task = task, key = key)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1136 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1137 |
Error(exception.Text, function = "InfoStartTime") |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1138 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1139 |
def InfoEndTime(self, object_type, task, key): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1140 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1141 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1142 |
self.out.write(raptor_timing.Timing.end_string(object_type = object_type, |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1143 |
task = task, key = key)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1144 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1145 |
Error(exception.Text, function = "InfoEndTime") |
3 | 1146 |
|
1147 |
def Debug(self, format, *extras, **attributes): |
|
1148 |
"Send a debugging message to the configured channel" |
|
1149 |
||
1150 |
# the debug text is out of our control so wrap it in a CDATA |
|
1151 |
# in case it contains characters special to XML... like <> |
|
1152 |
if self.debugOutput: |
|
1153 |
self.out.write("<debug" + self.attributeString(attributes) + ">" + |
|
1154 |
"><![CDATA[\n" + (format % extras) + "\n]]></debug>\n") |
|
1155 |
||
1156 |
def Warn(self, format, *extras, **attributes): |
|
1157 |
"""Send a warning message to the configured channel |
|
1158 |
(XML control characters will be escaped) |
|
1159 |
""" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1160 |
self.out.write("<warning" + self.attributeString(attributes) + ">" + |
3 | 1161 |
escape(format % extras) + "</warning>\n") |
1162 |
||
1163 |
def FatalError(self, format, *extras, **attributes): |
|
1164 |
"""Send an error message to the configured channel. This implies such a serious |
|
1165 |
error that the entire build must be shut down asap whilst still finishing off |
|
1166 |
correctly whatever housekeeping is possible e.g. producing error reports. |
|
1167 |
Remains quiet if the raptor object is already in a fatal state since there |
|
1168 |
further errors are probably triggered by the first. |
|
1169 |
""" |
|
1170 |
if not self.fatalErrorState: |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1171 |
self.out.write("<error" + self.attributeString(attributes) + ">" + |
3 | 1172 |
(format % extras) + "</error>\n") |
1173 |
self.errorCode = 1 |
|
1174 |
self.fatalErrorState = True |
|
1175 |
||
1176 |
def Error(self, format, *extras, **attributes): |
|
1177 |
"""Send an error message to the configured channel |
|
1178 |
(XML control characters will be escaped) |
|
1179 |
""" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1180 |
self.out.write("<error" + self.attributeString(attributes) + ">" + |
3 | 1181 |
escape(format % extras) + "</error>\n") |
1182 |
self.errorCode = 1 |
|
1183 |
||
1184 |
||
1185 |
def PrintXML(self, format, *extras): |
|
1186 |
"Print to configured channel (no newline is added) (assumes valid xml)" |
|
1187 |
if format: |
|
1188 |
self.out.write(format % extras) |
|
1189 |
||
5 | 1190 |
def GetLayersFromCLI(self): |
1191 |
"""Returns the list of layers as specified by the |
|
3 | 1192 |
commandline interface to Raptor e.g. parameters |
1193 |
or the current directory""" |
|
5 | 1194 |
layers=[] |
3 | 1195 |
# Look for bld.infs or sysdefs in the current dir if none were specified |
1196 |
if self.systemDefinitionFile == None and len(self.commandlineComponents) == 0: |
|
1197 |
if not self.preferBuildInfoToSystemDefinition: |
|
1198 |
cwd = os.getcwd() |
|
1199 |
self.systemDefinitionFile = self.FindSysDefIn(cwd) |
|
1200 |
if self.systemDefinitionFile == None: |
|
1201 |
aComponent = self.FindComponentIn(cwd) |
|
1202 |
if aComponent: |
|
5 | 1203 |
layers.append(Layer('default',[aComponent])) |
3 | 1204 |
else: |
1205 |
aComponent = self.FindComponentIn(cwd) |
|
1206 |
if aComponent is None: |
|
1207 |
self.systemDefinitionFile = self.FindSysDefIn(cwd) |
|
1208 |
else: |
|
5 | 1209 |
layers.append(Layer('default',[aComponent])) |
3 | 1210 |
|
5 | 1211 |
if len(layers) <= 0 and self.systemDefinitionFile == None: |
3 | 1212 |
self.Warn("No default bld.inf or system definition file found in current directory (%s)", cwd) |
1213 |
||
1214 |
# If we now have a System Definition to parse then get the layers of components |
|
1215 |
if self.systemDefinitionFile != None: |
|
1216 |
systemModel = raptor_xml.SystemModel(self, self.systemDefinitionFile, self.systemDefinitionBase) |
|
5 | 1217 |
layers = self.GatherSysModelLayers(systemModel, self.systemDefinitionRequestedLayers) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1218 |
|
3 | 1219 |
# Now get components specified on a commandline - build them after any |
1220 |
# layers in the system definition. |
|
1221 |
if len(self.commandlineComponents) > 0: |
|
5 | 1222 |
layers.append(Layer('commandline',self.commandlineComponents)) |
3 | 1223 |
|
1224 |
# If we aren't building components in order then flatten down |
|
1225 |
# the groups |
|
1226 |
if not self.systemDefinitionOrderLayers: |
|
1227 |
# Flatten the layers into one group of components if |
|
1228 |
# we are not required to build them in order. |
|
5 | 1229 |
newcg = Layer("all") |
1230 |
for cg in layers: |
|
1231 |
for c in cg: |
|
1232 |
newcg.add(c) |
|
1233 |
layers = [newcg] |
|
3 | 1234 |
|
5 | 1235 |
return layers |
3 | 1236 |
|
1237 |
def Build(self): |
|
1238 |
||
1239 |
if self.mission != Raptor.M_BUILD: # help or version requested instead. |
|
1240 |
return 0 |
|
1241 |
||
1242 |
# open the log file |
|
1243 |
self.OpenLog() |
|
1244 |
||
1245 |
||
1246 |
try: |
|
1247 |
# show the command and platform info |
|
1248 |
self.AssertBuildOK() |
|
1249 |
self.Introduction() |
|
1250 |
# establish an object cache |
|
1251 |
self.AssertBuildOK() |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1252 |
|
3 | 1253 |
self.LoadCache() |
1254 |
||
1255 |
# find out what configurations to build |
|
1256 |
self.AssertBuildOK() |
|
1257 |
buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames) |
|
1258 |
||
5 | 1259 |
self.buildUnitsToBuild = buildUnitsToBuild |
1260 |
||
3 | 1261 |
# find out what components to build, and in what way |
5 | 1262 |
layers = [] |
3 | 1263 |
|
1264 |
self.AssertBuildOK() |
|
1265 |
if len(buildUnitsToBuild) >= 0: |
|
5 | 1266 |
layers = self.GetLayersFromCLI() |
3 | 1267 |
|
5 | 1268 |
componentCount = reduce(lambda x,y : x + y, [len(cg) for cg in layers]) |
3 | 1269 |
|
1270 |
if not componentCount > 0: |
|
5 | 1271 |
raise BuildCannotProgressException("No components to build.") |
3 | 1272 |
|
1273 |
# check the configurations (tools versions) |
|
1274 |
self.AssertBuildOK() |
|
1275 |
||
1276 |
if self.toolcheck != 'off': |
|
1277 |
self.CheckConfigs(buildUnitsToBuild) |
|
1278 |
else: |
|
1279 |
self.Info(" Not Checking Tool Versions") |
|
1280 |
||
1281 |
self.AssertBuildOK() |
|
1282 |
||
5 | 1283 |
# Setup a make engine. |
1284 |
if not self.maker: |
|
1285 |
self.maker = raptor_make.MakeEngine(self) |
|
1286 |
if self.maker == None: |
|
1287 |
self.Error("No make engine present") |
|
3 | 1288 |
|
5 | 1289 |
self.AssertBuildOK() |
1290 |
||
1291 |
# if self.doParallelParsing and not (len(layers) == 1 and len(layers[0]) == 1): |
|
3 | 1292 |
if self.doParallelParsing: |
1293 |
# Create a Makefile to parse components in parallel and build them |
|
5 | 1294 |
for l in layers: |
1295 |
l.meta_realise(self) |
|
3 | 1296 |
else: |
1297 |
# Parse components serially, creating one set of makefiles |
|
1298 |
# create non-component specs |
|
5 | 1299 |
self.generic_specs = self.GenerateGenericSpecs(buildUnitsToBuild) |
3 | 1300 |
|
1301 |
self.AssertBuildOK() |
|
5 | 1302 |
for l in layers: |
3 | 1303 |
# create specs for a specific group of components |
5 | 1304 |
l.realise(self) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1305 |
|
5 | 1306 |
except BuildCannotProgressException,b: |
3 | 1307 |
if str(b) != "": |
1308 |
self.Info(str(b)) |
|
1309 |
||
1310 |
# final report |
|
1311 |
if not self.fatalErrorState: |
|
1312 |
self.Report() |
|
1313 |
||
1314 |
self.Cleanup() |
|
1315 |
||
1316 |
# close the log file |
|
1317 |
self.CloseLog() |
|
1318 |
||
1319 |
return self.errorCode |
|
1320 |
||
1321 |
@classmethod |
|
1322 |
def CreateCommandlineBuild(cls, argv): |
|
1323 |
""" Perform a 'typical' build. """ |
|
1324 |
# configure the framework |
|
1325 |
||
1326 |
build = Raptor() |
|
1327 |
build.AssertBuildOK() |
|
1328 |
build.ConfigFile() |
|
1329 |
build.ProcessConfig() |
|
1330 |
build.CommandLine(argv) |
|
1331 |
||
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1332 |
return build |
3 | 1333 |
|
1334 |
||
1335 |
||
1336 |
# Class for passing constricted parameters to filters |
|
1337 |
class BuildStats(object): |
|
1338 |
||
1339 |
def __init__(self, raptor_instance): |
|
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
1340 |
self.incoming_epocroot = incoming_epocroot |
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
59
diff
changeset
|
1341 |
self.epocroot = epocroot |
3 | 1342 |
self.logFileName = raptor_instance.logFileName |
1343 |
self.quiet = raptor_instance.quiet |
|
1344 |
self.doCheck = raptor_instance.doCheck |
|
1345 |
self.doWhat = raptor_instance.doWhat |
|
1346 |
self.platform = hostplatform |
|
1347 |
self.skipAll = raptor_instance.fatalErrorState |
|
1348 |
self.timestring = raptor_instance.timestring |
|
1349 |
self.targets = raptor_instance.targets |
|
1350 |
self.runtime = 0 |
|
1351 |
self.name = name |
|
1352 |
||
1353 |
||
1354 |
# raptor module functions |
|
1355 |
||
1356 |
def Main(argv): |
|
1357 |
"""The main entry point for Raptor. |
|
1358 |
||
1359 |
argv is a list of command-line parameters, |
|
1360 |
NOT including the name of the calling script. |
|
1361 |
||
1362 |
The return value is zero for success and non-zero for failure.""" |
|
1363 |
||
1364 |
DisplayBanner() |
|
1365 |
||
1366 |
# object which represents a build |
|
1367 |
b = Raptor.CreateCommandlineBuild(argv) |
|
1368 |
||
5 | 1369 |
return b.Build() |
3 | 1370 |
|
1371 |
||
1372 |
def DisplayBanner(): |
|
1373 |
"""Stuff that needs printing out for every command.""" |
|
1374 |
pass |
|
1375 |
||
1376 |
||
1377 |
||
5 | 1378 |
|
3 | 1379 |
# end of the raptor module |