summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-12 19:23:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-19 06:28:41 -0800
commitd3e182bc18ff2894f1efc8aad3d508dd432c996e (patch)
tree684a0097b15531897b4f2e6395cfaaf038d5a6b4
parent814c2b232ea5f88b5ad5031fb9d389c9c594aa01 (diff)
downloadbitbake-contrib-d3e182bc18ff2894f1efc8aad3d508dd432c996e.zip
bitbake-contrib-d3e182bc18ff2894f1efc8aad3d508dd432c996e.tar.gz
bitbake-contrib-d3e182bc18ff2894f1efc8aad3d508dd432c996e.tar.bz2
cooker: Rewrite dependency dot file generation
The package-depends.dot and pn-depends.dot files are inaccurate, missing out key dependencies such those made via the [depends] flags. As such they can be misleading to the user. They mainly exist for historical reasons, coming from a time before we had task based execution. This commit removes the two dated file formats and replaces them with a recipe-depends.dot which is a flattened version of task-depends.dot. The old format files are removed if present so that the user can't get confused about why data might not match between files. The code is also rewritten to use 'with f: f.write()' syntax as is more commonly used now. Also update the docs to match the change. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--doc/bitbake-user-manual/bitbake-user-manual-intro.xml13
-rw-r--r--lib/bb/cooker.py98
2 files changed, 49 insertions, 62 deletions
diff --git a/doc/bitbake-user-manual/bitbake-user-manual-intro.xml b/doc/bitbake-user-manual/bitbake-user-manual-intro.xml
index d602c46..daf5b35 100644
--- a/doc/bitbake-user-manual/bitbake-user-manual-intro.xml
+++ b/doc/bitbake-user-manual/bitbake-user-manual-intro.xml
@@ -666,19 +666,14 @@
</para>
<para>
- When you generate a dependency graph, BitBake writes four files
+ When you generate a dependency graph, BitBake writes three files
to the current working directory:
<itemizedlist>
- <listitem><para><emphasis><filename>package-depends.dot</filename>:</emphasis>
- Shows BitBake's knowledge of dependencies between
- runtime targets.
- </para></listitem>
- <listitem><para><emphasis><filename>pn-depends.dot</filename>:</emphasis>
- Shows dependencies between build-time targets
- (i.e. recipes).
+ <listitem><para><emphasis><filename>recipe-depends.dot</filename>:</emphasis>
+ Shows dependencies between recipes (a collapsed version of task-depends.dot).
</para></listitem>
<listitem><para><emphasis><filename>task-depends.dot</filename>:</emphasis>
- Shows dependencies between tasks.
+ Shows dependencies between tasks. This matches bitbake's internal task execution list.
</para></listitem>
<listitem><para><emphasis><filename>pn-buildlist</filename>:</emphasis>
Shows a simple list of targets that are to be built.
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index fd1c629..ce84e1c 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -947,62 +947,54 @@ class BBCooker:
depgraph = self.generateTaskDepTreeData(pkgs_to_build, task)
- # Prints a flattened form of package-depends below where subpackages of a package are merged into the main pn
- depends_file = open('pn-depends.dot', 'w' )
- buildlist_file = open('pn-buildlist', 'w' )
- print("digraph depends {", file=depends_file)
- for pn in depgraph["pn"]:
- fn = depgraph["pn"][pn]["filename"]
- version = depgraph["pn"][pn]["version"]
- print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file)
- print("%s" % pn, file=buildlist_file)
- buildlist_file.close()
+ with open('pn-buildlist', 'w') as f:
+ for pn in depgraph["pn"]:
+ f.write(pn + "\n")
logger.info("PN build list saved to 'pn-buildlist'")
- for pn in depgraph["depends"]:
- for depend in depgraph["depends"][pn]:
- print('"%s" -> "%s" [style=solid]' % (pn, depend), file=depends_file)
- for pn in depgraph["rdepends-pn"]:
- for rdepend in depgraph["rdepends-pn"][pn]:
- print('"%s" -> "%s" [style=dashed]' % (pn, rdepend), file=depends_file)
- print("}", file=depends_file)
- depends_file.close()
- logger.info("PN dependencies saved to 'pn-depends.dot'")
-
- depends_file = open('package-depends.dot', 'w' )
- print("digraph depends {", file=depends_file)
- for package in depgraph["packages"]:
- pn = depgraph["packages"][package]["pn"]
- fn = depgraph["packages"][package]["filename"]
- version = depgraph["packages"][package]["version"]
- if package == pn:
- print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file)
- else:
- print('"%s" [label="%s(%s) %s\\n%s"]' % (package, package, pn, version, fn), file=depends_file)
- for depend in depgraph["depends"][pn]:
- print('"%s" -> "%s" [style=solid]' % (package, depend), file=depends_file)
- for package in depgraph["rdepends-pkg"]:
- for rdepend in depgraph["rdepends-pkg"][package]:
- print('"%s" -> "%s" [style=dashed]' % (package, rdepend), file=depends_file)
- for package in depgraph["rrecs-pkg"]:
- for rdepend in depgraph["rrecs-pkg"][package]:
- print('"%s" -> "%s" [style=dotted]' % (package, rdepend), file=depends_file)
- print("}", file=depends_file)
- depends_file.close()
- logger.info("Package dependencies saved to 'package-depends.dot'")
-
- tdepends_file = open('task-depends.dot', 'w' )
- print("digraph depends {", file=tdepends_file)
- for task in depgraph["tdepends"]:
- (pn, taskname) = task.rsplit(".", 1)
- fn = depgraph["pn"][pn]["filename"]
- version = depgraph["pn"][pn]["version"]
- print('"%s.%s" [label="%s %s\\n%s\\n%s"]' % (pn, taskname, pn, taskname, version, fn), file=tdepends_file)
- for dep in depgraph["tdepends"][task]:
- print('"%s" -> "%s"' % (task, dep), file=tdepends_file)
- print("}", file=tdepends_file)
- tdepends_file.close()
+
+ # Remove old format output files to ensure no confusion with stale data
+ try:
+ os.unlink('pn-depends.dot')
+ except FileNotFoundError:
+ pass
+ try:
+ os.unlink('package-depends.dot')
+ except FileNotFoundError:
+ pass
+
+ with open('task-depends.dot', 'w') as f:
+ f.write("digraph depends {\n")
+ for task in depgraph["tdepends"]:
+ (pn, taskname) = task.rsplit(".", 1)
+ fn = depgraph["pn"][pn]["filename"]
+ version = depgraph["pn"][pn]["version"]
+ f.write('"%s.%s" [label="%s %s\\n%s\\n%s"]\n' % (pn, taskname, pn, taskname, version, fn))
+ for dep in depgraph["tdepends"][task]:
+ f.write('"%s" -> "%s"\n' % (task, dep))
+ f.write("}\n")
logger.info("Task dependencies saved to 'task-depends.dot'")
+ with open('recipe-depends.dot', 'w') as f:
+ f.write("digraph depends {\n")
+ pndeps = {}
+ for task in depgraph["tdepends"]:
+ (pn, taskname) = task.rsplit(".", 1)
+ if pn not in pndeps:
+ pndeps[pn] = set()
+ for dep in depgraph["tdepends"][task]:
+ (deppn, deptaskname) = dep.rsplit(".", 1)
+ pndeps[pn].add(deppn)
+ for pn in pndeps:
+ fn = depgraph["pn"][pn]["filename"]
+ version = depgraph["pn"][pn]["version"]
+ f.write('"%s" [label="%s\\n%s\\n%s"]\n' % (pn, pn, version, fn))
+ for dep in pndeps[pn]:
+ if dep == pn:
+ continue
+ f.write('"%s" -> "%s"\n' % (pn, dep))
+ f.write("}\n")
+ logger.info("Flatened recipe dependencies saved to 'recipe-depends.dot'")
+
def show_appends_with_no_recipes(self):
# Determine which bbappends haven't been applied