diff options
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 | ||