diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2008-02-26 17:23:31 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2008-02-26 17:23:31 +0000 |
commit | e608db7e231d300c99790f07e49b8951e1e3c0fa (patch) | |
tree | 02bc0ed10a3fe1d0de56a2c8361483d357b809c8 | |
parent | d2d97c5dc951398d5bf3f4b70b748d82d0b0e01b (diff) | |
download | bitbake-contrib-e608db7e231d300c99790f07e49b8951e1e3c0fa.tar.gz |
runqueue.py: Add StampUpdate event
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | lib/bb/event.py | 17 | ||||
-rw-r--r-- | lib/bb/runqueue.py | 99 |
3 files changed, 110 insertions, 7 deletions
@@ -106,6 +106,7 @@ Changes in Bitbake 1.9.x: - Cooker: Remove a debug message from the parsing loop to lower overhead - Convert build.py exec_task to use getVarFlags - Update shell to use cooker.buildFile + - Add StampUpdate event Changes in Bitbake 1.8.0: - Release 1.7.x as a stable series diff --git a/lib/bb/event.py b/lib/bb/event.py index f87b6f0e6..2eed2685a 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -158,6 +158,23 @@ def getName(e): class ConfigParsed(Event): """Configuration Parsing Complete""" +class StampUpdate(Event): + """Trigger for any adjustment of the stamp files to happen""" + + def __init__(self, targets, stampfns, d): + self._targets = targets + self._stampfns = stampfns + Event.__init__(self, d) + + def getStampPrefix(self): + return self._stampfns + + def getTargets(self): + return self._targets + + stampPrefix = property(getStampPrefix) + targets = property(getTargets) + class PkgBase(Event): """Base class for package events""" diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py index 8792053d9..73698283e 100644 --- a/lib/bb/runqueue.py +++ b/lib/bb/runqueue.py @@ -26,6 +26,7 @@ from bb import msg, data, event, mkdirhier, utils from sets import Set import bb, os, sys import signal +import stat class TaskFailure(Exception): """Exception raised when a task in a runqueue fails""" @@ -48,13 +49,13 @@ class RunQueueStats: self.active = self.active - 1 self.failed = self.failed + 1 - def taskCompleted(self): - self.active = self.active - 1 - self.completed = self.completed + 1 + def taskCompleted(self, number = 1): + self.active = self.active - number + self.completed = self.completed + number - def taskSkipped(self): - self.active = self.active + 1 - self.skipped = self.skipped + 1 + def taskSkipped(self, number = 1): + self.active = self.active + number + self.skipped = self.skipped + number def taskActive(self): self.active = self.active + 1 @@ -533,6 +534,7 @@ class RunQueue: for depend in depends: mark_active(depend, depth+1) + self.target_pairs = [] for target in self.targets: targetid = taskData.getbuild_id(target[0]) @@ -543,10 +545,11 @@ class RunQueue: continue fnid = taskData.build_targets[targetid][0] + fn = taskData.fn_index[fnid] + self.target_pairs.append((fn, target[1])) # Remove stamps for targets if force mode active if self.cooker.configuration.force: - fn = taskData.fn_index[fnid] bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (target[1], fn)) bb.build.del_stamp(target[1], self.dataCache, fn) @@ -658,6 +661,86 @@ class RunQueue: self.state = runQueueRunInit + def check_stamps(self): + unchecked = {} + current = [] + notcurrent = [] + buildable = [] + for task in range(len(self.runq_fnid)): + unchecked[task] = "" + if len(self.runq_depends[task]) == 0: + buildable.append(task) + + for task in range(len(self.runq_fnid)): + if task not in unchecked: + continue + fn = self.taskData.fn_index[self.runq_fnid[task]] + taskname = self.runq_task[task] + stampfile = "%s.%s" % (self.dataCache.stamp[fn], taskname) + # If the stamp is missing its not current + if not os.access(stampfile, os.F_OK): + del unchecked[task] + notcurrent.append(task) + continue + # If its a 'nostamp' task, it's not current + taskdep = self.dataCache.task_deps[fn] + if 'nostamp' in taskdep and task in taskdep['nostamp']: + del unchecked[task] + notcurrent.append(task) + continue + + while (len(buildable) > 0): + nextbuildable = [] + for task in buildable: + if task in unchecked: + fn = self.taskData.fn_index[self.runq_fnid[task]] + taskname = self.runq_task[task] + stampfile = "%s.%s" % (self.dataCache.stamp[fn], taskname) + iscurrent = True + + t1 = os.stat(stampfile)[stat.ST_MTIME] + for dep in self.runq_depends[task]: + if iscurrent: + fn2 = self.taskData.fn_index[self.runq_fnid[dep]] + taskname2 = self.runq_task[dep] + stampfile2 = "%s.%s" % (self.dataCache.stamp[fn2], taskname2) + if fn == fn2: + if dep in notcurrent: + iscurrent = False + else: + t2 = os.stat(stampfile2)[stat.ST_MTIME] + if t1 < t2: + iscurrent = False + del unchecked[task] + if iscurrent: + current.append(task) + else: + notcurrent.append(task) + + for revdep in self.runq_revdeps[task]: + alldeps = 1 + for dep in self.runq_depends[revdep]: + if dep in unchecked: + alldeps = 0 + if alldeps == 1: + nextbuildable.append(revdep) + + buildable = nextbuildable + + #for task in range(len(self.runq_fnid)): + # fn = self.taskData.fn_index[self.runq_fnid[task]] + # taskname = self.runq_task[task] + # print "%s %s.%s" % (task, taskname, fn) + + #print "Unchecked: %s" % unchecked + #print "Current: %s" % current + #print "Not current: %s" % notcurrent + + if len(unchecked) > 0: + bb.fatal("check_stamps fatal internal error") + return current + + def execute_runqueue(self): """ Run the tasks in a queue prepared by prepare_runqueue @@ -719,6 +802,8 @@ class RunQueue: self.state = runQueueRunning + event.fire(bb.event.StampUpdate(self.target_pairs, self.dataCache.stamp, self.cfgdata)) + # RP - this code allows tasks to run out of the correct order - disabled, FIXME # Find any tasks with current stamps and remove them from the queue # for task1 in range(self.stats.total): |