From 05c15162de90c41dad67e37a95ec9fdb440a7864 Mon Sep 17 00:00:00 2001 From: Julien Stephan Date: Mon, 25 Sep 2023 10:04:49 +0200 Subject: bitbake: cooker: add a new function to retrieve task signatures adding a new command in cooker to compute and get task signatures this commit also add the associated command and event needed to get the signatures using tinfoil Signed-off-by: Julien Stephan Signed-off-by: Richard Purdie --- lib/bb/command.py | 6 ++++++ lib/bb/cooker.py | 31 +++++++++++++++++++++++++++++++ lib/bb/event.py | 8 ++++++++ 3 files changed, 45 insertions(+) diff --git a/lib/bb/command.py b/lib/bb/command.py index 8663eed93..f2ee58716 100644 --- a/lib/bb/command.py +++ b/lib/bb/command.py @@ -781,3 +781,9 @@ class CommandsAsync: bb.event.fire(bb.event.FindSigInfoResult(res), command.cooker.databuilder.mcdata[mc]) command.finishAsyncCommand() findSigInfo.needcache = False + + def getTaskSignatures(self, command, params): + res = command.cooker.getTaskSignatures(params[0], params[1]) + bb.event.fire(bb.event.GetTaskSignatureResult(res), command.cooker.data) + command.finishAsyncCommand() + getTaskSignatures.needcache = True diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index 87aa71bb6..599c7ddaa 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -1442,6 +1442,37 @@ class BBCooker: self.idleCallBackRegister(buildFileIdle, rq) + def getTaskSignatures(self, target, tasks): + sig = [] + getAllTaskSignatures = False + + if not tasks: + tasks = ["do_build"] + getAllTaskSignatures = True + + for task in tasks: + taskdata, runlist = self.buildTaskData(target, task, self.configuration.halt) + rq = bb.runqueue.RunQueue(self, self.data, self.recipecaches, taskdata, runlist) + rq.rqdata.prepare() + + for l in runlist: + mc, pn, taskname, fn = l + + taskdep = rq.rqdata.dataCaches[mc].task_deps[fn] + for t in taskdep['tasks']: + if t in taskdep['nostamp'] or "setscene" in t: + continue + tid = bb.runqueue.build_tid(mc, fn, t) + + if t in task or getAllTaskSignatures: + try: + rq.rqdata.prepare_task_hash(tid) + sig.append([pn, t, rq.rqdata.get_task_unihash(tid)]) + except KeyError: + sig.append(self.getTaskSignatures(target, [t])[0]) + + return sig + def buildTargets(self, targets, task): """ Attempt to build the targets specified diff --git a/lib/bb/event.py b/lib/bb/event.py index 0d0e0a68a..f8acacd80 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -857,6 +857,14 @@ class FindSigInfoResult(Event): Event.__init__(self) self.result = result +class GetTaskSignatureResult(Event): + """ + Event to return results from GetTaskSignatures command + """ + def __init__(self, sig): + Event.__init__(self) + self.sig = sig + class ParseError(Event): """ Event to indicate parse failed -- cgit 1.2.3-korg