[bitbake-devel] [PATCH 12/16] runqueue: Clean up BB_HASHCHECK_FUNCTION API
Richard Purdie
richard.purdie at linuxfoundation.org
Fri Aug 2 15:20:45 UTC 2019
This function uses an old API which uses offsets into lists as a communication
mechanism. Update the API to use "tid" which is used universally in runqueue now.
We can also add kwargs support to the funciton definition to drop some of the
backwards compaiblility hoops we had to jump though with different function
argument combinations.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/runqueue.py | 54 +++++--------------
.../tests/runqueue-tests/classes/base.bbclass | 22 ++++----
2 files changed, 23 insertions(+), 53 deletions(-)
diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 8b9cb688fd..07dc5c0003 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -1388,57 +1388,29 @@ class RunQueue:
cache[tid] = iscurrent
return iscurrent
- def validate_hashes(self, tocheck, data, presentcount=None, siginfo=False):
+ def validate_hashes(self, tocheck, data, currentcount=None, siginfo=False):
valid = set()
if self.hashvalidate:
- sq_hash = []
- sq_hashfn = []
- sq_unihash = []
- sq_fn = []
- sq_taskname = []
- sq_task = []
+ sq_data = {}
+ sq_data['hash'] = {}
+ sq_data['hashfn'] = {}
+ sq_data['unihash'] = {}
for tid in tocheck:
(mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
+ sq_data['hash'][tid] = self.rqdata.runtaskentries[tid].hash
+ sq_data['hashfn'][tid] = self.rqdata.dataCaches[mc].hashfn[taskfn]
+ sq_data['unihash'][tid] = self.rqdata.runtaskentries[tid].unihash
- sq_fn.append(fn)
- sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn])
- sq_hash.append(self.rqdata.runtaskentries[tid].hash)
- sq_unihash.append(self.rqdata.runtaskentries[tid].unihash)
- sq_taskname.append(taskname)
- sq_task.append(tid)
-
- if presentcount is not None:
- data.setVar("BB_SETSCENE_STAMPCURRENT_COUNT", presentcount)
-
- valid_ids = self.validate_hash(sq_fn, sq_taskname, sq_hash, sq_hashfn, siginfo, sq_unihash, data, presentcount)
-
- if presentcount is not None:
- data.delVar("BB_SETSCENE_STAMPCURRENT_COUNT")
-
- for v in valid_ids:
- valid.add(sq_task[v])
+ valid_ids = self.validate_hash(sq_data, data, siginfo, currentcount)
return valid
- def validate_hash(self, sq_fn, sq_task, sq_hash, sq_hashfn, siginfo, sq_unihash, d, presentcount):
- locs = {"sq_fn" : sq_fn, "sq_task" : sq_task, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn,
- "sq_unihash" : sq_unihash, "siginfo" : siginfo, "d" : d}
+ def validate_hash(self, sq_data, d, siginfo, currentcount):
+ locs = {"sq_data" : sq_data, "d" : d, "siginfo" : siginfo, "currentcount" : currentcount}
- # Backwards compatibility
- hashvalidate_args = ("(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo, sq_unihash=sq_unihash)",
- "(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo)",
- "(sq_fn, sq_task, sq_hash, sq_hashfn, d)")
-
- for args in hashvalidate_args[:-1]:
- try:
- call = self.hashvalidate + args
- return bb.utils.better_eval(call, locs)
- except TypeError:
- continue
+ # Metadata has **kwargs so args can be added, sq_data can also gain new fields
+ call = self.hashvalidate + "(sq_data, d, siginfo=siginfo, currentcount=currentcount)"
- # Call the last entry without a try...catch to propagate any thrown
- # TypeError
- call = self.hashvalidate + hashvalidate_args[-1]
return bb.utils.better_eval(call, locs)
def _execute_runqueue(self):
diff --git a/lib/bb/tests/runqueue-tests/classes/base.bbclass b/lib/bb/tests/runqueue-tests/classes/base.bbclass
index 5b87e20bce..3a0f151c9a 100644
--- a/lib/bb/tests/runqueue-tests/classes/base.bbclass
+++ b/lib/bb/tests/runqueue-tests/classes/base.bbclass
@@ -216,27 +216,25 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
-def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=False, *, sq_unihash=None):
+def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, **kwargs):
- ret = []
- missed = []
+ found = set()
+ missed = set()
valid = d.getVar("SSTATEVALID").split()
- for task in range(len(sq_fn)):
- n = os.path.basename(sq_fn[task]).rsplit(".", 1)[0] + ":" + sq_task[task]
+ for tid in sq_data['hash']:
+ n = os.path.basename(bb.runqueue.fn_from_tid(tid)).split(".")[0] + ":do_" + bb.runqueue.taskname_from_tid(tid)[3:]
+ print(n)
if n in valid:
bb.note("SState: Found valid sstate for %s" % n)
- ret.append(task)
+ found.add(tid)
elif os.path.exists(d.expand("${TOPDIR}/%s.run" % n.replace("do_", ""))):
bb.note("SState: Found valid sstate for %s (already run)" % n)
- ret.append(task)
+ found.add(tid)
else:
- missed.append(task)
+ missed.add(tid)
bb.note("SState: Found no valid sstate for %s" % n)
- if hasattr(bb.parse.siggen, "checkhashes"):
- bb.parse.siggen.checkhashes(missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d)
-
- return ret
+ return found
--
2.20.1
More information about the bitbake-devel
mailing list