summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-29 15:46:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-06 11:21:32 +0100
commit40a5e193c4ba45c928fccd899415ea56b5417725 (patch)
treeedc19c09d09e7a84dfc4fba2fac021ac63801ced
parent43d37a6eaf2224c0dda1d1436a0afc2bd34fdddf (diff)
downloadpoky-40a5e193c4ba45c928fccd899415ea56b5417725.tar.gz
bitbake: runqueue: Clean up BB_HASHCHECK_FUNCTION API
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. (Bitbake rev: dc23550047e5078da491ce9a6f30989cb5260df6) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/runqueue.py54
-rw-r--r--bitbake/lib/bb/tests/runqueue-tests/classes/base.bbclass22
2 files changed, 23 insertions, 53 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 82cc9af81b..f0f95f9b5e 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1388,57 +1388,29 @@ class RunQueue:
1388 cache[tid] = iscurrent 1388 cache[tid] = iscurrent
1389 return iscurrent 1389 return iscurrent
1390 1390
1391 def validate_hashes(self, tocheck, data, presentcount=None, siginfo=False): 1391 def validate_hashes(self, tocheck, data, currentcount=None, siginfo=False):
1392 valid = set() 1392 valid = set()
1393 if self.hashvalidate: 1393 if self.hashvalidate:
1394 sq_hash = [] 1394 sq_data = {}
1395 sq_hashfn = [] 1395 sq_data['hash'] = {}
1396 sq_unihash = [] 1396 sq_data['hashfn'] = {}
1397 sq_fn = [] 1397 sq_data['unihash'] = {}
1398 sq_taskname = []
1399 sq_task = []
1400 for tid in tocheck: 1398 for tid in tocheck:
1401 (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) 1399 (mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
1400 sq_data['hash'][tid] = self.rqdata.runtaskentries[tid].hash
1401 sq_data['hashfn'][tid] = self.rqdata.dataCaches[mc].hashfn[taskfn]
1402 sq_data['unihash'][tid] = self.rqdata.runtaskentries[tid].unihash
1402 1403
1403 sq_fn.append(fn) 1404 valid_ids = self.validate_hash(sq_data, data, siginfo, currentcount)
1404 sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn])
1405 sq_hash.append(self.rqdata.runtaskentries[tid].hash)
1406 sq_unihash.append(self.rqdata.runtaskentries[tid].unihash)
1407 sq_taskname.append(taskname)
1408 sq_task.append(tid)
1409
1410 if presentcount is not None:
1411 data.setVar("BB_SETSCENE_STAMPCURRENT_COUNT", presentcount)
1412
1413 valid_ids = self.validate_hash(sq_fn, sq_taskname, sq_hash, sq_hashfn, siginfo, sq_unihash, data, presentcount)
1414
1415 if presentcount is not None:
1416 data.delVar("BB_SETSCENE_STAMPCURRENT_COUNT")
1417
1418 for v in valid_ids:
1419 valid.add(sq_task[v])
1420 1405
1421 return valid 1406 return valid
1422 1407
1423 def validate_hash(self, sq_fn, sq_task, sq_hash, sq_hashfn, siginfo, sq_unihash, d, presentcount): 1408 def validate_hash(self, sq_data, d, siginfo, currentcount):
1424 locs = {"sq_fn" : sq_fn, "sq_task" : sq_task, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, 1409 locs = {"sq_data" : sq_data, "d" : d, "siginfo" : siginfo, "currentcount" : currentcount}
1425 "sq_unihash" : sq_unihash, "siginfo" : siginfo, "d" : d}
1426 1410
1427 # Backwards compatibility 1411 # Metadata has **kwargs so args can be added, sq_data can also gain new fields
1428 hashvalidate_args = ("(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo, sq_unihash=sq_unihash)", 1412 call = self.hashvalidate + "(sq_data, d, siginfo=siginfo, currentcount=currentcount)"
1429 "(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo)",
1430 "(sq_fn, sq_task, sq_hash, sq_hashfn, d)")
1431
1432 for args in hashvalidate_args[:-1]:
1433 try:
1434 call = self.hashvalidate + args
1435 return bb.utils.better_eval(call, locs)
1436 except TypeError:
1437 continue
1438 1413
1439 # Call the last entry without a try...catch to propagate any thrown
1440 # TypeError
1441 call = self.hashvalidate + hashvalidate_args[-1]
1442 return bb.utils.better_eval(call, locs) 1414 return bb.utils.better_eval(call, locs)
1443 1415
1444 def _execute_runqueue(self): 1416 def _execute_runqueue(self):
diff --git a/bitbake/lib/bb/tests/runqueue-tests/classes/base.bbclass b/bitbake/lib/bb/tests/runqueue-tests/classes/base.bbclass
index 5b87e20bce..3a0f151c9a 100644
--- a/bitbake/lib/bb/tests/runqueue-tests/classes/base.bbclass
+++ b/bitbake/lib/bb/tests/runqueue-tests/classes/base.bbclass
@@ -216,27 +216,25 @@ def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
216 216
217BB_HASHCHECK_FUNCTION = "sstate_checkhashes" 217BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
218 218
219def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=False, *, sq_unihash=None): 219def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, **kwargs):
220 220
221 ret = [] 221 found = set()
222 missed = [] 222 missed = set()
223 223
224 valid = d.getVar("SSTATEVALID").split() 224 valid = d.getVar("SSTATEVALID").split()
225 225
226 for task in range(len(sq_fn)): 226 for tid in sq_data['hash']:
227 n = os.path.basename(sq_fn[task]).rsplit(".", 1)[0] + ":" + sq_task[task] 227 n = os.path.basename(bb.runqueue.fn_from_tid(tid)).split(".")[0] + ":do_" + bb.runqueue.taskname_from_tid(tid)[3:]
228 print(n)
228 if n in valid: 229 if n in valid:
229 bb.note("SState: Found valid sstate for %s" % n) 230 bb.note("SState: Found valid sstate for %s" % n)
230 ret.append(task) 231 found.add(tid)
231 elif os.path.exists(d.expand("${TOPDIR}/%s.run" % n.replace("do_", ""))): 232 elif os.path.exists(d.expand("${TOPDIR}/%s.run" % n.replace("do_", ""))):
232 bb.note("SState: Found valid sstate for %s (already run)" % n) 233 bb.note("SState: Found valid sstate for %s (already run)" % n)
233 ret.append(task) 234 found.add(tid)
234 else: 235 else:
235 missed.append(task) 236 missed.add(tid)
236 bb.note("SState: Found no valid sstate for %s" % n) 237 bb.note("SState: Found no valid sstate for %s" % n)
237 238
238 if hasattr(bb.parse.siggen, "checkhashes"): 239 return found
239 bb.parse.siggen.checkhashes(missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d)
240
241 return ret
242 240