summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/siggen.py72
-rw-r--r--bitbake/lib/bb/tests/siggen.py77
2 files changed, 31 insertions, 118 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index c4ff9d8de1..d0a555654b 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -182,6 +182,11 @@ class SignatureGenerator(object):
182 def exit(self): 182 def exit(self):
183 return 183 return
184 184
185def build_pnid(mc, pn, taskname):
186 if mc:
187 return "mc:" + mc + ":" + pn + ":" + taskname
188 return pn + ":" + taskname
189
185class SignatureGeneratorBasic(SignatureGenerator): 190class SignatureGeneratorBasic(SignatureGenerator):
186 """ 191 """
187 """ 192 """
@@ -309,15 +314,19 @@ class SignatureGeneratorBasic(SignatureGenerator):
309 recipename = dataCaches[mc].pkg_fn[mcfn] 314 recipename = dataCaches[mc].pkg_fn[mcfn]
310 315
311 self.tidtopn[tid] = recipename 316 self.tidtopn[tid] = recipename
317 # save hashfn for deps into siginfo?
318 for dep in deps:
319 (depmc, _, deptask, depmcfn) = bb.runqueue.split_tid_mcfn(dep)
320 dep_pn = dataCaches[depmc].pkg_fn[depmcfn]
312 321
313 for dep in sorted(deps, key=clean_basepath): 322 if not self.rundep_check(mcfn, recipename, task, dep, dep_pn, dataCaches):
314 (depmc, _, _, depmcfn) = bb.runqueue.split_tid_mcfn(dep)
315 depname = dataCaches[depmc].pkg_fn[depmcfn]
316 if not self.rundep_check(mcfn, recipename, task, dep, depname, dataCaches):
317 continue 323 continue
324
318 if dep not in self.taskhash: 325 if dep not in self.taskhash:
319 bb.fatal("%s is not in taskhash, caller isn't calling in dependency order?" % dep) 326 bb.fatal("%s is not in taskhash, caller isn't calling in dependency order?" % dep)
320 self.runtaskdeps[tid].append(dep) 327
328 dep_pnid = build_pnid(depmc, dep_pn, deptask)
329 self.runtaskdeps[tid].append((dep_pnid, dep))
321 330
322 if task in dataCaches[mc].file_checksums[mcfn]: 331 if task in dataCaches[mc].file_checksums[mcfn]:
323 if self.checksum_cache: 332 if self.checksum_cache:
@@ -348,8 +357,8 @@ class SignatureGeneratorBasic(SignatureGenerator):
348 def get_taskhash(self, tid, deps, dataCaches): 357 def get_taskhash(self, tid, deps, dataCaches):
349 358
350 data = self.basehash[tid] 359 data = self.basehash[tid]
351 for dep in self.runtaskdeps[tid]: 360 for dep in sorted(self.runtaskdeps[tid]):
352 data += self.get_unihash(dep) 361 data += self.get_unihash(dep[1])
353 362
354 for (f, cs) in self.file_checksum_values[tid]: 363 for (f, cs) in self.file_checksum_values[tid]:
355 if cs: 364 if cs:
@@ -414,7 +423,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
414 data['varvals'][dep] = self.datacaches[mc].siggen_varvals[mcfn][dep] 423 data['varvals'][dep] = self.datacaches[mc].siggen_varvals[mcfn][dep]
415 424
416 if runtime and tid in self.taskhash: 425 if runtime and tid in self.taskhash:
417 data['runtaskdeps'] = self.runtaskdeps[tid] 426 data['runtaskdeps'] = [dep[0] for dep in sorted(self.runtaskdeps[tid])]
418 data['file_checksum_values'] = [] 427 data['file_checksum_values'] = []
419 for f,cs in self.file_checksum_values[tid]: 428 for f,cs in self.file_checksum_values[tid]:
420 if "/./" in f: 429 if "/./" in f:
@@ -422,8 +431,8 @@ class SignatureGeneratorBasic(SignatureGenerator):
422 else: 431 else:
423 data['file_checksum_values'].append((os.path.basename(f), cs)) 432 data['file_checksum_values'].append((os.path.basename(f), cs))
424 data['runtaskhashes'] = {} 433 data['runtaskhashes'] = {}
425 for dep in data['runtaskdeps']: 434 for dep in self.runtaskdeps[tid]:
426 data['runtaskhashes'][dep] = self.get_unihash(dep) 435 data['runtaskhashes'][dep[0]] = self.get_unihash(dep[1])
427 data['taskhash'] = self.taskhash[tid] 436 data['taskhash'] = self.taskhash[tid]
428 data['unihash'] = self.get_unihash(tid) 437 data['unihash'] = self.get_unihash(tid)
429 438
@@ -793,39 +802,6 @@ def list_inline_diff(oldlist, newlist, colors=None):
793 ret.append(item) 802 ret.append(item)
794 return '[%s]' % (', '.join(ret)) 803 return '[%s]' % (', '.join(ret))
795 804
796def clean_basepath(basepath):
797 basepath, dir, recipe_task = basepath.rsplit("/", 2)
798 cleaned = dir + '/' + recipe_task
799
800 if basepath[0] == '/':
801 return cleaned
802
803 if basepath.startswith("mc:") and basepath.count(':') >= 2:
804 mc, mc_name, basepath = basepath.split(":", 2)
805 mc_suffix = ':mc:' + mc_name
806 else:
807 mc_suffix = ''
808
809 # mc stuff now removed from basepath. Whatever was next, if present will be the first
810 # suffix. ':/', recipe path start, marks the end of this. Something like
811 # 'virtual:a[:b[:c]]:/path...' (b and c being optional)
812 if basepath[0] != '/':
813 cleaned += ':' + basepath.split(':/', 1)[0]
814
815 return cleaned + mc_suffix
816
817def clean_basepaths(a):
818 b = {}
819 for x in a:
820 b[clean_basepath(x)] = a[x]
821 return b
822
823def clean_basepaths_list(a):
824 b = []
825 for x in a:
826 b.append(clean_basepath(x))
827 return b
828
829# Handled renamed fields 805# Handled renamed fields
830def handle_renames(data): 806def handle_renames(data):
831 if 'basewhitelist' in data: 807 if 'basewhitelist' in data:
@@ -994,11 +970,11 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
994 a = a_data['runtaskdeps'][idx] 970 a = a_data['runtaskdeps'][idx]
995 b = b_data['runtaskdeps'][idx] 971 b = b_data['runtaskdeps'][idx]
996 if a_data['runtaskhashes'][a] != b_data['runtaskhashes'][b] and not collapsed: 972 if a_data['runtaskhashes'][a] != b_data['runtaskhashes'][b] and not collapsed:
997 changed.append("%s with hash %s\n changed to\n%s with hash %s" % (clean_basepath(a), a_data['runtaskhashes'][a], clean_basepath(b), b_data['runtaskhashes'][b])) 973 changed.append("%s with hash %s\n changed to\n%s with hash %s" % (a, a_data['runtaskhashes'][a], b, b_data['runtaskhashes'][b]))
998 974
999 if changed: 975 if changed:
1000 clean_a = clean_basepaths_list(a_data['runtaskdeps']) 976 clean_a = a_data['runtaskdeps']
1001 clean_b = clean_basepaths_list(b_data['runtaskdeps']) 977 clean_b = b_data['runtaskdeps']
1002 if clean_a != clean_b: 978 if clean_a != clean_b:
1003 output.append(color_format("{color_title}runtaskdeps changed:{color_default}\n%s") % list_inline_diff(clean_a, clean_b, colors)) 979 output.append(color_format("{color_title}runtaskdeps changed:{color_default}\n%s") % list_inline_diff(clean_a, clean_b, colors))
1004 else: 980 else:
@@ -1007,8 +983,8 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
1007 983
1008 984
1009 if 'runtaskhashes' in a_data and 'runtaskhashes' in b_data: 985 if 'runtaskhashes' in a_data and 'runtaskhashes' in b_data:
1010 a = clean_basepaths(a_data['runtaskhashes']) 986 a = a_data['runtaskhashes']
1011 b = clean_basepaths(b_data['runtaskhashes']) 987 b = b_data['runtaskhashes']
1012 changed, added, removed = dict_diff(a, b) 988 changed, added, removed = dict_diff(a, b)
1013 if added: 989 if added:
1014 for dep in sorted(added): 990 for dep in sorted(added):
diff --git a/bitbake/lib/bb/tests/siggen.py b/bitbake/lib/bb/tests/siggen.py
index c21ab4e4fb..0dc67e6cc2 100644
--- a/bitbake/lib/bb/tests/siggen.py
+++ b/bitbake/lib/bb/tests/siggen.py
@@ -17,75 +17,12 @@ import bb.siggen
17 17
18class SiggenTest(unittest.TestCase): 18class SiggenTest(unittest.TestCase):
19 19
20 def test_clean_basepath_simple_target_basepath(self): 20 def test_build_pnid(self):
21 basepath = '/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' 21 tests = {
22 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask' 22 ('', 'helloworld', 'do_sometask') : 'helloworld:do_sometask',
23 ('XX', 'helloworld', 'do_sometask') : 'mc:XX:helloworld:do_sometask',
24 }
23 25
24 actual_cleaned = bb.siggen.clean_basepath(basepath) 26 for t in tests:
27 self.assertEqual(bb.siggen.build_pnid(*t), tests[t])
25 28
26 self.assertEqual(actual_cleaned, expected_cleaned)
27
28 def test_clean_basepath_basic_virtual_basepath(self):
29 basepath = 'virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
30 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something'
31
32 actual_cleaned = bb.siggen.clean_basepath(basepath)
33
34 self.assertEqual(actual_cleaned, expected_cleaned)
35
36 def test_clean_basepath_mc_basepath(self):
37 basepath = 'mc:somemachine:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
38 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:mc:somemachine'
39
40 actual_cleaned = bb.siggen.clean_basepath(basepath)
41
42 self.assertEqual(actual_cleaned, expected_cleaned)
43
44 def test_clean_basepath_virtual_long_prefix_basepath(self):
45 basepath = 'virtual:something:A:B:C:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
46 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:A:B:C'
47
48 actual_cleaned = bb.siggen.clean_basepath(basepath)
49
50 self.assertEqual(actual_cleaned, expected_cleaned)
51
52 def test_clean_basepath_mc_virtual_basepath(self):
53 basepath = 'mc:somemachine:virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
54 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:mc:somemachine'
55
56 actual_cleaned = bb.siggen.clean_basepath(basepath)
57
58 self.assertEqual(actual_cleaned, expected_cleaned)
59
60 def test_clean_basepath_mc_virtual_long_prefix_basepath(self):
61 basepath = 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
62 expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:C:B:A:mc:X'
63
64 actual_cleaned = bb.siggen.clean_basepath(basepath)
65
66 self.assertEqual(actual_cleaned, expected_cleaned)
67
68
69 # def test_clean_basepath_performance(self):
70 # input_basepaths = [
71 # 'mc:X:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
72 # 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
73 # 'virtual:something:C:B:A:/different/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
74 # 'virtual:something:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
75 # '/this/is/most/common/input/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
76 # '/and/should/be/tested/with/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
77 # '/more/weight/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
78 # ]
79
80 # time_start = time.time()
81
82 # i = 2000000
83 # while i >= 0:
84 # for basepath in input_basepaths:
85 # bb.siggen.clean_basepath(basepath)
86 # i -= 1
87
88 # elapsed = time.time() - time_start
89 # print('{} ({}s)'.format(self.id(), round(elapsed, 3)))
90
91 # self.assertTrue(False)