graph-depends: add option to set the colours
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 8 Jun 2014 14:03:49 +0000 (16:03 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 8 Jun 2014 14:43:17 +0000 (16:43 +0200)
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Francois Perrad <fperrad@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/scripts/graph-depends

index 2b460400099e67791b6f35791d99793784f9fe2e..0dafd77389f9873dd84c95480dbef8d33400be18 100755 (executable)
@@ -42,6 +42,12 @@ parser.add_argument("--package", '-p', metavar="PACKAGE",
                     help="Graph the dependencies of PACKAGE")
 parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, default=0,
                     help="Limit the dependency graph to DEPTH levels; 0 means no limit.")
+parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
+                    default="lightblue,grey,gainsboro",
+                    help="Comma-separated list of the three colours to use" \
+                       + " to draw the top-level package, the target" \
+                       + " packages, and the host packages, in this order." \
+                       + " Defaults to: 'lightblue,grey,gainsboro'")
 parser.add_argument("--transitive", dest="transitive", action='store_true',
                     default=True)
 parser.add_argument("--no-transitive", dest="transitive", action='store_false',
@@ -58,6 +64,17 @@ max_depth = args.depth
 
 transitive = args.transitive
 
+# Get the colours: we need exactly three colours,
+# so no need not split more than 4
+# We'll let 'dot' validate the colours...
+colours = args.colours.split(',',4)
+if len(colours) != 3:
+    sys.stderr.write("Error: incorrect colour list '%s'\n" % args.colours)
+    sys.exit(1)
+root_colour = colours[0]
+target_colour = colours[1]
+host_colour = colours[2]
+
 allpkgs = []
 
 # Execute the "make show-targets" command to get the list of the main
@@ -250,14 +267,14 @@ def print_attrs(pkg):
     else:
         label = pkg
     if pkg == 'all' or (mode == PKG_MODE and pkg == rootpkg):
-        color = 'lightblue'
+        color = root_colour
     else:
         if pkg.startswith('host') \
         or pkg.startswith('toolchain') \
         or pkg.startswith('rootfs'):
-            color = 'gainsboro'
+            color = host_colour
         else:
-            color = 'grey'
+            color = target_colour
     print "%s [label = \"%s\"]" % (name, label)
     print "%s [color=%s,style=filled]" % (name, color)