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