summaryrefslogtreecommitdiffstats
path: root/scripts/oe-depends-dot
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-depends-dot')
-rwxr-xr-xscripts/oe-depends-dot92
1 files changed, 76 insertions, 16 deletions
diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot
index 5cec23bf0a..d02ee455f6 100755
--- a/scripts/oe-depends-dot
+++ b/scripts/oe-depends-dot
@@ -2,18 +2,8 @@
#
# Copyright (C) 2018 Wind River Systems, Inc.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import sys
@@ -24,8 +14,8 @@ import re
class Dot(object):
def __init__(self):
parser = argparse.ArgumentParser(
- description="Analyse recipe-depends.dot generated by bitbake -g",
- epilog="Use %(prog)s --help to get help")
+ description="Analyse task-depends.dot generated by bitbake -g",
+ formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("dotfile",
help = "Specify the dotfile", nargs = 1, action='store', default='')
parser.add_argument("-k", "--key",
@@ -42,11 +32,71 @@ class Dot(object):
" For example, A->B, B->C, A->C, then A->C can be removed.",
action="store_true", default=False)
+ parser.epilog = """
+Examples:
+First generate the .dot file:
+ bitbake -g core-image-minimal
+
+To find out why a package is being built:
+ %(prog)s -k <package> -w ./task-depends.dot
+
+To find out what a package depends on:
+ %(prog)s -k <package> -d ./task-depends.dot
+
+Reduce the .dot file packages only, no tasks:
+ %(prog)s -r ./task-depends.dot
+"""
+
self.args = parser.parse_args()
if len(sys.argv) != 3 and len(sys.argv) < 5:
print('ERROR: Not enough args, see --help for usage')
+ @staticmethod
+ def insert_dep_chain(chain, rdeps, alldeps):
+ """
+ insert elements to chain from rdeps, according to alldeps
+ """
+ # chain should at least contain one element
+ if len(chain) == 0:
+ raise
+
+ inserted_elements = []
+ for rdep in rdeps:
+ if rdep in chain:
+ continue
+ else:
+ for i in range(0, len(chain)-1):
+ if chain[i] in alldeps[rdep] and rdep in alldeps[chain[i+1]]:
+ chain.insert(i+1, rdep)
+ inserted_elements.append(rdep)
+ break
+ if chain[-1] in alldeps[rdep] and rdep not in chain:
+ chain.append(rdep)
+ inserted_elements.append(rdep)
+ return inserted_elements
+
+ @staticmethod
+ def print_dep_chains(key, rdeps, alldeps):
+ rlist = rdeps.copy()
+ chain = []
+ removed_rdeps = [] # hold rdeps removed from rlist
+
+ chain.append(key)
+ while (len(rlist) != 0):
+ # insert chain from rlist
+ inserted_elements = Dot.insert_dep_chain(chain, rlist, alldeps)
+ if not inserted_elements:
+ if chain[-1] in rlist:
+ rlist.remove(chain[-1])
+ removed_rdeps.append(chain[-1])
+ chain.pop()
+ continue
+ else:
+ # insert chain from removed_rdeps
+ Dot.insert_dep_chain(chain, removed_rdeps, alldeps)
+ print(' -> '.join(list(reversed(chain))))
+
def main(self):
#print(self.args.dotfile[0])
# The format is {key: depends}
@@ -64,6 +114,10 @@ class Dot(object):
if key == "meta-world-pkgdata":
continue
dep = m.group(2)
+ key = key.split('.')[0]
+ dep = dep.split('.')[0]
+ if key == dep:
+ continue
if key in depends:
if not key in depends[key]:
depends[key].add(dep)
@@ -105,10 +159,16 @@ class Dot(object):
reverse_deps = []
if self.args.why:
- for k, v in depends.items():
- if self.args.key in v and not k in reverse_deps:
- reverse_deps.append(k)
+ key_list = [self.args.key]
+ current_key = self.args.key
+ while (len(key_list) != 0):
+ current_key = key_list.pop()
+ for k, v in depends.items():
+ if current_key in v and not k in reverse_deps:
+ reverse_deps.append(k)
+ key_list.append(k)
print('Because: %s' % ' '.join(reverse_deps))
+ Dot.print_dep_chains(self.args.key, reverse_deps, depends)
if __name__ == "__main__":
try: