|
@@ -36,6 +36,7 @@ from bb import msg, data, event
|
|
|
from bb import monitordisk
|
|
|
import subprocess
|
|
|
import pickle
|
|
|
+from multiprocessing import Process
|
|
|
|
|
|
bblogger = logging.getLogger("BitBake")
|
|
|
logger = logging.getLogger("BitBake.RunQueue")
|
|
@@ -49,30 +50,30 @@ def taskname_from_tid(tid):
|
|
|
return tid.rsplit(":", 1)[1]
|
|
|
|
|
|
def split_tid(tid):
|
|
|
+ (mc, fn, taskname, _) = split_tid_mcfn(tid)
|
|
|
+ return (mc, fn, taskname)
|
|
|
+
|
|
|
+def split_tid_mcfn(tid):
|
|
|
if tid.startswith('multiconfig:'):
|
|
|
elems = tid.split(':')
|
|
|
mc = elems[1]
|
|
|
fn = ":".join(elems[2:-1])
|
|
|
taskname = elems[-1]
|
|
|
+ mcfn = "multiconfig:" + mc + ":" + fn
|
|
|
else:
|
|
|
tid = tid.rsplit(":", 1)
|
|
|
mc = ""
|
|
|
fn = tid[0]
|
|
|
taskname = tid[1]
|
|
|
+ mcfn = fn
|
|
|
|
|
|
- return (mc, fn, taskname)
|
|
|
+ return (mc, fn, taskname, mcfn)
|
|
|
|
|
|
def build_tid(mc, fn, taskname):
|
|
|
if mc:
|
|
|
return "multiconfig:" + mc + ":" + fn + ":" + taskname
|
|
|
return fn + ":" + taskname
|
|
|
|
|
|
-def taskfn_fromtid(tid):
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- if mc:
|
|
|
- return "multiconfig:" + mc + ":" + fn
|
|
|
- return fn
|
|
|
-
|
|
|
class RunQueueStats:
|
|
|
"""
|
|
|
Holds statistics on the tasks handled by the associated runQueue
|
|
@@ -135,8 +136,7 @@ class RunQueueScheduler(object):
|
|
|
self.buildable = []
|
|
|
self.stamps = {}
|
|
|
for tid in self.rqdata.runtaskentries:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
self.stamps[tid] = bb.build.stampfile(taskname, self.rqdata.dataCaches[mc], taskfn, noextra=True)
|
|
|
if tid in self.rq.runq_buildable:
|
|
|
self.buildable.append(tid)
|
|
@@ -181,9 +181,21 @@ class RunQueueScheduler(object):
|
|
|
if self.rq.stats.active < self.rq.number_tasks:
|
|
|
return self.next_buildable_task()
|
|
|
|
|
|
- def newbuilable(self, task):
|
|
|
+ def newbuildable(self, task):
|
|
|
self.buildable.append(task)
|
|
|
|
|
|
+ def describe_task(self, taskid):
|
|
|
+ result = 'ID %s' % taskid
|
|
|
+ if self.rev_prio_map:
|
|
|
+ result = result + (' pri %d' % self.rev_prio_map[taskid])
|
|
|
+ return result
|
|
|
+
|
|
|
+ def dump_prio(self, comment):
|
|
|
+ bb.debug(3, '%s (most important first):\n%s' %
|
|
|
+ (comment,
|
|
|
+ '\n'.join(['%d. %s' % (index + 1, self.describe_task(taskid)) for
|
|
|
+ index, taskid in enumerate(self.prio_map)])))
|
|
|
+
|
|
|
class RunQueueSchedulerSpeed(RunQueueScheduler):
|
|
|
"""
|
|
|
A scheduler optimised for speed. The priority map is sorted by task weight,
|
|
@@ -213,35 +225,100 @@ class RunQueueSchedulerSpeed(RunQueueScheduler):
|
|
|
|
|
|
class RunQueueSchedulerCompletion(RunQueueSchedulerSpeed):
|
|
|
"""
|
|
|
- A scheduler optimised to complete .bb files are quickly as possible. The
|
|
|
+ A scheduler optimised to complete .bb files as quickly as possible. The
|
|
|
priority map is sorted by task weight, but then reordered so once a given
|
|
|
- .bb file starts to build, it's completed as quickly as possible. This works
|
|
|
- well where disk space is at a premium and classes like OE's rm_work are in
|
|
|
- force.
|
|
|
+ .bb file starts to build, it's completed as quickly as possible by
|
|
|
+ running all tasks related to the same .bb file one after the after.
|
|
|
+ This works well where disk space is at a premium and classes like OE's
|
|
|
+ rm_work are in force.
|
|
|
"""
|
|
|
name = "completion"
|
|
|
|
|
|
def __init__(self, runqueue, rqdata):
|
|
|
- RunQueueSchedulerSpeed.__init__(self, runqueue, rqdata)
|
|
|
-
|
|
|
- #FIXME - whilst this groups all fns together it does not reorder the
|
|
|
- #fn groups optimally.
|
|
|
-
|
|
|
- basemap = copy.deepcopy(self.prio_map)
|
|
|
- self.prio_map = []
|
|
|
- while (len(basemap) > 0):
|
|
|
- entry = basemap.pop(0)
|
|
|
- self.prio_map.append(entry)
|
|
|
- fn = fn_from_tid(entry)
|
|
|
- todel = []
|
|
|
- for entry in basemap:
|
|
|
- entry_fn = fn_from_tid(entry)
|
|
|
- if entry_fn == fn:
|
|
|
- todel.append(basemap.index(entry))
|
|
|
- self.prio_map.append(entry)
|
|
|
- todel.reverse()
|
|
|
- for idx in todel:
|
|
|
- del basemap[idx]
|
|
|
+ super(RunQueueSchedulerCompletion, self).__init__(runqueue, rqdata)
|
|
|
+
|
|
|
+ # Extract list of tasks for each recipe, with tasks sorted
|
|
|
+ # ascending from "must run first" (typically do_fetch) to
|
|
|
+ # "runs last" (do_build). The speed scheduler prioritizes
|
|
|
+ # tasks that must run first before the ones that run later;
|
|
|
+ # this is what we depend on here.
|
|
|
+ task_lists = {}
|
|
|
+ for taskid in self.prio_map:
|
|
|
+ fn, taskname = taskid.rsplit(':', 1)
|
|
|
+ task_lists.setdefault(fn, []).append(taskname)
|
|
|
+
|
|
|
+ # Now unify the different task lists. The strategy is that
|
|
|
+ # common tasks get skipped and new ones get inserted after the
|
|
|
+ # preceeding common one(s) as they are found. Because task
|
|
|
+ # lists should differ only by their number of tasks, but not
|
|
|
+ # the ordering of the common tasks, this should result in a
|
|
|
+ # deterministic result that is a superset of the individual
|
|
|
+ # task ordering.
|
|
|
+ all_tasks = []
|
|
|
+ for recipe, new_tasks in task_lists.items():
|
|
|
+ index = 0
|
|
|
+ old_task = all_tasks[index] if index < len(all_tasks) else None
|
|
|
+ for new_task in new_tasks:
|
|
|
+ if old_task == new_task:
|
|
|
+ # Common task, skip it. This is the fast-path which
|
|
|
+ # avoids a full search.
|
|
|
+ index += 1
|
|
|
+ old_task = all_tasks[index] if index < len(all_tasks) else None
|
|
|
+ else:
|
|
|
+ try:
|
|
|
+ index = all_tasks.index(new_task)
|
|
|
+ # Already present, just not at the current
|
|
|
+ # place. We re-synchronized by changing the
|
|
|
+ # index so that it matches again. Now
|
|
|
+ # move on to the next existing task.
|
|
|
+ index += 1
|
|
|
+ old_task = all_tasks[index] if index < len(all_tasks) else None
|
|
|
+ except ValueError:
|
|
|
+ # Not present. Insert before old_task, which
|
|
|
+ # remains the same (but gets shifted back).
|
|
|
+ all_tasks.insert(index, new_task)
|
|
|
+ index += 1
|
|
|
+ bb.debug(3, 'merged task list: %s' % all_tasks)
|
|
|
+
|
|
|
+ # Now reverse the order so that tasks that finish the work on one
|
|
|
+ # recipe are considered more imporant (= come first). The ordering
|
|
|
+ # is now so that do_build is most important.
|
|
|
+ all_tasks.reverse()
|
|
|
+
|
|
|
+ # Group tasks of the same kind before tasks of less important
|
|
|
+ # kinds at the head of the queue (because earlier = lower
|
|
|
+ # priority number = runs earlier), while preserving the
|
|
|
+ # ordering by recipe. If recipe foo is more important than
|
|
|
+ # bar, then the goal is to work on foo's do_populate_sysroot
|
|
|
+ # before bar's do_populate_sysroot and on the more important
|
|
|
+ # tasks of foo before any of the less important tasks in any
|
|
|
+ # other recipe (if those other recipes are more important than
|
|
|
+ # foo).
|
|
|
+ #
|
|
|
+ # All of this only applies when tasks are runable. Explicit
|
|
|
+ # dependencies still override this ordering by priority.
|
|
|
+ #
|
|
|
+ # Here's an example why this priority re-ordering helps with
|
|
|
+ # minimizing disk usage. Consider a recipe foo with a higher
|
|
|
+ # priority than bar where foo DEPENDS on bar. Then the
|
|
|
+ # implicit rule (from base.bbclass) is that foo's do_configure
|
|
|
+ # depends on bar's do_populate_sysroot. This ensures that
|
|
|
+ # bar's do_populate_sysroot gets done first. Normally the
|
|
|
+ # tasks from foo would continue to run once that is done, and
|
|
|
+ # bar only gets completed and cleaned up later. By ordering
|
|
|
+ # bar's task that depend on bar's do_populate_sysroot before foo's
|
|
|
+ # do_configure, that problem gets avoided.
|
|
|
+ task_index = 0
|
|
|
+ self.dump_prio('original priorities')
|
|
|
+ for task in all_tasks:
|
|
|
+ for index in range(task_index, self.numTasks):
|
|
|
+ taskid = self.prio_map[index]
|
|
|
+ taskname = taskid.rsplit(':', 1)[1]
|
|
|
+ if taskname == task:
|
|
|
+ del self.prio_map[index]
|
|
|
+ self.prio_map.insert(task_index, taskid)
|
|
|
+ task_index += 1
|
|
|
+ self.dump_prio('completion priorities')
|
|
|
|
|
|
class RunTaskEntry(object):
|
|
|
def __init__(self):
|
|
@@ -263,9 +340,11 @@ class RunQueueData:
|
|
|
self.rq = rq
|
|
|
self.warn_multi_bb = False
|
|
|
|
|
|
- self.stampwhitelist = cfgData.getVar("BB_STAMP_WHITELIST", True) or ""
|
|
|
- self.multi_provider_whitelist = (cfgData.getVar("MULTI_PROVIDER_WHITELIST", True) or "").split()
|
|
|
+ self.stampwhitelist = cfgData.getVar("BB_STAMP_WHITELIST") or ""
|
|
|
+ self.multi_provider_whitelist = (cfgData.getVar("MULTI_PROVIDER_WHITELIST") or "").split()
|
|
|
self.setscenewhitelist = get_setscene_enforce_whitelist(cfgData)
|
|
|
+ self.setscenewhitelist_checked = False
|
|
|
+ self.setscene_enforce = (cfgData.getVar('BB_SETSCENE_ENFORCE') == "1")
|
|
|
self.init_progress_reporter = bb.progress.DummyMultiStageProcessProgressReporter()
|
|
|
|
|
|
self.reset()
|
|
@@ -289,8 +368,8 @@ class RunQueueData:
|
|
|
return tid + task_name_suffix
|
|
|
|
|
|
def get_short_user_idstring(self, task, task_name_suffix = ""):
|
|
|
- (mc, fn, taskname) = split_tid(task)
|
|
|
- pn = self.dataCaches[mc].pkg_fn[fn]
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(task)
|
|
|
+ pn = self.dataCaches[mc].pkg_fn[taskfn]
|
|
|
taskname = taskname_from_tid(task) + task_name_suffix
|
|
|
return "%s:%s" % (pn, taskname)
|
|
|
|
|
@@ -511,9 +590,8 @@ class RunQueueData:
|
|
|
for mc in taskData:
|
|
|
for tid in taskData[mc].taskentries:
|
|
|
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
#runtid = build_tid(mc, fn, taskname)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
|
|
|
#logger.debug(2, "Processing %s,%s:%s", mc, fn, taskname)
|
|
|
|
|
@@ -529,7 +607,7 @@ class RunQueueData:
|
|
|
#
|
|
|
# e.g. addtask before X after Y
|
|
|
for t in taskData[mc].taskentries[tid].tdepends:
|
|
|
- (_, depfn, deptaskname) = split_tid(t)
|
|
|
+ (_, depfn, deptaskname, _) = split_tid_mcfn(t)
|
|
|
depends.add(build_tid(mc, depfn, deptaskname))
|
|
|
|
|
|
# Resolve 'deptask' dependencies
|
|
@@ -566,6 +644,8 @@ class RunQueueData:
|
|
|
for (depname, idependtask) in irdepends:
|
|
|
if depname in taskData[mc].run_targets:
|
|
|
# Won't be in run_targets if ASSUME_PROVIDED
|
|
|
+ if not taskData[mc].run_targets[depname]:
|
|
|
+ continue
|
|
|
depdata = taskData[mc].run_targets[depname][0]
|
|
|
if depdata is not None:
|
|
|
t = depdata + ":" + idependtask
|
|
@@ -611,12 +691,15 @@ class RunQueueData:
|
|
|
|
|
|
def generate_recdeps(t):
|
|
|
newdeps = set()
|
|
|
- (mc, fn, taskname) = split_tid(t)
|
|
|
+ (mc, fn, taskname, _) = split_tid_mcfn(t)
|
|
|
add_resolved_dependencies(mc, fn, tasknames, newdeps)
|
|
|
extradeps[tid].update(newdeps)
|
|
|
seendeps.add(t)
|
|
|
newdeps.add(t)
|
|
|
for i in newdeps:
|
|
|
+ if i not in self.runtaskentries:
|
|
|
+ # Not all recipes might have the recrdeptask task as a task
|
|
|
+ continue
|
|
|
task = self.runtaskentries[i].task
|
|
|
for n in self.runtaskentries[i].depends:
|
|
|
if n not in seendeps:
|
|
@@ -723,6 +806,23 @@ class RunQueueData:
|
|
|
|
|
|
self.init_progress_reporter.next_stage()
|
|
|
|
|
|
+ if self.cooker.configuration.runall is not None:
|
|
|
+ runall = "do_%s" % self.cooker.configuration.runall
|
|
|
+ runall_tids = { k: v for k, v in self.runtaskentries.items() if taskname_from_tid(k) == runall }
|
|
|
+
|
|
|
+ # re-run the mark_active and then drop unused tasks from new list
|
|
|
+ runq_build = {}
|
|
|
+ for tid in list(runall_tids):
|
|
|
+ mark_active(tid,1)
|
|
|
+
|
|
|
+ for tid in list(self.runtaskentries.keys()):
|
|
|
+ if tid not in runq_build:
|
|
|
+ del self.runtaskentries[tid]
|
|
|
+ delcount += 1
|
|
|
+
|
|
|
+ if len(self.runtaskentries) == 0:
|
|
|
+ bb.msg.fatal("RunQueue", "No remaining tasks to run for build target %s with runall %s" % (target, runall))
|
|
|
+
|
|
|
#
|
|
|
# Step D - Sanity checks and computation
|
|
|
#
|
|
@@ -774,8 +874,7 @@ class RunQueueData:
|
|
|
prov_list = {}
|
|
|
seen_fn = []
|
|
|
for tid in self.runtaskentries:
|
|
|
- (tidmc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (tidmc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
if taskfn in seen_fn:
|
|
|
continue
|
|
|
if mc != tidmc:
|
|
@@ -885,15 +984,15 @@ class RunQueueData:
|
|
|
self.runq_setscene_tids = []
|
|
|
if not self.cooker.configuration.nosetscene:
|
|
|
for tid in self.runtaskentries:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- setscenetid = fn + ":" + taskname + "_setscene"
|
|
|
+ (mc, fn, taskname, _) = split_tid_mcfn(tid)
|
|
|
+ setscenetid = tid + "_setscene"
|
|
|
if setscenetid not in taskData[mc].taskentries:
|
|
|
continue
|
|
|
self.runq_setscene_tids.append(tid)
|
|
|
|
|
|
def invalidate_task(tid, error_nostamp):
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskdep = self.dataCaches[mc].task_deps[fn]
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
+ taskdep = self.dataCaches[mc].task_deps[taskfn]
|
|
|
if fn + ":" + taskname not in taskData[mc].taskentries:
|
|
|
logger.warning("Task %s does not exist, invalidating this task will have no effect" % taskname)
|
|
|
if 'nostamp' in taskdep and taskname in taskdep['nostamp']:
|
|
@@ -946,8 +1045,7 @@ class RunQueueData:
|
|
|
procdep = []
|
|
|
for dep in self.runtaskentries[tid].depends:
|
|
|
procdep.append(fn_from_tid(dep) + "." + taskname_from_tid(dep))
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
self.runtaskentries[tid].hash = bb.parse.siggen.get_taskhash(taskfn, taskname, procdep, self.dataCaches[mc])
|
|
|
task = self.runtaskentries[tid].task
|
|
|
|
|
@@ -979,16 +1077,22 @@ class RunQueue:
|
|
|
self.cfgData = cfgData
|
|
|
self.rqdata = RunQueueData(self, cooker, cfgData, dataCaches, taskData, targets)
|
|
|
|
|
|
- self.stamppolicy = cfgData.getVar("BB_STAMP_POLICY", True) or "perfile"
|
|
|
- self.hashvalidate = cfgData.getVar("BB_HASHCHECK_FUNCTION", True) or None
|
|
|
- self.setsceneverify = cfgData.getVar("BB_SETSCENE_VERIFY_FUNCTION2", True) or None
|
|
|
- self.depvalidate = cfgData.getVar("BB_SETSCENE_DEPVALID", True) or None
|
|
|
+ self.stamppolicy = cfgData.getVar("BB_STAMP_POLICY") or "perfile"
|
|
|
+ self.hashvalidate = cfgData.getVar("BB_HASHCHECK_FUNCTION") or None
|
|
|
+ self.setsceneverify = cfgData.getVar("BB_SETSCENE_VERIFY_FUNCTION2") or None
|
|
|
+ self.depvalidate = cfgData.getVar("BB_SETSCENE_DEPVALID") or None
|
|
|
|
|
|
self.state = runQueuePrepare
|
|
|
|
|
|
# For disk space monitor
|
|
|
+ # Invoked at regular time intervals via the bitbake heartbeat event
|
|
|
+ # while the build is running. We generate a unique name for the handler
|
|
|
+ # here, just in case that there ever is more than one RunQueue instance,
|
|
|
+ # start the handler when reaching runQueueSceneRun, and stop it when
|
|
|
+ # done with the build.
|
|
|
self.dm = monitordisk.diskMonitor(cfgData)
|
|
|
-
|
|
|
+ self.dm_event_handler_name = '_bb_diskmonitor_' + str(id(self))
|
|
|
+ self.dm_event_handler_registered = False
|
|
|
self.rqexe = None
|
|
|
self.worker = {}
|
|
|
self.fakeworker = {}
|
|
@@ -1000,8 +1104,9 @@ class RunQueue:
|
|
|
magic = "decafbadbad"
|
|
|
if fakeroot:
|
|
|
magic = magic + "beef"
|
|
|
- fakerootcmd = self.cfgData.getVar("FAKEROOTCMD", True)
|
|
|
- fakerootenv = (self.cfgData.getVar("FAKEROOTBASEENV", True) or "").split()
|
|
|
+ mcdata = self.cooker.databuilder.mcdata[mc]
|
|
|
+ fakerootcmd = mcdata.getVar("FAKEROOTCMD")
|
|
|
+ fakerootenv = (mcdata.getVar("FAKEROOTBASEENV") or "").split()
|
|
|
env = os.environ.copy()
|
|
|
for key, value in (var.split('=') for var in fakerootenv):
|
|
|
env[key] = value
|
|
@@ -1027,12 +1132,13 @@ class RunQueue:
|
|
|
"logdefaultverboselogs" : bb.msg.loggerVerboseLogs,
|
|
|
"logdefaultdomain" : bb.msg.loggerDefaultDomains,
|
|
|
"prhost" : self.cooker.prhost,
|
|
|
- "buildname" : self.cfgData.getVar("BUILDNAME", True),
|
|
|
- "date" : self.cfgData.getVar("DATE", True),
|
|
|
- "time" : self.cfgData.getVar("TIME", True),
|
|
|
+ "buildname" : self.cfgData.getVar("BUILDNAME"),
|
|
|
+ "date" : self.cfgData.getVar("DATE"),
|
|
|
+ "time" : self.cfgData.getVar("TIME"),
|
|
|
}
|
|
|
|
|
|
worker.stdin.write(b"<cookerconfig>" + pickle.dumps(self.cooker.configuration) + b"</cookerconfig>")
|
|
|
+ worker.stdin.write(b"<extraconfigdata>" + pickle.dumps(self.cooker.extraconfigdata) + b"</extraconfigdata>")
|
|
|
worker.stdin.write(b"<workerdata>" + pickle.dumps(workerdata) + b"</workerdata>")
|
|
|
worker.stdin.flush()
|
|
|
|
|
@@ -1062,10 +1168,9 @@ class RunQueue:
|
|
|
for mc in self.rqdata.dataCaches:
|
|
|
self.worker[mc] = self._start_worker(mc)
|
|
|
|
|
|
- def start_fakeworker(self, rqexec):
|
|
|
- if not self.fakeworker:
|
|
|
- for mc in self.rqdata.dataCaches:
|
|
|
- self.fakeworker[mc] = self._start_worker(mc, True, rqexec)
|
|
|
+ def start_fakeworker(self, rqexec, mc):
|
|
|
+ if not mc in self.fakeworker:
|
|
|
+ self.fakeworker[mc] = self._start_worker(mc, True, rqexec)
|
|
|
|
|
|
def teardown_workers(self):
|
|
|
self.teardown = True
|
|
@@ -1099,8 +1204,7 @@ class RunQueue:
|
|
|
except:
|
|
|
return None
|
|
|
|
|
|
- (mc, fn, tn) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, tn, taskfn) = split_tid_mcfn(tid)
|
|
|
if taskname is None:
|
|
|
taskname = tn
|
|
|
|
|
@@ -1134,8 +1238,7 @@ class RunQueue:
|
|
|
t1 = get_timestamp(stampfile)
|
|
|
for dep in self.rqdata.runtaskentries[tid].depends:
|
|
|
if iscurrent:
|
|
|
- (mc2, fn2, taskname2) = split_tid(dep)
|
|
|
- taskfn2 = taskfn_fromtid(dep)
|
|
|
+ (mc2, fn2, taskname2, taskfn2) = split_tid_mcfn(dep)
|
|
|
stampfile2 = bb.build.stampfile(taskname2, self.rqdata.dataCaches[mc2], taskfn2)
|
|
|
stampfile3 = bb.build.stampfile(taskname2 + "_setscene", self.rqdata.dataCaches[mc2], taskfn2)
|
|
|
t2 = get_timestamp(stampfile2)
|
|
@@ -1213,10 +1316,12 @@ class RunQueue:
|
|
|
self.rqdata.init_progress_reporter.next_stage()
|
|
|
self.rqexe = RunQueueExecuteScenequeue(self)
|
|
|
|
|
|
- if self.state in [runQueueSceneRun, runQueueRunning, runQueueCleanUp]:
|
|
|
- self.dm.check(self)
|
|
|
-
|
|
|
if self.state is runQueueSceneRun:
|
|
|
+ if not self.dm_event_handler_registered:
|
|
|
+ res = bb.event.register(self.dm_event_handler_name,
|
|
|
+ lambda x: self.dm.check(self) if self.state in [runQueueSceneRun, runQueueRunning, runQueueCleanUp] else False,
|
|
|
+ ('bb.event.HeartbeatEvent',))
|
|
|
+ self.dm_event_handler_registered = True
|
|
|
retval = self.rqexe.execute()
|
|
|
|
|
|
if self.state is runQueueRunInit:
|
|
@@ -1235,7 +1340,13 @@ class RunQueue:
|
|
|
if self.state is runQueueCleanUp:
|
|
|
retval = self.rqexe.finish()
|
|
|
|
|
|
- if (self.state is runQueueComplete or self.state is runQueueFailed) and self.rqexe:
|
|
|
+ build_done = self.state is runQueueComplete or self.state is runQueueFailed
|
|
|
+
|
|
|
+ if build_done and self.dm_event_handler_registered:
|
|
|
+ bb.event.remove(self.dm_event_handler_name, None)
|
|
|
+ self.dm_event_handler_registered = False
|
|
|
+
|
|
|
+ if build_done and self.rqexe:
|
|
|
self.teardown_workers()
|
|
|
if self.rqexe.stats.failed:
|
|
|
logger.info("Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed.", self.rqexe.stats.completed + self.rqexe.stats.failed, self.rqexe.stats.skipped, self.rqexe.stats.failed)
|
|
@@ -1244,12 +1355,7 @@ class RunQueue:
|
|
|
logger.info("Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and all succeeded.", self.rqexe.stats.completed, self.rqexe.stats.skipped)
|
|
|
|
|
|
if self.state is runQueueFailed:
|
|
|
- if not self.rqdata.taskData[''].tryaltconfigs:
|
|
|
- raise bb.runqueue.TaskFailure(self.rqexe.failed_tids)
|
|
|
- for tid in self.rqexe.failed_tids:
|
|
|
- (mc, fn, tn) = split_tid(tid)
|
|
|
- self.rqdata.taskData[mc].fail_fn(fn)
|
|
|
- self.rqdata.reset()
|
|
|
+ raise bb.runqueue.TaskFailure(self.rqexe.failed_tids)
|
|
|
|
|
|
if self.state is runQueueComplete:
|
|
|
# All done
|
|
@@ -1292,15 +1398,36 @@ class RunQueue:
|
|
|
else:
|
|
|
self.rqexe.finish()
|
|
|
|
|
|
+ def rq_dump_sigfn(self, fn, options):
|
|
|
+ bb_cache = bb.cache.NoCache(self.cooker.databuilder)
|
|
|
+ the_data = bb_cache.loadDataFull(fn, self.cooker.collection.get_file_appends(fn))
|
|
|
+ siggen = bb.parse.siggen
|
|
|
+ dataCaches = self.rqdata.dataCaches
|
|
|
+ siggen.dump_sigfn(fn, dataCaches, options)
|
|
|
+
|
|
|
def dump_signatures(self, options):
|
|
|
- done = set()
|
|
|
+ fns = set()
|
|
|
bb.note("Reparsing files to collect dependency data")
|
|
|
- bb_cache = bb.cache.NoCache(self.cooker.databuilder)
|
|
|
+
|
|
|
for tid in self.rqdata.runtaskentries:
|
|
|
- fn = taskfn_fromtid(tid)
|
|
|
- if fn not in done:
|
|
|
- the_data = bb_cache.loadDataFull(fn, self.cooker.collection.get_file_appends(fn))
|
|
|
- done.add(fn)
|
|
|
+ fn = fn_from_tid(tid)
|
|
|
+ fns.add(fn)
|
|
|
+
|
|
|
+ max_process = int(self.cfgData.getVar("BB_NUMBER_PARSE_THREADS") or os.cpu_count() or 1)
|
|
|
+ # We cannot use the real multiprocessing.Pool easily due to some local data
|
|
|
+ # that can't be pickled. This is a cheap multi-process solution.
|
|
|
+ launched = []
|
|
|
+ while fns:
|
|
|
+ if len(launched) < max_process:
|
|
|
+ p = Process(target=self.rq_dump_sigfn, args=(fns.pop(), options))
|
|
|
+ p.start()
|
|
|
+ launched.append(p)
|
|
|
+ for q in launched:
|
|
|
+ # The finished processes are joined when calling is_alive()
|
|
|
+ if not q.is_alive():
|
|
|
+ launched.remove(q)
|
|
|
+ for p in launched:
|
|
|
+ p.join()
|
|
|
|
|
|
bb.parse.siggen.dump_sigs(self.rqdata.dataCaches, options)
|
|
|
|
|
@@ -1319,8 +1446,7 @@ class RunQueue:
|
|
|
valid_new = set()
|
|
|
|
|
|
for tid in self.rqdata.runtaskentries:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
|
|
|
if 'noexec' in taskdep and taskname in taskdep['noexec']:
|
|
@@ -1328,11 +1454,11 @@ class RunQueue:
|
|
|
continue
|
|
|
|
|
|
sq_fn.append(fn)
|
|
|
- sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[fn])
|
|
|
+ sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn])
|
|
|
sq_hash.append(self.rqdata.runtaskentries[tid].hash)
|
|
|
sq_taskname.append(taskname)
|
|
|
sq_task.append(tid)
|
|
|
- locs = { "sq_fn" : sq_fn, "sq_task" : sq_taskname, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, "d" : self.cooker.expanded_data }
|
|
|
+ locs = { "sq_fn" : sq_fn, "sq_task" : sq_taskname, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, "d" : self.cooker.data }
|
|
|
try:
|
|
|
call = self.hashvalidate + "(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=True)"
|
|
|
valid = bb.utils.better_eval(call, locs)
|
|
@@ -1408,8 +1534,8 @@ class RunQueue:
|
|
|
|
|
|
|
|
|
for tid in invalidtasks:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- pn = self.rqdata.dataCaches[mc].pkg_fn[fn]
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
+ pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
h = self.rqdata.runtaskentries[tid].hash
|
|
|
matches = bb.siggen.find_siginfo(pn, taskname, [], self.cfgData)
|
|
|
match = None
|
|
@@ -1433,8 +1559,8 @@ class RunQueueExecute:
|
|
|
self.cfgData = rq.cfgData
|
|
|
self.rqdata = rq.rqdata
|
|
|
|
|
|
- self.number_tasks = int(self.cfgData.getVar("BB_NUMBER_THREADS", True) or 1)
|
|
|
- self.scheduler = self.cfgData.getVar("BB_SCHEDULER", True) or "speed"
|
|
|
+ self.number_tasks = int(self.cfgData.getVar("BB_NUMBER_THREADS") or 1)
|
|
|
+ self.scheduler = self.cfgData.getVar("BB_SCHEDULER") or "speed"
|
|
|
|
|
|
self.runq_buildable = set()
|
|
|
self.runq_running = set()
|
|
@@ -1512,11 +1638,11 @@ class RunQueueExecute:
|
|
|
taskdata = {}
|
|
|
taskdeps.add(task)
|
|
|
for dep in taskdeps:
|
|
|
- (mc, fn, taskname) = split_tid(dep)
|
|
|
- pn = self.rqdata.dataCaches[mc].pkg_fn[fn]
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(dep)
|
|
|
+ pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
taskdata[dep] = [pn, taskname, fn]
|
|
|
call = self.rq.depvalidate + "(task, taskdata, notneeded, d)"
|
|
|
- locs = { "task" : task, "taskdata" : taskdata, "notneeded" : self.scenequeue_notneeded, "d" : self.cooker.expanded_data }
|
|
|
+ locs = { "task" : task, "taskdata" : taskdata, "notneeded" : self.scenequeue_notneeded, "d" : self.cooker.data }
|
|
|
valid = bb.utils.better_eval(call, locs)
|
|
|
return valid
|
|
|
|
|
@@ -1569,8 +1695,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
tasknames = {}
|
|
|
fns = {}
|
|
|
for tid in self.rqdata.runtaskentries:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
fns[tid] = taskfn
|
|
|
tasknames[tid] = taskname
|
|
@@ -1585,13 +1710,12 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
invalidtasks.append(tid)
|
|
|
|
|
|
call = self.rq.setsceneverify + "(covered, tasknames, fns, d, invalidtasks=invalidtasks)"
|
|
|
- locs = { "covered" : self.rq.scenequeue_covered, "tasknames" : tasknames, "fns" : fns, "d" : self.cooker.expanded_data, "invalidtasks" : invalidtasks }
|
|
|
+ locs = { "covered" : self.rq.scenequeue_covered, "tasknames" : tasknames, "fns" : fns, "d" : self.cooker.data, "invalidtasks" : invalidtasks }
|
|
|
covered_remove = bb.utils.better_eval(call, locs)
|
|
|
|
|
|
def removecoveredtask(tid):
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
taskname = taskname + '_setscene'
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
bb.build.del_stamp(taskname, self.rqdata.dataCaches[mc], taskfn)
|
|
|
self.rq.scenequeue_covered.remove(tid)
|
|
|
|
|
@@ -1617,7 +1741,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
for mc in self.rqdata.dataCaches:
|
|
|
target_pairs = []
|
|
|
for tid in self.rqdata.target_tids:
|
|
|
- (tidmc, fn, taskname) = split_tid(tid)
|
|
|
+ (tidmc, fn, taskname, _) = split_tid_mcfn(tid)
|
|
|
if tidmc == mc:
|
|
|
target_pairs.append((fn, taskname))
|
|
|
|
|
@@ -1638,7 +1762,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
if type(obj) is type and
|
|
|
issubclass(obj, RunQueueScheduler))
|
|
|
|
|
|
- user_schedulers = self.cfgData.getVar("BB_SCHEDULERS", True)
|
|
|
+ user_schedulers = self.cfgData.getVar("BB_SCHEDULERS")
|
|
|
if user_schedulers:
|
|
|
for sched in user_schedulers.split():
|
|
|
if not "." in sched:
|
|
@@ -1657,7 +1781,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
|
|
|
def setbuildable(self, task):
|
|
|
self.runq_buildable.add(task)
|
|
|
- self.sched.newbuilable(task)
|
|
|
+ self.sched.newbuildable(task)
|
|
|
|
|
|
def task_completeoutright(self, task):
|
|
|
"""
|
|
@@ -1710,10 +1834,12 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
Run the tasks in a queue prepared by rqdata.prepare()
|
|
|
"""
|
|
|
|
|
|
- if self.rqdata.setscenewhitelist:
|
|
|
+ if self.rqdata.setscenewhitelist is not None and not self.rqdata.setscenewhitelist_checked:
|
|
|
+ self.rqdata.setscenewhitelist_checked = True
|
|
|
+
|
|
|
# Check tasks that are going to run against the whitelist
|
|
|
def check_norun_task(tid, showerror=False):
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
# Ignore covered tasks
|
|
|
if tid in self.rq.scenequeue_covered:
|
|
|
return False
|
|
@@ -1721,11 +1847,11 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
if self.rq.check_stamp_task(tid, taskname, cache=self.stampcache):
|
|
|
return False
|
|
|
# Ignore noexec tasks
|
|
|
- taskdep = self.rqdata.dataCaches[mc].task_deps[fn]
|
|
|
+ taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
if 'noexec' in taskdep and taskname in taskdep['noexec']:
|
|
|
return False
|
|
|
|
|
|
- pn = self.rqdata.dataCaches[mc].pkg_fn[fn]
|
|
|
+ pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
if not check_setscene_enforce_whitelist(pn, taskname, self.rqdata.setscenewhitelist):
|
|
|
if showerror:
|
|
|
if tid in self.rqdata.runq_setscene_tids:
|
|
@@ -1761,8 +1887,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
|
|
|
task = self.sched.next()
|
|
|
if task is not None:
|
|
|
- (mc, fn, taskname) = split_tid(task)
|
|
|
- taskfn = taskfn_fromtid(task)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(task)
|
|
|
|
|
|
if task in self.rq.scenequeue_covered:
|
|
|
logger.debug(2, "Setscene covered task %s", task)
|
|
@@ -1782,7 +1907,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
bb.event.fire(startevent, self.cfgData)
|
|
|
self.runq_running.add(task)
|
|
|
self.stats.taskActive()
|
|
|
- if not self.cooker.configuration.dry_run:
|
|
|
+ if not (self.cooker.configuration.dry_run or self.rqdata.setscene_enforce):
|
|
|
bb.build.make_stamp(taskname, self.rqdata.dataCaches[mc], taskfn)
|
|
|
self.task_complete(task)
|
|
|
return True
|
|
@@ -1793,19 +1918,19 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
taskdepdata = self.build_taskdepdata(task)
|
|
|
|
|
|
taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
- if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not self.cooker.configuration.dry_run:
|
|
|
- if not self.rq.fakeworker:
|
|
|
+ if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not (self.cooker.configuration.dry_run or self.rqdata.setscene_enforce):
|
|
|
+ if not mc in self.rq.fakeworker:
|
|
|
try:
|
|
|
- self.rq.start_fakeworker(self)
|
|
|
+ self.rq.start_fakeworker(self, mc)
|
|
|
except OSError as exc:
|
|
|
logger.critical("Failed to spawn fakeroot worker to run %s: %s" % (task, str(exc)))
|
|
|
self.rq.state = runQueueFailed
|
|
|
self.stats.taskFailed()
|
|
|
return True
|
|
|
- self.rq.fakeworker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, False, self.cooker.collection.get_file_appends(fn), taskdepdata)) + b"</runtask>")
|
|
|
+ self.rq.fakeworker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, False, self.cooker.collection.get_file_appends(taskfn), taskdepdata, self.rqdata.setscene_enforce)) + b"</runtask>")
|
|
|
self.rq.fakeworker[mc].process.stdin.flush()
|
|
|
else:
|
|
|
- self.rq.worker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, False, self.cooker.collection.get_file_appends(taskfn), taskdepdata)) + b"</runtask>")
|
|
|
+ self.rq.worker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, False, self.cooker.collection.get_file_appends(taskfn), taskdepdata, self.rqdata.setscene_enforce)) + b"</runtask>")
|
|
|
self.rq.worker[mc].process.stdin.flush()
|
|
|
|
|
|
self.build_stamps[task] = bb.build.stampfile(taskname, self.rqdata.dataCaches[mc], taskfn, noextra=True)
|
|
@@ -1842,12 +1967,12 @@ class RunQueueExecuteTasks(RunQueueExecute):
|
|
|
while next:
|
|
|
additional = []
|
|
|
for revdep in next:
|
|
|
- (mc, fn, taskname) = split_tid(revdep)
|
|
|
- taskfn = taskfn_fromtid(revdep)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(revdep)
|
|
|
pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
deps = self.rqdata.runtaskentries[revdep].depends
|
|
|
provides = self.rqdata.dataCaches[mc].fn_provides[taskfn]
|
|
|
- taskdepdata[revdep] = [pn, taskname, fn, deps, provides]
|
|
|
+ taskhash = self.rqdata.runtaskentries[revdep].hash
|
|
|
+ taskdepdata[revdep] = [pn, taskname, fn, deps, provides, taskhash]
|
|
|
for revdep2 in deps:
|
|
|
if revdep2 not in taskdepdata:
|
|
|
additional.append(revdep2)
|
|
@@ -1876,6 +2001,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
sq_revdeps_new = {}
|
|
|
sq_revdeps_squash = {}
|
|
|
self.sq_harddeps = {}
|
|
|
+ self.stamps = {}
|
|
|
|
|
|
# We need to construct a dependency graph for the setscene functions. Intermediate
|
|
|
# dependencies between the setscene tasks only complicate the code. This code
|
|
@@ -1899,6 +2025,8 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
for tid in self.rqdata.runq_setscene_tids:
|
|
|
#bb.warn("Added endpoint 2 %s" % (tid))
|
|
|
for dep in self.rqdata.runtaskentries[tid].depends:
|
|
|
+ if tid in sq_revdeps[dep]:
|
|
|
+ sq_revdeps[dep].remove(tid)
|
|
|
if dep not in endpoints:
|
|
|
endpoints[dep] = set()
|
|
|
#bb.warn(" Added endpoint 3 %s" % (dep))
|
|
@@ -1918,12 +2046,13 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
if point in self.rqdata.runq_setscene_tids:
|
|
|
sq_revdeps_new[point] = tasks
|
|
|
tasks = set()
|
|
|
+ continue
|
|
|
for dep in self.rqdata.runtaskentries[point].depends:
|
|
|
if point in sq_revdeps[dep]:
|
|
|
sq_revdeps[dep].remove(point)
|
|
|
if tasks:
|
|
|
sq_revdeps_new[dep] |= tasks
|
|
|
- if (len(sq_revdeps[dep]) == 0 or len(sq_revdeps_new[dep]) != 0) and dep not in self.rqdata.runq_setscene_tids:
|
|
|
+ if len(sq_revdeps[dep]) == 0 and dep not in self.rqdata.runq_setscene_tids:
|
|
|
newendpoints[dep] = task
|
|
|
if len(newendpoints) != 0:
|
|
|
process_endpoints(newendpoints)
|
|
@@ -1986,9 +2115,10 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
# e.g. do_sometask_setscene[depends] = "targetname:do_someothertask_setscene"
|
|
|
# Note that anything explicitly depended upon will have its reverse dependencies removed to avoid circular dependencies
|
|
|
for tid in self.rqdata.runq_setscene_tids:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- realtid = fn + ":" + taskname + "_setscene"
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
+ realtid = tid + "_setscene"
|
|
|
idepends = self.rqdata.taskData[mc].taskentries[realtid].idepends
|
|
|
+ self.stamps[tid] = bb.build.stampfile(taskname + "_setscene", self.rqdata.dataCaches[mc], taskfn, noextra=True)
|
|
|
for (depname, idependtask) in idepends:
|
|
|
|
|
|
if depname not in self.rqdata.taskData[mc].build_targets:
|
|
@@ -2050,10 +2180,9 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
noexec = []
|
|
|
stamppresent = []
|
|
|
for tid in self.sq_revdeps:
|
|
|
- (mc, fn, taskname) = split_tid(tid)
|
|
|
- taskfn = taskfn_fromtid(tid)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
|
|
|
|
|
- taskdep = self.rqdata.dataCaches[mc].task_deps[fn]
|
|
|
+ taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
|
|
|
if 'noexec' in taskdep and taskname in taskdep['noexec']:
|
|
|
noexec.append(tid)
|
|
@@ -2074,12 +2203,12 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
continue
|
|
|
|
|
|
sq_fn.append(fn)
|
|
|
- sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[fn])
|
|
|
+ sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn])
|
|
|
sq_hash.append(self.rqdata.runtaskentries[tid].hash)
|
|
|
sq_taskname.append(taskname)
|
|
|
sq_task.append(tid)
|
|
|
call = self.rq.hashvalidate + "(sq_fn, sq_task, sq_hash, sq_hashfn, d)"
|
|
|
- locs = { "sq_fn" : sq_fn, "sq_task" : sq_taskname, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, "d" : self.cooker.expanded_data }
|
|
|
+ locs = { "sq_fn" : sq_fn, "sq_task" : sq_taskname, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, "d" : self.cooker.data }
|
|
|
valid = bb.utils.better_eval(call, locs)
|
|
|
|
|
|
valid_new = stamppresent
|
|
@@ -2120,10 +2249,10 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
self.scenequeue_updatecounters(task)
|
|
|
|
|
|
def check_taskfail(self, task):
|
|
|
- if self.rqdata.setscenewhitelist:
|
|
|
+ if self.rqdata.setscenewhitelist is not None:
|
|
|
realtask = task.split('_setscene')[0]
|
|
|
- (mc, fn, taskname) = split_tid(realtask)
|
|
|
- pn = self.rqdata.dataCaches[mc].pkg_fn[fn]
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(realtask)
|
|
|
+ pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
if not check_setscene_enforce_whitelist(pn, taskname, self.rqdata.setscenewhitelist):
|
|
|
logger.error('Task %s.%s failed' % (pn, taskname + "_setscene"))
|
|
|
self.rq.state = runQueueCleanUp
|
|
@@ -2166,7 +2295,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
if self.stats.active < self.number_tasks:
|
|
|
# Find the next setscene to run
|
|
|
for nexttask in self.rqdata.runq_setscene_tids:
|
|
|
- if nexttask in self.runq_buildable and nexttask not in self.runq_running:
|
|
|
+ if nexttask in self.runq_buildable and nexttask not in self.runq_running and self.stamps[nexttask] not in self.build_stamps.values():
|
|
|
if nexttask in self.unskippable:
|
|
|
logger.debug(2, "Setscene task %s is unskippable" % nexttask)
|
|
|
if nexttask not in self.unskippable and len(self.sq_revdeps[nexttask]) > 0 and self.sq_revdeps[nexttask].issubset(self.scenequeue_covered) and self.check_dependencies(nexttask, self.sq_revdeps[nexttask], True):
|
|
@@ -2186,8 +2315,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
task = nexttask
|
|
|
break
|
|
|
if task is not None:
|
|
|
- (mc, fn, taskname) = split_tid(task)
|
|
|
- taskfn = taskfn_fromtid(task)
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(task)
|
|
|
taskname = taskname + "_setscene"
|
|
|
if self.rq.check_stamp_task(task, taskname_from_tid(task), recurse = True, cache=self.stampcache):
|
|
|
logger.debug(2, 'Stamp for underlying task %s is current, so skipping setscene variant', task)
|
|
@@ -2207,16 +2335,20 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
startevent = sceneQueueTaskStarted(task, self.stats, self.rq)
|
|
|
bb.event.fire(startevent, self.cfgData)
|
|
|
|
|
|
+ taskdepdata = self.build_taskdepdata(task)
|
|
|
+
|
|
|
taskdep = self.rqdata.dataCaches[mc].task_deps[taskfn]
|
|
|
if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not self.cooker.configuration.dry_run:
|
|
|
- if not self.rq.fakeworker:
|
|
|
- self.rq.start_fakeworker(self)
|
|
|
- self.rq.fakeworker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, True, self.cooker.collection.get_file_appends(taskfn), None)) + b"</runtask>")
|
|
|
+ if not mc in self.rq.fakeworker:
|
|
|
+ self.rq.start_fakeworker(self, mc)
|
|
|
+ self.rq.fakeworker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, True, self.cooker.collection.get_file_appends(taskfn), taskdepdata, False)) + b"</runtask>")
|
|
|
self.rq.fakeworker[mc].process.stdin.flush()
|
|
|
else:
|
|
|
- self.rq.worker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, True, self.cooker.collection.get_file_appends(taskfn), None)) + b"</runtask>")
|
|
|
+ self.rq.worker[mc].process.stdin.write(b"<runtask>" + pickle.dumps((taskfn, task, taskname, True, self.cooker.collection.get_file_appends(taskfn), taskdepdata, False)) + b"</runtask>")
|
|
|
self.rq.worker[mc].process.stdin.flush()
|
|
|
|
|
|
+ self.build_stamps[task] = bb.build.stampfile(taskname, self.rqdata.dataCaches[mc], taskfn, noextra=True)
|
|
|
+ self.build_stamps2.append(self.build_stamps[task])
|
|
|
self.runq_running.add(task)
|
|
|
self.stats.taskActive()
|
|
|
if self.stats.active < self.number_tasks:
|
|
@@ -2235,7 +2367,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
self.rq.scenequeue_covered = self.scenequeue_covered
|
|
|
self.rq.scenequeue_notcovered = self.scenequeue_notcovered
|
|
|
|
|
|
- logger.debug(1, 'We can skip tasks %s', sorted(self.rq.scenequeue_covered))
|
|
|
+ logger.debug(1, 'We can skip tasks %s', "\n".join(sorted(self.rq.scenequeue_covered)))
|
|
|
|
|
|
self.rq.state = runQueueRunInit
|
|
|
|
|
@@ -2247,6 +2379,44 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
|
|
|
def runqueue_process_waitpid(self, task, status):
|
|
|
RunQueueExecute.runqueue_process_waitpid(self, task, status)
|
|
|
|
|
|
+
|
|
|
+ def build_taskdepdata(self, task):
|
|
|
+ def getsetscenedeps(tid):
|
|
|
+ deps = set()
|
|
|
+ (mc, fn, taskname, _) = split_tid_mcfn(tid)
|
|
|
+ realtid = tid + "_setscene"
|
|
|
+ idepends = self.rqdata.taskData[mc].taskentries[realtid].idepends
|
|
|
+ for (depname, idependtask) in idepends:
|
|
|
+ if depname not in self.rqdata.taskData[mc].build_targets:
|
|
|
+ continue
|
|
|
+
|
|
|
+ depfn = self.rqdata.taskData[mc].build_targets[depname][0]
|
|
|
+ if depfn is None:
|
|
|
+ continue
|
|
|
+ deptid = depfn + ":" + idependtask.replace("_setscene", "")
|
|
|
+ deps.add(deptid)
|
|
|
+ return deps
|
|
|
+
|
|
|
+ taskdepdata = {}
|
|
|
+ next = getsetscenedeps(task)
|
|
|
+ next.add(task)
|
|
|
+ while next:
|
|
|
+ additional = []
|
|
|
+ for revdep in next:
|
|
|
+ (mc, fn, taskname, taskfn) = split_tid_mcfn(revdep)
|
|
|
+ pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
|
|
|
+ deps = getsetscenedeps(revdep)
|
|
|
+ provides = self.rqdata.dataCaches[mc].fn_provides[taskfn]
|
|
|
+ taskhash = self.rqdata.runtaskentries[revdep].hash
|
|
|
+ taskdepdata[revdep] = [pn, taskname, fn, deps, provides, taskhash]
|
|
|
+ for revdep2 in deps:
|
|
|
+ if revdep2 not in taskdepdata:
|
|
|
+ additional.append(revdep2)
|
|
|
+ next = additional
|
|
|
+
|
|
|
+ #bb.note("Task %s: " % task + str(taskdepdata).replace("], ", "],\n"))
|
|
|
+ return taskdepdata
|
|
|
+
|
|
|
class TaskFailure(Exception):
|
|
|
"""
|
|
|
Exception raised when a task in a runqueue fails
|
|
@@ -2313,6 +2483,9 @@ class runQueueTaskFailed(runQueueEvent):
|
|
|
runQueueEvent.__init__(self, task, stats, rq)
|
|
|
self.exitcode = exitcode
|
|
|
|
|
|
+ def __str__(self):
|
|
|
+ return "Task (%s) failed with exit code '%s'" % (self.taskstring, self.exitcode)
|
|
|
+
|
|
|
class sceneQueueTaskFailed(sceneQueueEvent):
|
|
|
"""
|
|
|
Event notifying a setscene task failed
|
|
@@ -2321,6 +2494,9 @@ class sceneQueueTaskFailed(sceneQueueEvent):
|
|
|
sceneQueueEvent.__init__(self, task, stats, rq)
|
|
|
self.exitcode = exitcode
|
|
|
|
|
|
+ def __str__(self):
|
|
|
+ return "Setscene task (%s) failed with exit code '%s' - real task will be run instead" % (self.taskstring, self.exitcode)
|
|
|
+
|
|
|
class sceneQueueComplete(sceneQueueEvent):
|
|
|
"""
|
|
|
Event when all the sceneQueue tasks are complete
|
|
@@ -2365,16 +2541,11 @@ class runQueuePipe():
|
|
|
self.rqexec = rqexec
|
|
|
|
|
|
def read(self):
|
|
|
- for w in [self.rq.worker, self.rq.fakeworker]:
|
|
|
- for mc in w:
|
|
|
- w[mc].process.poll()
|
|
|
- if w[mc].process.returncode is not None and not self.rq.teardown:
|
|
|
- name = None
|
|
|
- if w in self.rq.worker:
|
|
|
- name = "Worker"
|
|
|
- elif w in self.rq.fakeworker:
|
|
|
- name = "Fakeroot"
|
|
|
- bb.error("%s process (%s) exited unexpectedly (%s), shutting down..." % (name, w.pid, str(w.returncode)))
|
|
|
+ for workers, name in [(self.rq.worker, "Worker"), (self.rq.fakeworker, "Fakeroot")]:
|
|
|
+ for worker in workers.values():
|
|
|
+ worker.process.poll()
|
|
|
+ if worker.process.returncode is not None and not self.rq.teardown:
|
|
|
+ bb.error("%s process (%s) exited unexpectedly (%s), shutting down..." % (name, worker.process.pid, str(worker.process.returncode)))
|
|
|
self.rq.finish_runqueue(True)
|
|
|
|
|
|
start = len(self.queue)
|
|
@@ -2417,9 +2588,9 @@ class runQueuePipe():
|
|
|
self.input.close()
|
|
|
|
|
|
def get_setscene_enforce_whitelist(d):
|
|
|
- if d.getVar('BB_SETSCENE_ENFORCE', True) != '1':
|
|
|
+ if d.getVar('BB_SETSCENE_ENFORCE') != '1':
|
|
|
return None
|
|
|
- whitelist = (d.getVar("BB_SETSCENE_ENFORCE_WHITELIST", True) or "").split()
|
|
|
+ whitelist = (d.getVar("BB_SETSCENE_ENFORCE_WHITELIST") or "").split()
|
|
|
outlist = []
|
|
|
for item in whitelist[:]:
|
|
|
if item.startswith('%:'):
|
|
@@ -2432,7 +2603,7 @@ def get_setscene_enforce_whitelist(d):
|
|
|
|
|
|
def check_setscene_enforce_whitelist(pn, taskname, whitelist):
|
|
|
import fnmatch
|
|
|
- if whitelist:
|
|
|
+ if whitelist is not None:
|
|
|
item = '%s:%s' % (pn, taskname)
|
|
|
for whitelist_item in whitelist:
|
|
|
if fnmatch.fnmatch(item, whitelist_item):
|