diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-12 19:23:09 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-19 06:28:46 -0800 |
commit | 6cfc1c83b90c9c9dd5290749aed49896327739e6 (patch) | |
tree | 30e835624224706bfd24d4a031c9c3b8d1a1fd0b /bitbake | |
parent | 701ae7d1f4d718ef9425c1f89f9f1693e4d110e7 (diff) | |
download | poky-6cfc1c83b90c9c9dd5290749aed49896327739e6.tar.gz |
bitbake: 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.
(Bitbake rev: d3e182bc18ff2894f1efc8aad3d508dd432c996e)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.xml | 13 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 98 |
2 files changed, 49 insertions, 62 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.xml b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.xml index d602c469b0..daf5b35b6a 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.xml | |||
@@ -666,19 +666,14 @@ | |||
666 | </para> | 666 | </para> |
667 | 667 | ||
668 | <para> | 668 | <para> |
669 | When you generate a dependency graph, BitBake writes four files | 669 | When you generate a dependency graph, BitBake writes three files |
670 | to the current working directory: | 670 | to the current working directory: |
671 | <itemizedlist> | 671 | <itemizedlist> |
672 | <listitem><para><emphasis><filename>package-depends.dot</filename>:</emphasis> | 672 | <listitem><para><emphasis><filename>recipe-depends.dot</filename>:</emphasis> |
673 | Shows BitBake's knowledge of dependencies between | 673 | Shows dependencies between recipes (a collapsed version of task-depends.dot). |
674 | runtime targets. | ||
675 | </para></listitem> | ||
676 | <listitem><para><emphasis><filename>pn-depends.dot</filename>:</emphasis> | ||
677 | Shows dependencies between build-time targets | ||
678 | (i.e. recipes). | ||
679 | </para></listitem> | 674 | </para></listitem> |
680 | <listitem><para><emphasis><filename>task-depends.dot</filename>:</emphasis> | 675 | <listitem><para><emphasis><filename>task-depends.dot</filename>:</emphasis> |
681 | Shows dependencies between tasks. | 676 | Shows dependencies between tasks. This matches bitbake's internal task execution list. |
682 | </para></listitem> | 677 | </para></listitem> |
683 | <listitem><para><emphasis><filename>pn-buildlist</filename>:</emphasis> | 678 | <listitem><para><emphasis><filename>pn-buildlist</filename>:</emphasis> |
684 | Shows a simple list of targets that are to be built. | 679 | Shows a simple list of targets that are to be built. |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index fd1c629188..ce84e1c745 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -947,62 +947,54 @@ class BBCooker: | |||
947 | 947 | ||
948 | depgraph = self.generateTaskDepTreeData(pkgs_to_build, task) | 948 | depgraph = self.generateTaskDepTreeData(pkgs_to_build, task) |
949 | 949 | ||
950 | # Prints a flattened form of package-depends below where subpackages of a package are merged into the main pn | 950 | with open('pn-buildlist', 'w') as f: |
951 | depends_file = open('pn-depends.dot', 'w' ) | 951 | for pn in depgraph["pn"]: |
952 | buildlist_file = open('pn-buildlist', 'w' ) | 952 | f.write(pn + "\n") |
953 | print("digraph depends {", file=depends_file) | ||
954 | for pn in depgraph["pn"]: | ||
955 | fn = depgraph["pn"][pn]["filename"] | ||
956 | version = depgraph["pn"][pn]["version"] | ||
957 | print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file) | ||
958 | print("%s" % pn, file=buildlist_file) | ||
959 | buildlist_file.close() | ||
960 | logger.info("PN build list saved to 'pn-buildlist'") | 953 | logger.info("PN build list saved to 'pn-buildlist'") |
961 | for pn in depgraph["depends"]: | 954 | |
962 | for depend in depgraph["depends"][pn]: | 955 | # Remove old format output files to ensure no confusion with stale data |
963 | print('"%s" -> "%s" [style=solid]' % (pn, depend), file=depends_file) | 956 | try: |
964 | for pn in depgraph["rdepends-pn"]: | 957 | os.unlink('pn-depends.dot') |
965 | for rdepend in depgraph["rdepends-pn"][pn]: | 958 | except FileNotFoundError: |
966 | print('"%s" -> "%s" [style=dashed]' % (pn, rdepend), file=depends_file) | 959 | pass |
967 | print("}", file=depends_file) | 960 | try: |
968 | depends_file.close() | 961 | os.unlink('package-depends.dot') |
969 | logger.info("PN dependencies saved to 'pn-depends.dot'") | 962 | except FileNotFoundError: |
970 | 963 | pass | |
971 | depends_file = open('package-depends.dot', 'w' ) | 964 | |
972 | print("digraph depends {", file=depends_file) | 965 | with open('task-depends.dot', 'w') as f: |
973 | for package in depgraph["packages"]: | 966 | f.write("digraph depends {\n") |
974 | pn = depgraph["packages"][package]["pn"] | 967 | for task in depgraph["tdepends"]: |
975 | fn = depgraph["packages"][package]["filename"] | 968 | (pn, taskname) = task.rsplit(".", 1) |
976 | version = depgraph["packages"][package]["version"] | 969 | fn = depgraph["pn"][pn]["filename"] |
977 | if package == pn: | 970 | version = depgraph["pn"][pn]["version"] |
978 | print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file) | 971 | f.write('"%s.%s" [label="%s %s\\n%s\\n%s"]\n' % (pn, taskname, pn, taskname, version, fn)) |
979 | else: | 972 | for dep in depgraph["tdepends"][task]: |
980 | print('"%s" [label="%s(%s) %s\\n%s"]' % (package, package, pn, version, fn), file=depends_file) | 973 | f.write('"%s" -> "%s"\n' % (task, dep)) |
981 | for depend in depgraph["depends"][pn]: | 974 | f.write("}\n") |
982 | print('"%s" -> "%s" [style=solid]' % (package, depend), file=depends_file) | ||
983 | for package in depgraph["rdepends-pkg"]: | ||
984 | for rdepend in depgraph["rdepends-pkg"][package]: | ||
985 | print('"%s" -> "%s" [style=dashed]' % (package, rdepend), file=depends_file) | ||
986 | for package in depgraph["rrecs-pkg"]: | ||
987 | for rdepend in depgraph["rrecs-pkg"][package]: | ||
988 | print('"%s" -> "%s" [style=dotted]' % (package, rdepend), file=depends_file) | ||
989 | print("}", file=depends_file) | ||
990 | depends_file.close() | ||
991 | logger.info("Package dependencies saved to 'package-depends.dot'") | ||
992 | |||
993 | tdepends_file = open('task-depends.dot', 'w' ) | ||
994 | print("digraph depends {", file=tdepends_file) | ||
995 | for task in depgraph["tdepends"]: | ||
996 | (pn, taskname) = task.rsplit(".", 1) | ||
997 | fn = depgraph["pn"][pn]["filename"] | ||
998 | version = depgraph["pn"][pn]["version"] | ||
999 | print('"%s.%s" [label="%s %s\\n%s\\n%s"]' % (pn, taskname, pn, taskname, version, fn), file=tdepends_file) | ||
1000 | for dep in depgraph["tdepends"][task]: | ||
1001 | print('"%s" -> "%s"' % (task, dep), file=tdepends_file) | ||
1002 | print("}", file=tdepends_file) | ||
1003 | tdepends_file.close() | ||
1004 | logger.info("Task dependencies saved to 'task-depends.dot'") | 975 | logger.info("Task dependencies saved to 'task-depends.dot'") |
1005 | 976 | ||
977 | with open('recipe-depends.dot', 'w') as f: | ||
978 | f.write("digraph depends {\n") | ||
979 | pndeps = {} | ||
980 | for task in depgraph["tdepends"]: | ||
981 | (pn, taskname) = task.rsplit(".", 1) | ||
982 | if pn not in pndeps: | ||
983 | pndeps[pn] = set() | ||
984 | for dep in depgraph["tdepends"][task]: | ||
985 | (deppn, deptaskname) = dep.rsplit(".", 1) | ||
986 | pndeps[pn].add(deppn) | ||
987 | for pn in pndeps: | ||
988 | fn = depgraph["pn"][pn]["filename"] | ||
989 | version = depgraph["pn"][pn]["version"] | ||
990 | f.write('"%s" [label="%s\\n%s\\n%s"]\n' % (pn, pn, version, fn)) | ||
991 | for dep in pndeps[pn]: | ||
992 | if dep == pn: | ||
993 | continue | ||
994 | f.write('"%s" -> "%s"\n' % (pn, dep)) | ||
995 | f.write("}\n") | ||
996 | logger.info("Flatened recipe dependencies saved to 'recipe-depends.dot'") | ||
997 | |||
1006 | def show_appends_with_no_recipes(self): | 998 | def show_appends_with_no_recipes(self): |
1007 | # Determine which bbappends haven't been applied | 999 | # Determine which bbappends haven't been applied |
1008 | 1000 | ||