diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-12 13:59:30 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-16 13:53:17 +0100 |
commit | 5333f31fc7555f0a39246d4fcafa71debf71abe2 (patch) | |
tree | 80521386c4821015d2dad22f5e39adb64a78b52a /bitbake/lib/bb/runqueue.py | |
parent | be564f82ca9e94965fcf27fe5f96522824ae16fd (diff) | |
download | poky-5333f31fc7555f0a39246d4fcafa71debf71abe2.tar.gz |
bitbake: runqueue: Abstract hash verification function
Pull the common pieces of the hash verification code into a single function
and reduce code duplication.
(Bitbake rev: d0c39e05cef841c6f29cc6c919df6cbf271a9bda)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 103d42df2b..00c71070d2 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -1376,10 +1376,43 @@ class RunQueue: | |||
1376 | cache[tid] = iscurrent | 1376 | cache[tid] = iscurrent |
1377 | return iscurrent | 1377 | return iscurrent |
1378 | 1378 | ||
1379 | def validate_hash(self, *, sq_fn, sq_task, sq_hash, sq_hashfn, siginfo, sq_unihash, d): | 1379 | def validate_hashes(self, tocheck, data, presentcount=None, siginfo=False): |
1380 | valid = set() | ||
1381 | if self.hashvalidate: | ||
1382 | sq_hash = [] | ||
1383 | sq_hashfn = [] | ||
1384 | sq_unihash = [] | ||
1385 | sq_fn = [] | ||
1386 | sq_taskname = [] | ||
1387 | sq_task = [] | ||
1388 | for tid in tocheck: | ||
1389 | (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) | ||
1390 | |||
1391 | sq_fn.append(fn) | ||
1392 | sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn]) | ||
1393 | sq_hash.append(self.rqdata.runtaskentries[tid].hash) | ||
1394 | sq_unihash.append(self.rqdata.runtaskentries[tid].unihash) | ||
1395 | sq_taskname.append(taskname) | ||
1396 | sq_task.append(tid) | ||
1397 | |||
1398 | if presentcount is not None: | ||
1399 | data.setVar("BB_SETSCENE_STAMPCURRENT_COUNT", presentcount) | ||
1400 | |||
1401 | valid_ids = self.validate_hash(sq_fn, sq_taskname, sq_hash, sq_hashfn, siginfo, sq_unihash, data, presentcount) | ||
1402 | |||
1403 | if presentcount is not None: | ||
1404 | data.delVar("BB_SETSCENE_STAMPCURRENT_COUNT") | ||
1405 | |||
1406 | for v in valid_ids: | ||
1407 | valid.add(sq_task[v]) | ||
1408 | |||
1409 | return valid | ||
1410 | |||
1411 | def validate_hash(self, sq_fn, sq_task, sq_hash, sq_hashfn, siginfo, sq_unihash, d, presentcount): | ||
1380 | locs = {"sq_fn" : sq_fn, "sq_task" : sq_task, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, | 1412 | locs = {"sq_fn" : sq_fn, "sq_task" : sq_task, "sq_hash" : sq_hash, "sq_hashfn" : sq_hashfn, |
1381 | "sq_unihash" : sq_unihash, "siginfo" : siginfo, "d" : d} | 1413 | "sq_unihash" : sq_unihash, "siginfo" : siginfo, "d" : d} |
1382 | 1414 | ||
1415 | # Backwards compatibility | ||
1383 | hashvalidate_args = ("(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo, sq_unihash=sq_unihash)", | 1416 | hashvalidate_args = ("(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo, sq_unihash=sq_unihash)", |
1384 | "(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo)", | 1417 | "(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=siginfo)", |
1385 | "(sq_fn, sq_task, sq_hash, sq_hashfn, d)") | 1418 | "(sq_fn, sq_task, sq_hash, sq_hashfn, d)") |
@@ -1564,16 +1597,8 @@ class RunQueue: | |||
1564 | 1597 | ||
1565 | def print_diffscenetasks(self): | 1598 | def print_diffscenetasks(self): |
1566 | 1599 | ||
1567 | valid = [] | ||
1568 | sq_hash = [] | ||
1569 | sq_hashfn = [] | ||
1570 | sq_unihash = [] | ||
1571 | sq_fn = [] | ||
1572 | sq_taskname = [] | ||
1573 | sq_task = [] | ||
1574 | noexec = [] | 1600 | noexec = [] |
1575 | stamppresent = [] | 1601 | tocheck = set() |
1576 | valid_new = set() | ||
1577 | 1602 | ||
1578 | for tid in self.rqdata.runtaskentries: | 1603 | for tid in self.rqdata.runtaskentries: |
1579 | (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) | 1604 | (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) |
@@ -1583,18 +1608,9 @@ class RunQueue: | |||
1583 | noexec.append(tid) | 1608 | noexec.append(tid) |
1584 | continue | 1609 | continue |
1585 | 1610 | ||
1586 | sq_fn.append(fn) | 1611 | tocheck.add(tid) |
1587 | sq_hashfn.append(self.rqdata.dataCaches[mc].hashfn[taskfn]) | ||
1588 | sq_hash.append(self.rqdata.runtaskentries[tid].hash) | ||
1589 | sq_unihash.append(self.rqdata.runtaskentries[tid].unihash) | ||
1590 | sq_taskname.append(taskname) | ||
1591 | sq_task.append(tid) | ||
1592 | 1612 | ||
1593 | valid = self.validate_hash(sq_fn=sq_fn, sq_task=sq_taskname, sq_hash=sq_hash, sq_hashfn=sq_hashfn, | 1613 | valid_new = self.validate_hashes(tocheck, self.cooker.data, None, True) |
1594 | siginfo=True, sq_unihash=sq_unihash, d=self.cooker.data) | ||
1595 | |||
1596 | for v in valid: | ||
1597 | valid_new.add(sq_task[v]) | ||
1598 | 1614 | ||
1599 | # Tasks which are both setscene and noexec never care about dependencies | 1615 | # Tasks which are both setscene and noexec never care about dependencies |
1600 | # We therefore find tasks which are setscene and noexec and mark their | 1616 | # We therefore find tasks which are setscene and noexec and mark their |
@@ -2501,14 +2517,10 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq): | |||
2501 | rqdata.init_progress_reporter.finish() | 2517 | rqdata.init_progress_reporter.finish() |
2502 | 2518 | ||
2503 | if rq.hashvalidate: | 2519 | if rq.hashvalidate: |
2504 | sq_hash = [] | ||
2505 | sq_hashfn = [] | ||
2506 | sq_unihash = [] | ||
2507 | sq_fn = [] | ||
2508 | sq_taskname = [] | ||
2509 | sq_task = [] | ||
2510 | noexec = [] | 2520 | noexec = [] |
2511 | stamppresent = [] | 2521 | stamppresent = [] |
2522 | tocheck = set() | ||
2523 | |||
2512 | for tid in sqdata.sq_revdeps: | 2524 | for tid in sqdata.sq_revdeps: |
2513 | (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) | 2525 | (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) |
2514 | 2526 | ||
@@ -2532,23 +2544,13 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq): | |||
2532 | sqrq.sq_task_skip(tid) | 2544 | sqrq.sq_task_skip(tid) |
2533 | continue | 2545 | continue |
2534 | 2546 | ||
2535 | sq_fn.append(fn) | 2547 | tocheck.add(tid) |
2536 | sq_hashfn.append(rqdata.dataCaches[mc].hashfn[taskfn]) | ||
2537 | sq_hash.append(rqdata.runtaskentries[tid].hash) | ||
2538 | sq_unihash.append(rqdata.runtaskentries[tid].unihash) | ||
2539 | sq_taskname.append(taskname) | ||
2540 | sq_task.append(tid) | ||
2541 | |||
2542 | cooker.data.setVar("BB_SETSCENE_STAMPCURRENT_COUNT", len(stamppresent)) | ||
2543 | |||
2544 | valid = rq.validate_hash(sq_fn=sq_fn, sq_task=sq_taskname, sq_hash=sq_hash, sq_hashfn=sq_hashfn, | ||
2545 | siginfo=False, sq_unihash=sq_unihash, d=cooker.data) | ||
2546 | 2548 | ||
2547 | cooker.data.delVar("BB_SETSCENE_STAMPCURRENT_COUNT") | 2549 | valid = rq.validate_hashes(tocheck, cooker.data, len(stamppresent), False) |
2548 | 2550 | ||
2549 | valid_new = stamppresent | 2551 | valid_new = stamppresent |
2550 | for v in valid: | 2552 | for v in valid: |
2551 | valid_new.append(sq_task[v]) | 2553 | valid_new.append(v) |
2552 | 2554 | ||
2553 | for tid in sqdata.sq_revdeps: | 2555 | for tid in sqdata.sq_revdeps: |
2554 | if tid not in valid_new and tid not in noexec: | 2556 | if tid not in valid_new and tid not in noexec: |