diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-12-09 11:57:38 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-12-18 10:24:06 +0000 |
commit | 85a17f86ea2edf24b54aa62bd25e10ff522cb6e7 (patch) | |
tree | 69baa4d959be832b5c096b7d69b0fc2bcb2247b5 /bitbake/lib/bb/cooker.py | |
parent | d086fa3aed34a05d52e73c255ca22379149a64a1 (diff) | |
download | poky-85a17f86ea2edf24b54aa62bd25e10ff522cb6e7.tar.gz |
bitbake: add option to write offline event log file
This patch adds a "-w/--write-log" option to bitbake
that writes an event log file for the current build.
The name of the file is passed as a parameter to the "-w"
argument. If the parameter is the empty string '', the file
name is generated in the form bitbake_eventlog_DATE.json,
where DATE is the current date and time, with second precision.
The "-w" option can also be supplied as the BBEVENTLOG
environment variable.
We add a script, toater-eventreplay, that reads an event
log file and loads the data into a Toaster database, creating
a build entry.
We modify the toasterui to fix minor issues with reading
events from an event log file.
Performance impact is undetectable under no-task executed builds.
(Bitbake rev: 1befb4a783bb7b7b387d4b5ee08830d9516f1ac2)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index df9a0cab03..16fd4ad34c 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -205,6 +205,75 @@ class BBCooker: | |||
205 | self.data = self.databuilder.data | 205 | self.data = self.databuilder.data |
206 | self.data_hash = self.databuilder.data_hash | 206 | self.data_hash = self.databuilder.data_hash |
207 | 207 | ||
208 | |||
209 | # we log all events to a file if so directed | ||
210 | if self.configuration.writeeventlog: | ||
211 | import json, pickle | ||
212 | DEFAULT_EVENTFILE = self.configuration.writeeventlog | ||
213 | class EventLogWriteHandler(): | ||
214 | |||
215 | class EventWriter(): | ||
216 | def __init__(self, cooker): | ||
217 | self.file_inited = None | ||
218 | self.cooker = cooker | ||
219 | self.event_queue = [] | ||
220 | |||
221 | def init_file(self): | ||
222 | try: | ||
223 | # delete the old log | ||
224 | os.remove(DEFAULT_EVENTFILE) | ||
225 | except: | ||
226 | pass | ||
227 | |||
228 | # write current configuration data | ||
229 | with open(DEFAULT_EVENTFILE, "w") as f: | ||
230 | f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])})) | ||
231 | |||
232 | def write_event(self, event): | ||
233 | with open(DEFAULT_EVENTFILE, "a") as f: | ||
234 | try: | ||
235 | f.write("%s\n" % json.dumps({"class":event.__module__ + "." + event.__class__.__name__, "vars":json.dumps(pickle.dumps(event)) })) | ||
236 | except Exception as e: | ||
237 | import traceback | ||
238 | print(e, traceback.format_exc(e)) | ||
239 | |||
240 | |||
241 | def send(self, event): | ||
242 | event_class = event.__module__ + "." + event.__class__.__name__ | ||
243 | |||
244 | # init on bb.event.BuildStarted | ||
245 | if self.file_inited is None: | ||
246 | if event_class == "bb.event.BuildStarted": | ||
247 | self.init_file() | ||
248 | self.file_inited = True | ||
249 | |||
250 | # write pending events | ||
251 | for e in self.event_queue: | ||
252 | self.write_event(e) | ||
253 | |||
254 | # also write the current event | ||
255 | self.write_event(event) | ||
256 | |||
257 | else: | ||
258 | # queue all events until the file is inited | ||
259 | self.event_queue.append(event) | ||
260 | |||
261 | else: | ||
262 | # we have the file, just write the event | ||
263 | self.write_event(event) | ||
264 | |||
265 | # set our handler's event processor | ||
266 | event = EventWriter(self) # self is the cooker here | ||
267 | |||
268 | |||
269 | # set up cooker features for this mock UI handler | ||
270 | |||
271 | # we need to write the dependency tree in the log | ||
272 | self.featureset.setFeature(CookerFeatures.SEND_DEPENDS_TREE) | ||
273 | # register the log file writer as UI Handler | ||
274 | bb.event.register_UIHhandler(EventLogWriteHandler()) | ||
275 | |||
276 | |||
208 | # | 277 | # |
209 | # Special updated configuration we use for firing events | 278 | # Special updated configuration we use for firing events |
210 | # | 279 | # |
@@ -505,7 +574,7 @@ class BBCooker: | |||
505 | taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False) | 574 | taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False) |
506 | 575 | ||
507 | return runlist, taskdata | 576 | return runlist, taskdata |
508 | 577 | ||
509 | ######## WARNING : this function requires cache_extra to be enabled ######## | 578 | ######## WARNING : this function requires cache_extra to be enabled ######## |
510 | 579 | ||
511 | def generateTaskDepTreeData(self, pkgs_to_build, task): | 580 | def generateTaskDepTreeData(self, pkgs_to_build, task): |
@@ -1550,10 +1619,10 @@ class CookerCollectFiles(object): | |||
1550 | for p in pkgfns: | 1619 | for p in pkgfns: |
1551 | realfn, cls = bb.cache.Cache.virtualfn2realfn(p) | 1620 | realfn, cls = bb.cache.Cache.virtualfn2realfn(p) |
1552 | priorities[p] = self.calc_bbfile_priority(realfn, matched) | 1621 | priorities[p] = self.calc_bbfile_priority(realfn, matched) |
1553 | 1622 | ||
1554 | # Don't show the warning if the BBFILE_PATTERN did match .bbappend files | 1623 | # Don't show the warning if the BBFILE_PATTERN did match .bbappend files |
1555 | unmatched = set() | 1624 | unmatched = set() |
1556 | for _, _, regex, pri in self.bbfile_config_priorities: | 1625 | for _, _, regex, pri in self.bbfile_config_priorities: |
1557 | if not regex in matched: | 1626 | if not regex in matched: |
1558 | unmatched.add(regex) | 1627 | unmatched.add(regex) |
1559 | 1628 | ||