diff mbox series

oe-depends-dot: improve '-w' behavior

Message ID 20230830082158.1618931-1-Qi.Chen@windriver.com
State New
Headers show
Series oe-depends-dot: improve '-w' behavior | expand

Commit Message

ChenQi Aug. 30, 2023, 8:21 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

The '-w' option is not giving very helpful information. For example,
if we add 'spice' to IMAGE_INSTALL, bitbake -g core-image-minimal,
and then run `oe-depends-dot -k nspr -w task-depends.dot', the result is:

  $ oe-depends-dot -k nspr -w task-depends.dot
  Because: core-image-minimal nss
  core-image-minimal -> nss -> nspr

The result is not showing the full dependency chain which brings in nspr.
With this patch, the result is:

  $ oe-depends-dot -k nspr -w task-depends.dot
  Because: core-image-minimal nss libcacard spice
  core-image-minimal -> spice -> libcacard -> nss -> nspr

This patch also fixes a typo in help message: recipe-depends.dot -> task-depends.dot.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/oe-depends-dot | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot
index 1c2d51c6ec..d02ee455f6 100755
--- a/scripts/oe-depends-dot
+++ b/scripts/oe-depends-dot
@@ -14,7 +14,7 @@  import re
 class Dot(object):
     def __init__(self):
         parser = argparse.ArgumentParser(
-            description="Analyse recipe-depends.dot generated by bitbake -g",
+            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='')
@@ -159,9 +159,14 @@  Reduce the .dot file packages only, no tasks:
 
         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)