pan class="n">fire(TaskSucceeded(item, localdata)) task_cache.append(item) data.setVar('_task_cache', task_cache, d) except FuncFailed, reason: bb.msg.note(1, bb.msg.domain.Build, "Task failed: %s" % reason ) failedevent = TaskFailed(item, d) event.fire(failedevent) raise EventException("Function failed in task: %s" % reason, failedevent) if data.getVarFlag(task, 'dontrundeps', d): execute(None, task) else: task_graph.walkdown(task, execute) # make stamp, or cause event and raise exception if not data.getVarFlag(task, 'nostamp', d): make_stamp(task, d) def extract_stamp_data(d, fn): """ Extracts stamp data from d which is either a data dictonary (fn unset) or a dataCache entry (fn set). """ if fn: return (d.task_queues[fn], d.stamp[fn], d.task_deps[fn]) task_graph = data.getVar('_task_graph', d) if not task_graph: task_graph = bb.digraph() data.setVar('_task_graph', task_graph, d) return (task_graph, data.getVar('STAMP', d, 1), None) def extract_stamp(d, fn): """ Extracts stamp format which is either a data dictonary (fn unset) or a dataCache entry (fn set). """ if fn: return d.stamp[fn] return data.getVar('STAMP', d, 1) def stamp_is_current(task, d, file_name = None, checkdeps = 1): """ Check status of a given task's stamp. Returns 0 if it is not current and needs updating. (d can be a data dict or dataCache) """ (task_graph, stampfn, taskdep) = extract_stamp_data(d, file_name) if not stampfn: return 0 stampfile = "%s.%s" % (stampfn, task) if not os.access(stampfile, os.F_OK): return 0 if checkdeps == 0: return 1 import stat tasktime = os.stat(stampfile)[stat.ST_MTIME] _deps = [] def checkStamp(graph, task): # check for existance if file_name: if 'nostamp' in taskdep and task in taskdep['nostamp']: return 1 else: if data.getVarFlag(task, 'nostamp', d): return 1 if not stamp_is_current(task, d, file_name, 0 ): return 0 depfile = "%s.%s" % (stampfn, task) deptime = os.stat(depfile)[stat.ST_MTIME] if deptime > tasktime: return 0 return 1 return task_graph.walkdown(task, checkStamp) def stamp_internal(task, d, file_name): """ Internal stamp helper function Removes any stamp for the given task Makes sure the stamp directory exists Returns the stamp path+filename """ stamp = extract_stamp(d, file_name) if not stamp: return stamp = "%s.%s" % (stamp, task) mkdirhier(os.path.dirname(stamp)) # Remove the file and recreate to force timestamp # change on broken NFS filesystems if os.access(stamp, os.F_OK): os.remove(stamp) return stamp def make_stamp(task, d, file_name = None): """ Creates/updates a stamp for a given task (d can be a data dict or dataCache) """ stamp = stamp_internal(task, d, file_name) if stamp: f = open(stamp, "w") f.close() def del_stamp(task, d, file_name = None): """ Removes a stamp for a given task (d can be a data dict or dataCache) """ stamp_internal(task, d, file_name) def add_tasks(tasklist, d): task_graph = data.getVar('_task_graph', d) task_deps = data.getVar('_task_deps', d) if not task_graph: task_graph = bb.digraph() if not task_deps: task_deps = {} for task in tasklist: deps = tasklist[task] task = data.expand(task, d) data.setVarFlag(task, 'task', 1, d) task_graph.addnode(task, None) for dep in deps: dep = data.expand(dep, d) if not task_graph.hasnode(dep): task_graph.addnode(dep, None) task_graph.addnode(task, dep) flags = data.getVarFlags(task, d) def getTask(name): if name in flags: deptask = data.expand(flags[name], d) if not name in task_deps: task_deps[name] = {} task_deps[name][task] = deptask getTask('depends') getTask('deptask') getTask('rdeptask') getTask('recrdeptask') getTask('nostamp') # don't assume holding a reference data.setVar('_task_graph', task_graph, d) data.setVar('_task_deps', task_deps, d) def remove_task(task, kill, d): """Remove an BB 'task'. If kill is 1, also remove tasks that depend on this task.""" task_graph = data.getVar('_task_graph', d) if not task_graph: task_graph = bb.digraph() if not task_graph.hasnode(task): return data.delVarFlag(task, 'task', d) ref = 1 if kill == 1: ref = 2 task_graph.delnode(task, ref) data.setVar('_task_graph', task_graph, d) def task_exists(task, d): task_graph = data.getVar('_task_graph', d) if not task_graph: task_graph = bb.digraph() data.setVar('_task_graph', task_graph, d) return task_graph.hasnode(task)