author | Jon Chatten |
Thu, 25 Feb 2010 14:55:31 +0000 | |
branch | fix |
changeset 266 | 23ff30e04b42 |
parent 226 | 59f343577f92 |
child 268 | 692d9a4eefc4 |
child 370 | c86748d54051 |
permissions | -rw-r--r-- |
3 | 1 |
# |
225
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
2 |
# Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 | 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"] |
136
d84e89d4dde4
Tab/space problem
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
133
diff
changeset
|
62 |
epocroot = incoming_epocroot.replace("\\","/") |
3 | 63 |
else: |
133
8184bb802ee1
In epocroot handling make windows the exceptional case because it is, use os.sep.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
64 |
if 'win' in hostplatform: |
8184bb802ee1
In epocroot handling make windows the exceptional case because it is, use os.sep.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
65 |
incoming_epocroot = os.sep |
8184bb802ee1
In epocroot handling make windows the exceptional case because it is, use os.sep.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
66 |
epocroot = "/" |
8184bb802ee1
In epocroot handling make windows the exceptional case because it is, use os.sep.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
67 |
os.environ["EPOCROOT"] = os.sep |
8184bb802ee1
In epocroot handling make windows the exceptional case because it is, use os.sep.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
68 |
else: |
3 | 69 |
epocroot=os.environ['HOME'] + os.sep + "epocroot" |
70 |
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
|
71 |
incoming_epocroot = epocroot |
3 | 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 |
|
225
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
332 |
if build.noDependInclude == True: |
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
333 |
cli_options += " --no-depend-include" |
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
334 |
|
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
335 |
if build.noDependGenerate == True: |
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
336 |
cli_options += " --no-depend-generate" |
d401dbd3a410
Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents:
219
diff
changeset
|
337 |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
338 |
|
5 | 339 |
nc = len(self.children) |
340 |
number_blocks = build.jobs |
|
3 | 341 |
block_size = (nc / number_blocks) + 1 |
342 |
component_blocks = [] |
|
343 |
spec_nodes = [] |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
344 |
|
3 | 345 |
b = 0 |
5 | 346 |
childlist = list(self.children) |
3 | 347 |
while b < nc: |
5 | 348 |
component_blocks.append(childlist[b:b+block_size]) |
3 | 349 |
b += block_size |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
350 |
|
5 | 351 |
while len(component_blocks[-1]) <= 0: |
3 | 352 |
component_blocks.pop() |
5 | 353 |
number_blocks -= 1 |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
354 |
|
5 | 355 |
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
|
356 |
# 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
|
357 |
# name. The bindee's have __pp appended. |
5 | 358 |
tm = build.topMakefile.Absolute() |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
359 |
binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File())) |
5 | 360 |
build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp") |
361 |
||
3 | 362 |
loop_number = 0 |
363 |
for block in component_blocks: |
|
364 |
loop_number += 1 |
|
365 |
specNode = raptor_data.Specification("metadata_" + self.name) |
|
366 |
||
5 | 367 |
componentList = " ".join([str(c.bldinf_filename) for c in block]) |
368 |
||
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
369 |
|
5 | 370 |
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
|
371 |
|
3 | 372 |
makefile_path = str(build.topMakefile) + "_" + str(loop_number) |
373 |
try: |
|
374 |
os.unlink(makefile_path) # until we have dependencies working properly |
|
375 |
except Exception,e: |
|
376 |
# print "couldn't unlink %s: %s" %(componentMakefileName, str(e)) |
|
377 |
pass |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
378 |
|
3 | 379 |
# add some basic data in a component-wide variant |
380 |
var = raptor_data.Variant() |
|
381 |
var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList)) |
|
382 |
var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path)) |
|
383 |
var.AddOperation(raptor_data.Set("CONFIGS", configList)) |
|
384 |
var.AddOperation(raptor_data.Set("CLI_OPTIONS", cli_options)) |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
385 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
386 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
387 |
# Allow the flm to skip exports. Note: this parameter |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
388 |
doexport_str = '1' |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
389 |
if not build.doExport: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
390 |
doexport_str = '' |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
391 |
var.AddOperation(raptor_data.Set("DOEXPORT", doexport_str )) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
392 |
|
3 | 393 |
# Pass on '-n' (if specified) to the makefile-generating sbs calls |
394 |
if build.noBuild: |
|
395 |
var.AddOperation(raptor_data.Set("NO_BUILD", "1")) |
|
396 |
specNode.AddVariant(var) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
397 |
|
3 | 398 |
try: |
399 |
interface = build.cache.FindNamedInterface("build.makefiles") |
|
400 |
specNode.SetInterface(interface) |
|
401 |
except KeyError: |
|
402 |
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
|
403 |
|
3 | 404 |
spec_nodes.append(specNode) |
5 | 405 |
binding_makefiles.addInclude(str(makefile_path)+"_all") |
406 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
407 |
build.InfoDiscovery(object_type = "layers", count = 1) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
408 |
build.InfoStartTime(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)) |
5 | 410 |
m = self.realise_makefile(build, spec_nodes) |
411 |
m.close() |
|
412 |
gen_result = build.Make(m) |
|
3 | 413 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
414 |
build.InfoEndTime(object_type = "layer", task = "parse", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
415 |
key = str(build.topMakefile)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
416 |
build.InfoStartTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
417 |
key = str(build.topMakefile)) |
5 | 418 |
build.Debug("Binding Makefile base name is %s ", binding_makefiles.filenamebase) |
419 |
binding_makefiles.close() |
|
420 |
b = build.Make(binding_makefiles) |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
421 |
build.InfoEndTime(object_type = "layer", task = "build", |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
422 |
key = str(build.topMakefile)) |
5 | 423 |
return b |
3 | 424 |
|
425 |
||
5 | 426 |
|
427 |
||
428 |
class BuildCannotProgressException(Exception): |
|
3 | 429 |
pass |
430 |
||
431 |
# raptor module classes |
|
432 |
||
433 |
class Raptor(object): |
|
434 |
"""An instance of a running Raptor program. |
|
435 |
||
436 |
When operated from the command-line there is a single Raptor object |
|
437 |
created by the Main function. When operated by an IDE several Raptor |
|
438 |
objects may be created and operated at the same time.""" |
|
439 |
||
440 |
||
441 |
M_BUILD = 1 |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
442 |
M_VERSION = 2 |
3 | 443 |
|
444 |
def __init__(self, home = None): |
|
445 |
||
446 |
self.DefaultSetUp(home) |
|
447 |
||
448 |
||
449 |
def DefaultSetUp(self, home = None): |
|
450 |
"revert to the default set-up state" |
|
451 |
self.errorCode = 0 |
|
452 |
self.skipAll = False |
|
453 |
self.summary = True |
|
454 |
self.out = sys.stdout # Just until filters get started. |
|
455 |
||
456 |
# Create a bootstrap output system. |
|
457 |
self.out = filter_list.FilterList() |
|
458 |
||
459 |
if home == None: |
|
460 |
try: |
|
461 |
home = os.environ[env] |
|
462 |
except KeyError: |
|
463 |
home = os.getcwd() |
|
464 |
||
465 |
# make sure the home directory exists |
|
466 |
self.home = generic_path.Path(home).Absolute() |
|
467 |
||
468 |
if not self.home.isDir(): |
|
469 |
self.Error("%s '%s' is not a directory", env, self.home) |
|
470 |
return |
|
471 |
||
472 |
# the set-up file location. |
|
473 |
# use the override "env2/xml2" if it exists |
|
474 |
# else use the primary "env/xml" if it exists |
|
475 |
# else keep the hard-coded defaults. |
|
476 |
self.raptorXML = self.home.Append(xml) |
|
477 |
||
478 |
if env2 in os.environ: |
|
479 |
sbs_init = generic_path.Join(os.environ[env2], xml2) |
|
480 |
if sbs_init.isFile(): |
|
481 |
self.raptorXML = sbs_init |
|
482 |
||
483 |
# things that can be overridden by the set-up file |
|
484 |
for key, value in defaults.items(): |
|
485 |
self.__dict__[key] = value |
|
486 |
||
487 |
# things to initialise |
|
488 |
self.args = [] |
|
489 |
||
5 | 490 |
self.layers = [] |
491 |
self.orderLayers = False |
|
3 | 492 |
self.commandlineComponents = [] |
493 |
||
494 |
self.systemModel = None |
|
495 |
self.systemDefinitionFile = None |
|
496 |
self.systemDefinitionRequestedLayers = [] |
|
497 |
self.systemDefinitionOrderLayers = False |
|
498 |
||
499 |
self.specGroups = {} |
|
500 |
||
501 |
self.configNames = [] |
|
502 |
self.configsToBuild = set() |
|
503 |
self.makeOptions = [] |
|
504 |
self.maker = None |
|
505 |
self.debugOutput = False |
|
506 |
self.doExportOnly = False |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
507 |
self.doExport = True |
3 | 508 |
self.noBuild = False |
509 |
self.noDependInclude = False |
|
219 | 510 |
self.noDependGenerate = False |
3 | 511 |
self.projects = set() |
512 |
||
513 |
self.cache = raptor_cache.Cache(self) |
|
514 |
self.override = {env: str(self.home)} |
|
515 |
self.targets = [] |
|
516 |
self.defaultTargets = [] |
|
517 |
||
518 |
self.doCheck = False |
|
519 |
self.doWhat = False |
|
520 |
self.doParallelParsing = False |
|
521 |
self.mission = Raptor.M_BUILD |
|
522 |
||
523 |
# what platform and filesystem are we running on? |
|
524 |
self.filesystem = raptor_utilities.getOSFileSystem() |
|
525 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
526 |
self.timing = False |
3 | 527 |
self.toolset = None |
528 |
||
529 |
self.starttime = time.time() |
|
530 |
self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S") |
|
531 |
||
532 |
self.fatalErrorState = False |
|
533 |
||
534 |
def AddConfigList(self, configPathList): |
|
535 |
# this function converts cmd line option into a list |
|
536 |
# and prepends it to default config. |
|
537 |
self.configPath = generic_path.NormalisePathList(configPathList.split(os.pathsep)) + self.configPath |
|
538 |
return True |
|
539 |
||
540 |
def AddConfigName(self, name): |
|
5 | 541 |
if name == "build": |
542 |
traceback.print_stack((sys.stdout)) |
|
543 |
sys.exit(1) |
|
3 | 544 |
self.configNames.append(name) |
545 |
return True |
|
546 |
||
547 |
def RunQuietly(self, TrueOrFalse): |
|
548 |
self.quiet = TrueOrFalse |
|
549 |
return True |
|
550 |
||
551 |
def SetCheck(self, TrueOrFalse): |
|
552 |
self.doCheck = TrueOrFalse |
|
553 |
return True |
|
554 |
||
555 |
def SetWhat(self, TrueOrFalse): |
|
556 |
self.doWhat = TrueOrFalse |
|
557 |
return True |
|
558 |
||
559 |
def SetEnv(self, name, value): |
|
560 |
self.override[name] = value |
|
561 |
||
562 |
def AddTarget(self, target): |
|
563 |
if self.doCheck or self.doWhat: |
|
564 |
self.Warn("ignoring target %s because --what or --check is specified.\n", target) |
|
565 |
else: |
|
566 |
self.targets.append(target) |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
567 |
|
3 | 568 |
def AddSourceTarget(self, filename): |
569 |
# source targets are sanitised and then added as if they were a "normal" makefile target |
|
570 |
# in addition they have a default, empty, top-level target assigned in order that they can |
|
571 |
# be presented to any generated makefile without error |
|
572 |
sourceTarget = generic_path.Path(filename).Absolute() |
|
573 |
sourceTarget = 'SOURCETARGET_' + raptor_utilities.sanitise(str(sourceTarget)) |
|
574 |
self.AddTarget(sourceTarget) |
|
575 |
self.defaultTargets.append(sourceTarget) |
|
576 |
return True |
|
577 |
||
578 |
def SetSysDefFile(self, filename): |
|
579 |
self.systemDefinitionFile = generic_path.Path(filename) |
|
580 |
return True |
|
581 |
||
582 |
def SetSysDefBase(self, path): |
|
583 |
self.systemDefinitionBase = generic_path.Path(path) |
|
584 |
return True |
|
585 |
||
586 |
def AddSysDefLayer(self, layer): |
|
587 |
self.systemDefinitionRequestedLayers.append(layer) |
|
588 |
return True |
|
589 |
||
590 |
def SetSysDefOrderLayers(self, TrueOrFalse): |
|
591 |
self.systemDefinitionOrderLayers = TrueOrFalse |
|
592 |
return True |
|
593 |
||
594 |
def AddBuildInfoFile(self, filename): |
|
595 |
bldinf = generic_path.Path(filename).Absolute() |
|
596 |
self.commandlineComponents.append(bldinf) |
|
597 |
return True |
|
598 |
||
599 |
def SetTopMakefile(self, filename): |
|
600 |
self.topMakefile = generic_path.Path(filename) |
|
601 |
return True |
|
602 |
||
603 |
def SetDebugOutput(self, TrueOrFalse): |
|
604 |
self.debugOutput = TrueOrFalse |
|
605 |
return True |
|
606 |
||
607 |
def SetExportOnly(self, TrueOrFalse): |
|
608 |
self.doExportOnly = TrueOrFalse |
|
21
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
609 |
if not self.doExport: |
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 |
3 | 612 |
return True |
613 |
||
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
614 |
def SetNoExport(self, TrueOrFalse): |
14 | 615 |
self.doExport = not TrueOrFalse |
21
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
616 |
if self.doExportOnly: |
a695dd5e4c37
Make --noexport and --export-only exclusive
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
617 |
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
|
618 |
return False |
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
619 |
return True |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
620 |
|
3 | 621 |
def SetNoBuild(self, TrueOrFalse): |
622 |
self.noBuild = TrueOrFalse |
|
623 |
return True |
|
624 |
||
625 |
def SetNoDependInclude(self, TrueOrFalse): |
|
626 |
self.noDependInclude = TrueOrFalse |
|
627 |
return True |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
628 |
|
219 | 629 |
def SetNoDependGenerate(self, TrueOrFalse): |
630 |
self.noDependGenerate = TrueOrFalse |
|
631 |
return True |
|
632 |
||
3 | 633 |
def SetKeepGoing(self, TrueOrFalse): |
634 |
self.keepGoing = TrueOrFalse |
|
635 |
return True |
|
636 |
||
637 |
def SetLogFileName(self, logfile): |
|
638 |
if logfile == "-": |
|
639 |
self.logFileName = None # stdout |
|
640 |
else: |
|
641 |
self.logFileName = generic_path.Path(logfile) |
|
642 |
return True |
|
643 |
||
644 |
def SetMakeEngine(self, makeEngine): |
|
193
8e61308a207e
don't break sbs_init.xml files with make engine validation changes
timothy.murphy@nokia.com
parents:
191
diff
changeset
|
645 |
self.makeEngine = makeEngine |
3 | 646 |
return True |
647 |
||
648 |
def AddMakeOption(self, makeOption): |
|
649 |
self.makeOptions.append(makeOption) |
|
650 |
return True |
|
651 |
||
652 |
def SetJobs(self, numberOfJobs): |
|
653 |
try: |
|
654 |
self.jobs = int(numberOfJobs) |
|
655 |
except ValueError: |
|
656 |
self.jobs = 0 |
|
657 |
||
658 |
if self.jobs < 1: |
|
659 |
self.Warn("The number of jobs (%s) must be a positive integer\n", numberOfJobs) |
|
660 |
self.jobs = 1 |
|
661 |
return False |
|
662 |
return True |
|
663 |
||
664 |
def SetTries(self, numberOfTries): |
|
665 |
try: |
|
666 |
self.tries = int(numberOfTries) |
|
667 |
except ValueError: |
|
668 |
self.tries = 0 |
|
669 |
||
670 |
if self.tries < 1: |
|
671 |
self.Warn("The number of tries (%s) must be a positive integer\n", numberOfTries) |
|
672 |
self.tries = 1 |
|
673 |
return False |
|
674 |
return True |
|
675 |
||
676 |
def SetToolCheck(self, type): |
|
677 |
type = type.lower() |
|
678 |
toolcheck_types= [ "forced", "on", "off" ] |
|
679 |
if type in toolcheck_types: |
|
680 |
self.toolcheck=type |
|
681 |
else: |
|
682 |
self.Warn("toolcheck option must be one of: %s" % toolcheck_types) |
|
683 |
return False |
|
684 |
||
685 |
return True |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
686 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
687 |
def SetTiming(self, TrueOrFalse): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
688 |
self.timing = TrueOrFalse |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
689 |
return True |
3 | 690 |
|
691 |
def SetParallelParsing(self, type): |
|
692 |
type = type.lower() |
|
693 |
if type == "on": |
|
694 |
self.doParallelParsing = True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
695 |
elif type == "slave": |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
696 |
self.isParallelParsingSlave = True |
3 | 697 |
elif type == "off": |
698 |
self.doParallelParsing = False |
|
699 |
else: |
|
700 |
self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)" % type) |
|
701 |
return False |
|
702 |
||
703 |
return True |
|
704 |
||
705 |
def AddProject(self, projectName): |
|
706 |
self.projects.add(projectName.lower()) |
|
707 |
return True |
|
708 |
||
709 |
def FilterList(self, value): |
|
710 |
self.filterList = value |
|
711 |
return True |
|
712 |
||
713 |
def IgnoreOsDetection(self, value): |
|
714 |
self.ignoreOsDetection = value |
|
715 |
return True |
|
716 |
||
717 |
def PrintVersion(self,dummy): |
|
718 |
global name |
|
5 | 719 |
print name, "version", raptor_version.fullversion() |
3 | 720 |
self.mission = Raptor.M_VERSION |
721 |
return False |
|
722 |
||
723 |
# worker methods |
|
724 |
||
725 |
def Introduction(self): |
|
726 |
"""Print a header of useful information about Raptor""" |
|
727 |
||
5 | 728 |
self.Info("%s: version %s\n", name, raptor_version.fullversion()) |
3 | 729 |
|
730 |
self.Info("%s %s", env, str(self.home)) |
|
731 |
self.Info("Set-up %s", str(self.raptorXML)) |
|
732 |
self.Info("Command-line-arguments %s", " ".join(self.args)) |
|
733 |
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
|
734 |
|
3 | 735 |
# the inherited environment |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
736 |
for e, value in sorted( os.environ.items() ): |
5 | 737 |
self.Info("Environment %s=%s", e, value.replace("]]>", "]]>")) |
3 | 738 |
|
739 |
# and some general debug stuff |
|
740 |
self.Debug("Platform %s", "-".join(hostplatform)) |
|
741 |
self.Debug("Filesystem %s", self.filesystem) |
|
742 |
self.Debug("Python %d.%d.%d", *sys.version_info[:3]) |
|
743 |
self.Debug("Command-line-parser %s", self.CLI) |
|
744 |
||
745 |
for e,value in self.override.items(): |
|
746 |
self.Debug("Override %s = %s", e, value) |
|
747 |
||
748 |
for t in self.targets: |
|
749 |
self.Debug("Target %s", t) |
|
750 |
||
751 |
||
752 |
def ConfigFile(self): |
|
753 |
if not self.raptorXML.isFile(): |
|
754 |
return |
|
755 |
||
756 |
self.cache.Load(self.raptorXML) |
|
757 |
||
758 |
# find the 'defaults.raptor' variant and extract the values |
|
759 |
try: |
|
760 |
var = self.cache.FindNamedVariant("defaults.init") |
|
761 |
evaluator = self.GetEvaluator( None, raptor_data.BuildUnit(var.name,[var]) ) |
|
762 |
||
763 |
for key, value in defaults.items(): |
|
764 |
newValue = evaluator.Resolve(key) |
|
765 |
||
766 |
if newValue != None: |
|
767 |
# got a string for the value |
|
768 |
if type(value) == types.BooleanType: |
|
769 |
newValue = (newValue.lower() != "false") |
|
770 |
elif type(value) == types.IntType: |
|
771 |
newValue = int(newValue) |
|
772 |
elif isinstance(value, generic_path.Path): |
|
773 |
newValue = generic_path.Path(newValue) |
|
774 |
||
775 |
self.__dict__[key] = newValue |
|
776 |
||
777 |
except KeyError: |
|
778 |
# it is OK to not have this but useful to say it wasn't there |
|
779 |
self.Info("No 'defaults.init' configuration found in " + str(self.raptorXML)) |
|
780 |
||
781 |
||
782 |
def CommandLine(self, args): |
|
783 |
# remember the arguments for the log |
|
784 |
self.args = args |
|
785 |
||
786 |
# assuming self.CLI = "raptor_cli" |
|
787 |
more_to_do = raptor_cli.GetArgs(self, args) |
|
788 |
||
789 |
# resolve inter-argument dependencies. |
|
790 |
# --what or --check implies the WHAT target and FilterWhat Filter |
|
791 |
if self.doWhat or self.doCheck: |
|
792 |
self.targets = ["WHAT"] |
|
793 |
self.filterList = "filterwhat" |
|
794 |
||
795 |
else: |
|
796 |
# 1. CLEAN/CLEANEXPORT/REALLYCLEAN needs the FilterClean filter. |
|
797 |
# 2. Targets that clean should not be combined with other targets. |
|
798 |
||
799 |
targets = [x.lower() for x in self.targets] |
|
800 |
||
801 |
CL = "clean" |
|
802 |
CE = "cleanexport" |
|
803 |
RC = "reallyclean" |
|
804 |
||
805 |
is_clean = 0 |
|
806 |
is_suspicious_clean = 0 |
|
807 |
||
808 |
if CL in targets and CE in targets: |
|
809 |
is_clean = 1 |
|
810 |
if len(targets) > 2: |
|
811 |
is_suspicious_clean = 1 |
|
812 |
elif RC in targets or CL in targets or CE in targets: |
|
813 |
is_clean = 1 |
|
814 |
if len(targets) > 1: |
|
815 |
is_suspicious_clean = 1 |
|
816 |
||
817 |
if is_clean: |
|
818 |
self.filterList += ",filterclean" |
|
819 |
if is_suspicious_clean: |
|
820 |
self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.') |
|
821 |
||
822 |
if not more_to_do: |
|
823 |
self.skipAll = True # nothing else to do |
|
824 |
||
825 |
def ProcessConfig(self): |
|
826 |
# this function will perform additional processing of config |
|
827 |
||
828 |
# create list of generic paths |
|
829 |
self.configPath = generic_path.NormalisePathList(self.systemConfig.split(os.pathsep)) |
|
830 |
||
831 |
def LoadCache(self): |
|
832 |
def mkAbsolute(aGenericPath): |
|
833 |
""" internal function to make a generic_path.Path |
|
834 |
absolute if required""" |
|
835 |
if not aGenericPath.isAbsolute(): |
|
836 |
return self.home.Append(aGenericPath) |
|
837 |
else: |
|
838 |
return aGenericPath |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
839 |
|
3 | 840 |
# make generic paths absolute (if required) |
841 |
self.configPath = map(mkAbsolute, self.configPath) |
|
842 |
self.cache.Load(self.configPath) |
|
843 |
||
844 |
if not self.systemFLM.isAbsolute(): |
|
845 |
self.systemFLM = self.home.Append(self.systemFLM) |
|
846 |
||
847 |
self.cache.Load(self.systemFLM) |
|
848 |
||
849 |
def GetConfig(self, configname): |
|
850 |
names = configname.split(".") |
|
851 |
||
852 |
cache = self.cache |
|
853 |
||
854 |
base = names[0] |
|
855 |
mods = names[1:] |
|
856 |
||
857 |
if base in cache.groups: |
|
858 |
x = cache.FindNamedGroup(base) |
|
859 |
elif base in cache.aliases: |
|
860 |
x = cache.FindNamedAlias(base) |
|
861 |
elif base in cache.variants: |
|
862 |
x = cache.FindNamedVariant(base) |
|
863 |
else: |
|
864 |
raise Exception("Unknown build configuration '%s'" % configname) |
|
865 |
||
866 |
x.ClearModifiers() |
|
867 |
||
868 |
||
869 |
try: |
|
870 |
for m in mods: x.AddModifier( cache.FindNamedVariant(m) ) |
|
871 |
except KeyError: |
|
872 |
raise Exception("Unknown build configuration '%s'" % configname) |
|
873 |
return x |
|
874 |
||
875 |
def GetBuildUnitsToBuild(self, configNames): |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
876 |
"""Return a list of the configuration objects that correspond to the |
3 | 877 |
list of configuration names in the configNames parameter. |
878 |
||
879 |
raptor.GetBuildUnitsToBuild(["armv5", "winscw"]) |
|
880 |
>>> [ config1, config2, ... , configN ] |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
881 |
""" |
3 | 882 |
|
883 |
if len(configNames) == 0: |
|
884 |
# use default config |
|
885 |
if len(self.defaultConfig) == 0: |
|
886 |
self.Warn("No default configuration name") |
|
887 |
else: |
|
888 |
configNames.append(self.defaultConfig) |
|
889 |
||
890 |
buildUnitsToBuild = set() |
|
891 |
||
892 |
||
893 |
for c in set(configNames): |
|
5 | 894 |
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
|
895 |
try: |
3 | 896 |
x = self.GetConfig(c) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
897 |
gb = x.GenerateBuildUnits(self.cache) |
5 | 898 |
buildUnitsToBuild.update( gb ) |
3 | 899 |
except Exception, e: |
900 |
self.FatalError(str(e)) |
|
901 |
||
902 |
for b in buildUnitsToBuild: |
|
903 |
self.Info("Buildable configuration '%s'", b.name) |
|
904 |
||
905 |
if len(buildUnitsToBuild) == 0: |
|
906 |
self.Error("No build configurations given") |
|
907 |
||
908 |
return buildUnitsToBuild |
|
909 |
||
910 |
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
|
911 |
"""Check the toolset for a particular config, allow other objects access |
3 | 912 |
to the toolset for this build (e.g. the raptor_make class).""" |
913 |
if self.toolset is None: |
|
914 |
if self.toolcheck == 'on': |
|
915 |
self.toolset = raptor_data.ToolSet(log=self) |
|
916 |
elif self.toolcheck == 'forced' : |
|
917 |
self.toolset = raptor_data.ToolSet(log=self, forced=True) |
|
918 |
else: |
|
919 |
return True |
|
920 |
||
921 |
return self.toolset.check(evaluator, configname) |
|
922 |
||
923 |
||
924 |
def CheckConfigs(self, configs): |
|
925 |
""" Tool checking for all the buildable configurations |
|
926 |
NB. We are allowed to use different tool versions for different |
|
927 |
configurations.""" |
|
928 |
||
929 |
tools_ok = True |
|
930 |
for b in configs: |
|
931 |
self.Debug("Tool check for %s", b.name) |
|
932 |
evaluator = self.GetEvaluator(None, b, gathertools=True) |
|
933 |
tools_ok = tools_ok and self.CheckToolset(evaluator, b.name) |
|
934 |
||
935 |
return tools_ok |
|
936 |
||
937 |
||
938 |
||
939 |
def GatherSysModelLayers(self, systemModel, systemDefinitionRequestedLayers): |
|
940 |
"""Return a list of lists of components to be built. |
|
941 |
||
942 |
components = GatherSysModelLayers(self, configurations) |
|
943 |
>>> set("abc/group/bld.inf","def/group/bld.inf, ....") |
|
944 |
""" |
|
945 |
layersToBuild = [] |
|
946 |
||
947 |
if systemModel: |
|
948 |
# We either process all available layers in the system model, or a subset of |
|
949 |
# layers specified on the command line. In both cases, the processing is the same, |
|
950 |
# and can be subject to ordering if explicitly requested. |
|
951 |
systemModel.DumpInfo() |
|
952 |
||
953 |
if systemDefinitionRequestedLayers: |
|
954 |
layersToProcess = systemDefinitionRequestedLayers |
|
955 |
else: |
|
956 |
layersToProcess = systemModel.GetLayerNames() |
|
957 |
||
958 |
for layer in layersToProcess: |
|
959 |
systemModel.DumpLayerInfo(layer) |
|
960 |
||
961 |
if systemModel.IsLayerBuildable(layer): |
|
5 | 962 |
layersToBuild.append(Layer(layer, |
3 | 963 |
systemModel.GetLayerComponents(layer))) |
964 |
||
965 |
return layersToBuild |
|
966 |
||
967 |
||
5 | 968 |
# Add bld.inf or system definition xml to command line layers (depending on preference) |
3 | 969 |
def FindSysDefIn(self, aDir = None): |
970 |
# Find a system definition file |
|
971 |
||
972 |
if aDir is None: |
|
973 |
dir = generic_path.CurrentDir() |
|
974 |
else: |
|
975 |
dir = generic_path.Path(aDir) |
|
976 |
||
977 |
sysDef = dir.Append(self.systemDefinition) |
|
978 |
if not sysDef.isFile(): |
|
979 |
return None |
|
980 |
||
981 |
return sysDef |
|
982 |
||
983 |
||
984 |
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
|
985 |
# look for a bld.inf |
3 | 986 |
|
987 |
if aDir is None: |
|
988 |
dir = generic_path.CurrentDir() |
|
989 |
else: |
|
990 |
dir = generic_path.Path(aDir) |
|
991 |
||
992 |
bldInf = dir.Append(self.buildInformation) |
|
993 |
componentgroup = [] |
|
994 |
||
995 |
if bldInf.isFile(): |
|
996 |
return bldInf |
|
997 |
||
998 |
return None |
|
999 |
||
1000 |
def GenerateGenericSpecs(self, configsToBuild): |
|
1001 |
# if a Configuration has any config-wide interfaces |
|
1002 |
# then add a Specification node to call each of them. |
|
1003 |
configWide = {} |
|
1004 |
genericSpecs = [] |
|
1005 |
for c in configsToBuild: |
|
1006 |
evaluator = self.GetEvaluator(None, c) |
|
1007 |
iface = evaluator.Get("INTERFACE.config") |
|
1008 |
if iface: |
|
1009 |
if iface in configWide: |
|
1010 |
# seen it already, so reuse the node |
|
1011 |
filter = configWide[iface] |
|
1012 |
filter.AddConfigCondition(c.name) |
|
1013 |
else: |
|
1014 |
# create a new node |
|
5 | 1015 |
filter = raptor_data.Filter(name = "config_wide") |
3 | 1016 |
filter.AddConfigCondition(c.name) |
1017 |
for i in iface.split(): |
|
1018 |
spec = raptor_data.Specification(i) |
|
1019 |
spec.SetInterface(i) |
|
1020 |
filter.AddChildSpecification(spec) |
|
1021 |
# remember it, use it |
|
1022 |
configWide[iface] = filter |
|
1023 |
genericSpecs.append(filter) |
|
1024 |
||
1025 |
return genericSpecs |
|
1026 |
||
1027 |
||
1028 |
def GetEvaluator(self, specification, configuration, gathertools=False): |
|
1029 |
""" this will perform some caching later """ |
|
5 | 1030 |
return raptor_data.Evaluator(specification, configuration, gathertools=gathertools, cache = self.cache) |
3 | 1031 |
|
1032 |
||
5 | 1033 |
def Make(self, makefileset): |
1034 |
if not self.noBuild and makefileset is not None: |
|
1035 |
if self.maker.Make(makefileset): |
|
1036 |
self.Info("The make-engine exited successfully.") |
|
1037 |
return True |
|
1038 |
else: |
|
1039 |
self.Error("The make-engine exited with errors.") |
|
1040 |
return False |
|
1041 |
else: |
|
1042 |
self.Info("No build performed") |
|
3 | 1043 |
|
1044 |
||
1045 |
||
1046 |
def Report(self): |
|
1047 |
if self.quiet: |
|
1048 |
return |
|
1049 |
||
1050 |
self.endtime = time.time() |
|
1051 |
self.runtime = int(0.5 + self.endtime - self.starttime) |
|
1052 |
self.raptor_params.runtime = self.runtime |
|
1053 |
self.Info("Run time %s seconds" % self.runtime) |
|
1054 |
||
1055 |
def AssertBuildOK(self): |
|
5 | 1056 |
"""Raise a BuildCannotProgressException if no further processing is required |
3 | 1057 |
""" |
1058 |
if self.Skip(): |
|
5 | 1059 |
raise BuildCannotProgressException("") |
3 | 1060 |
|
1061 |
return True |
|
1062 |
||
1063 |
def Skip(self): |
|
1064 |
"""Indicate not to perform operation if: |
|
1065 |
fatalErrorState is set |
|
1066 |
an error code is set but we're not in keepgoing mode |
|
1067 |
""" |
|
1068 |
return self.fatalErrorState or ((self.errorCode != 0) and (not self.keepGoing)) |
|
1069 |
||
1070 |
||
1071 |
# log file open/close |
|
1072 |
||
1073 |
def OpenLog(self): |
|
1074 |
"""Open a log file for the various I/O methods to write to.""" |
|
1075 |
||
1076 |
try: |
|
1077 |
# Find all the raptor plugins and put them into a pluginbox. |
|
1078 |
if not self.systemPlugins.isAbsolute(): |
|
1079 |
self.systemPlugins = self.home.Append(self.systemPlugins) |
|
1080 |
||
1081 |
self.pbox = pluginbox.PluginBox(str(self.systemPlugins)) |
|
1082 |
||
1083 |
self.raptor_params = BuildStats(self) |
|
1084 |
||
1085 |
# Open the requested plugins using the pluginbox |
|
1086 |
self.out.open(self.raptor_params, self.filterList.split(','), self.pbox) |
|
1087 |
||
1088 |
# log header |
|
1089 |
self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n") |
|
1090 |
||
1091 |
namespace = "http://symbian.com/xml/build/log" |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1092 |
progress_namespace = "http://symbian.com/xml/build/log/progress" |
3 | 1093 |
schema = "http://symbian.com/xml/build/log/1_0.xsd" |
1094 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1095 |
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
|
1096 |
% (raptor_version.fullversion(), namespace, progress_namespace, namespace, schema)) |
3 | 1097 |
self.logOpen = True |
1098 |
except Exception,e: |
|
1099 |
self.out = sys.stdout # make sure that we can actually get errors out. |
|
1100 |
self.logOpen = False |
|
9 | 1101 |
self.FatalError("Unable to open the output logs: %s" % str(e)) |
3 | 1102 |
|
1103 |
def CloseLog(self): |
|
1104 |
if self.logOpen: |
|
1105 |
self.out.summary() |
|
1106 |
self.out.write("</buildlog>\n") |
|
1107 |
||
1108 |
if not self.out.close(): |
|
1109 |
self.errorCode = 1 |
|
1110 |
||
1111 |
||
1112 |
def Cleanup(self): |
|
1113 |
# ensure that the toolset cache is flushed. |
|
1114 |
if self.toolset is not None: |
|
1115 |
self.toolset.write() |
|
1116 |
||
1117 |
# I/O methods |
|
1118 |
||
1119 |
@staticmethod |
|
1120 |
def attributeString(dictionary): |
|
1121 |
"turn a dictionary into a string of XML attributes" |
|
1122 |
atts = "" |
|
1123 |
for a,v in dictionary.items(): |
|
1124 |
atts += " " + a + "='" + v + "'" |
|
1125 |
return atts |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1126 |
|
3 | 1127 |
def Info(self, format, *extras, **attributes): |
1128 |
"""Send an information message to the configured channel |
|
1129 |
(XML control characters will be escaped) |
|
1130 |
""" |
|
1131 |
self.out.write("<info" + self.attributeString(attributes) + ">" + |
|
1132 |
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
|
1133 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1134 |
def InfoDiscovery(self, object_type, count): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1135 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1136 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1137 |
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
|
1138 |
count = count)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1139 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1140 |
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
|
1141 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1142 |
def InfoStartTime(self, object_type, task, key): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1143 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1144 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1145 |
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
|
1146 |
task = task, key = key)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1147 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1148 |
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
|
1149 |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1150 |
def InfoEndTime(self, object_type, task, key): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1151 |
if self.timing: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1152 |
try: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1153 |
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
|
1154 |
task = task, key = key)) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1155 |
except Exception, exception: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
21
diff
changeset
|
1156 |
Error(exception.Text, function = "InfoEndTime") |
3 | 1157 |
|
1158 |
def Debug(self, format, *extras, **attributes): |
|
1159 |
"Send a debugging message to the configured channel" |
|
1160 |
||
1161 |
# the debug text is out of our control so wrap it in a CDATA |
|
1162 |
# in case it contains characters special to XML... like <> |
|
1163 |
if self.debugOutput: |
|
1164 |
self.out.write("<debug" + self.attributeString(attributes) + ">" + |
|
1165 |
"><![CDATA[\n" + (format % extras) + "\n]]></debug>\n") |
|
1166 |
||
1167 |
def Warn(self, format, *extras, **attributes): |
|
1168 |
"""Send a warning message to the configured channel |
|
1169 |
(XML control characters will be escaped) |
|
1170 |
""" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1171 |
self.out.write("<warning" + self.attributeString(attributes) + ">" + |
3 | 1172 |
escape(format % extras) + "</warning>\n") |
1173 |
||
1174 |
def FatalError(self, format, *extras, **attributes): |
|
1175 |
"""Send an error message to the configured channel. This implies such a serious |
|
1176 |
error that the entire build must be shut down asap whilst still finishing off |
|
1177 |
correctly whatever housekeeping is possible e.g. producing error reports. |
|
1178 |
Remains quiet if the raptor object is already in a fatal state since there |
|
1179 |
further errors are probably triggered by the first. |
|
1180 |
""" |
|
1181 |
if not self.fatalErrorState: |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1182 |
self.out.write("<error" + self.attributeString(attributes) + ">" + |
3 | 1183 |
(format % extras) + "</error>\n") |
1184 |
self.errorCode = 1 |
|
1185 |
self.fatalErrorState = True |
|
1186 |
||
1187 |
def Error(self, format, *extras, **attributes): |
|
1188 |
"""Send an error message to the configured channel |
|
1189 |
(XML control characters will be escaped) |
|
1190 |
""" |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1191 |
self.out.write("<error" + self.attributeString(attributes) + ">" + |
3 | 1192 |
escape(format % extras) + "</error>\n") |
1193 |
self.errorCode = 1 |
|
1194 |
||
1195 |
||
1196 |
def PrintXML(self, format, *extras): |
|
1197 |
"Print to configured channel (no newline is added) (assumes valid xml)" |
|
1198 |
if format: |
|
1199 |
self.out.write(format % extras) |
|
1200 |
||
5 | 1201 |
def GetLayersFromCLI(self): |
1202 |
"""Returns the list of layers as specified by the |
|
3 | 1203 |
commandline interface to Raptor e.g. parameters |
1204 |
or the current directory""" |
|
5 | 1205 |
layers=[] |
3 | 1206 |
# Look for bld.infs or sysdefs in the current dir if none were specified |
1207 |
if self.systemDefinitionFile == None and len(self.commandlineComponents) == 0: |
|
1208 |
if not self.preferBuildInfoToSystemDefinition: |
|
1209 |
cwd = os.getcwd() |
|
1210 |
self.systemDefinitionFile = self.FindSysDefIn(cwd) |
|
1211 |
if self.systemDefinitionFile == None: |
|
1212 |
aComponent = self.FindComponentIn(cwd) |
|
1213 |
if aComponent: |
|
5 | 1214 |
layers.append(Layer('default',[aComponent])) |
3 | 1215 |
else: |
1216 |
aComponent = self.FindComponentIn(cwd) |
|
1217 |
if aComponent is None: |
|
1218 |
self.systemDefinitionFile = self.FindSysDefIn(cwd) |
|
1219 |
else: |
|
5 | 1220 |
layers.append(Layer('default',[aComponent])) |
3 | 1221 |
|
5 | 1222 |
if len(layers) <= 0 and self.systemDefinitionFile == None: |
3 | 1223 |
self.Warn("No default bld.inf or system definition file found in current directory (%s)", cwd) |
1224 |
||
1225 |
# If we now have a System Definition to parse then get the layers of components |
|
1226 |
if self.systemDefinitionFile != None: |
|
1227 |
systemModel = raptor_xml.SystemModel(self, self.systemDefinitionFile, self.systemDefinitionBase) |
|
5 | 1228 |
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
|
1229 |
|
3 | 1230 |
# Now get components specified on a commandline - build them after any |
1231 |
# layers in the system definition. |
|
1232 |
if len(self.commandlineComponents) > 0: |
|
5 | 1233 |
layers.append(Layer('commandline',self.commandlineComponents)) |
3 | 1234 |
|
1235 |
# If we aren't building components in order then flatten down |
|
1236 |
# the groups |
|
1237 |
if not self.systemDefinitionOrderLayers: |
|
1238 |
# Flatten the layers into one group of components if |
|
1239 |
# we are not required to build them in order. |
|
5 | 1240 |
newcg = Layer("all") |
1241 |
for cg in layers: |
|
1242 |
for c in cg: |
|
1243 |
newcg.add(c) |
|
1244 |
layers = [newcg] |
|
3 | 1245 |
|
5 | 1246 |
return layers |
3 | 1247 |
|
1248 |
def Build(self): |
|
1249 |
||
1250 |
if self.mission != Raptor.M_BUILD: # help or version requested instead. |
|
1251 |
return 0 |
|
1252 |
||
1253 |
# open the log file |
|
1254 |
self.OpenLog() |
|
1255 |
||
1256 |
||
1257 |
try: |
|
1258 |
# show the command and platform info |
|
1259 |
self.AssertBuildOK() |
|
1260 |
self.Introduction() |
|
1261 |
# establish an object cache |
|
1262 |
self.AssertBuildOK() |
|
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1263 |
|
3 | 1264 |
self.LoadCache() |
1265 |
||
1266 |
# find out what configurations to build |
|
1267 |
self.AssertBuildOK() |
|
1268 |
buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames) |
|
1269 |
||
5 | 1270 |
self.buildUnitsToBuild = buildUnitsToBuild |
1271 |
||
3 | 1272 |
# find out what components to build, and in what way |
5 | 1273 |
layers = [] |
3 | 1274 |
|
1275 |
self.AssertBuildOK() |
|
1276 |
if len(buildUnitsToBuild) >= 0: |
|
5 | 1277 |
layers = self.GetLayersFromCLI() |
3 | 1278 |
|
5 | 1279 |
componentCount = reduce(lambda x,y : x + y, [len(cg) for cg in layers]) |
3 | 1280 |
|
1281 |
if not componentCount > 0: |
|
5 | 1282 |
raise BuildCannotProgressException("No components to build.") |
3 | 1283 |
|
1284 |
# check the configurations (tools versions) |
|
1285 |
self.AssertBuildOK() |
|
1286 |
||
1287 |
if self.toolcheck != 'off': |
|
1288 |
self.CheckConfigs(buildUnitsToBuild) |
|
1289 |
else: |
|
191
3bfc260b6d61
fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents:
136
diff
changeset
|
1290 |
self.Info("Not Checking Tool Versions") |
3 | 1291 |
|
1292 |
self.AssertBuildOK() |
|
1293 |
||
5 | 1294 |
# Setup a make engine. |
1295 |
if not self.maker: |
|
191
3bfc260b6d61
fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents:
136
diff
changeset
|
1296 |
try: |
193
8e61308a207e
don't break sbs_init.xml files with make engine validation changes
timothy.murphy@nokia.com
parents:
191
diff
changeset
|
1297 |
self.maker = raptor_make.MakeEngine(self, self.makeEngine) |
191
3bfc260b6d61
fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents:
136
diff
changeset
|
1298 |
except raptor_make.BadMakeEngineException,e: |
3bfc260b6d61
fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents:
136
diff
changeset
|
1299 |
self.Error("Unable to use make engine: %s " % str(e)) |
3bfc260b6d61
fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents:
136
diff
changeset
|
1300 |
|
3 | 1301 |
|
5 | 1302 |
self.AssertBuildOK() |
1303 |
||
1304 |
# if self.doParallelParsing and not (len(layers) == 1 and len(layers[0]) == 1): |
|
3 | 1305 |
if self.doParallelParsing: |
1306 |
# Create a Makefile to parse components in parallel and build them |
|
5 | 1307 |
for l in layers: |
1308 |
l.meta_realise(self) |
|
3 | 1309 |
else: |
1310 |
# Parse components serially, creating one set of makefiles |
|
1311 |
# create non-component specs |
|
5 | 1312 |
self.generic_specs = self.GenerateGenericSpecs(buildUnitsToBuild) |
3 | 1313 |
|
1314 |
self.AssertBuildOK() |
|
5 | 1315 |
for l in layers: |
3 | 1316 |
# create specs for a specific group of components |
5 | 1317 |
l.realise(self) |
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1318 |
|
5 | 1319 |
except BuildCannotProgressException,b: |
3 | 1320 |
if str(b) != "": |
1321 |
self.Info(str(b)) |
|
1322 |
||
1323 |
# final report |
|
1324 |
if not self.fatalErrorState: |
|
1325 |
self.Report() |
|
1326 |
||
1327 |
self.Cleanup() |
|
1328 |
||
1329 |
# close the log file |
|
1330 |
self.CloseLog() |
|
1331 |
||
1332 |
return self.errorCode |
|
1333 |
||
1334 |
@classmethod |
|
1335 |
def CreateCommandlineBuild(cls, argv): |
|
1336 |
""" Perform a 'typical' build. """ |
|
1337 |
# configure the framework |
|
1338 |
||
1339 |
build = Raptor() |
|
1340 |
build.AssertBuildOK() |
|
1341 |
build.ConfigFile() |
|
1342 |
build.ProcessConfig() |
|
1343 |
build.CommandLine(argv) |
|
1344 |
||
59
0f7d6c11c675
Environment variables in the log are sorted alphabetically.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
29
diff
changeset
|
1345 |
return build |
3 | 1346 |
|
1347 |
||
1348 |
||
1349 |
# Class for passing constricted parameters to filters |
|
1350 |
class BuildStats(object): |
|
1351 |
||
1352 |
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
|
1353 |
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
|
1354 |
self.epocroot = epocroot |
3 | 1355 |
self.logFileName = raptor_instance.logFileName |
1356 |
self.quiet = raptor_instance.quiet |
|
1357 |
self.doCheck = raptor_instance.doCheck |
|
1358 |
self.doWhat = raptor_instance.doWhat |
|
1359 |
self.platform = hostplatform |
|
1360 |
self.skipAll = raptor_instance.fatalErrorState |
|
1361 |
self.timestring = raptor_instance.timestring |
|
1362 |
self.targets = raptor_instance.targets |
|
1363 |
self.runtime = 0 |
|
1364 |
self.name = name |
|
1365 |
||
1366 |
||
1367 |
# raptor module functions |
|
1368 |
||
1369 |
def Main(argv): |
|
1370 |
"""The main entry point for Raptor. |
|
1371 |
||
1372 |
argv is a list of command-line parameters, |
|
1373 |
NOT including the name of the calling script. |
|
1374 |
||
1375 |
The return value is zero for success and non-zero for failure.""" |
|
1376 |
||
1377 |
DisplayBanner() |
|
1378 |
||
1379 |
# object which represents a build |
|
1380 |
b = Raptor.CreateCommandlineBuild(argv) |
|
1381 |
||
5 | 1382 |
return b.Build() |
3 | 1383 |
|
1384 |
||
1385 |
def DisplayBanner(): |
|
1386 |
"""Stuff that needs printing out for every command.""" |
|
1387 |
pass |
|
1388 |
||
1389 |
||
1390 |
||
5 | 1391 |
|
3 | 1392 |
# end of the raptor module |