diff options
-rwxr-xr-x | scripts/oe-depends-dot | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot index 5cec23bf0a..6c7e9d3383 100755 --- a/scripts/oe-depends-dot +++ b/scripts/oe-depends-dot | |||
@@ -47,6 +47,51 @@ class Dot(object): | |||
47 | if len(sys.argv) != 3 and len(sys.argv) < 5: | 47 | if len(sys.argv) != 3 and len(sys.argv) < 5: |
48 | print('ERROR: Not enough args, see --help for usage') | 48 | print('ERROR: Not enough args, see --help for usage') |
49 | 49 | ||
50 | @staticmethod | ||
51 | def insert_dep_chain(chain, rdeps, alldeps): | ||
52 | """ | ||
53 | insert elements to chain from rdeps, according to alldeps | ||
54 | """ | ||
55 | # chain should at least contain one element | ||
56 | if len(chain) == 0: | ||
57 | raise | ||
58 | |||
59 | inserted_elements = [] | ||
60 | for rdep in rdeps: | ||
61 | if rdep in chain: | ||
62 | continue | ||
63 | else: | ||
64 | for i in range(0, len(chain)-1): | ||
65 | if chain[i] in alldeps[rdep] and rdep in alldeps[chain[i+1]]: | ||
66 | chain.insert(i+1, rdep) | ||
67 | inserted_elements.append(rdep) | ||
68 | break | ||
69 | if chain[-1] in alldeps[rdep] and rdep not in chain: | ||
70 | chain.append(rdep) | ||
71 | inserted_elements.append(rdep) | ||
72 | return inserted_elements | ||
73 | |||
74 | @staticmethod | ||
75 | def print_dep_chains(key, rdeps, alldeps): | ||
76 | rlist = rdeps.copy() | ||
77 | chain = [] | ||
78 | removed_rdeps = [] # hold rdeps removed from rlist | ||
79 | |||
80 | chain.append(key) | ||
81 | while (len(rlist) != 0): | ||
82 | # insert chain from rlist | ||
83 | inserted_elements = Dot.insert_dep_chain(chain, rlist, alldeps) | ||
84 | if not inserted_elements: | ||
85 | if chain[-1] in rlist: | ||
86 | rlist.remove(chain[-1]) | ||
87 | removed_rdeps.append(chain[-1]) | ||
88 | chain.pop() | ||
89 | continue | ||
90 | else: | ||
91 | # insert chain from removed_rdeps | ||
92 | Dot.insert_dep_chain(chain, removed_rdeps, alldeps) | ||
93 | print(' -> '.join(list(reversed(chain)))) | ||
94 | |||
50 | def main(self): | 95 | def main(self): |
51 | #print(self.args.dotfile[0]) | 96 | #print(self.args.dotfile[0]) |
52 | # The format is {key: depends} | 97 | # The format is {key: depends} |
@@ -109,6 +154,7 @@ class Dot(object): | |||
109 | if self.args.key in v and not k in reverse_deps: | 154 | if self.args.key in v and not k in reverse_deps: |
110 | reverse_deps.append(k) | 155 | reverse_deps.append(k) |
111 | print('Because: %s' % ' '.join(reverse_deps)) | 156 | print('Because: %s' % ' '.join(reverse_deps)) |
157 | Dot.print_dep_chains(self.args.key, reverse_deps, depends) | ||
112 | 158 | ||
113 | if __name__ == "__main__": | 159 | if __name__ == "__main__": |
114 | try: | 160 | try: |