From patchwork Sat Mar 31 16:35:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 893829 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40D3yd0BPWz9s1r for ; Sun, 1 Apr 2018 02:36:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 781C88881B; Sat, 31 Mar 2018 16:36:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A5aF4Gw_hfCR; Sat, 31 Mar 2018 16:36:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 12C5A887ED; Sat, 31 Mar 2018 16:36:06 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 6872E1C16D3 for ; Sat, 31 Mar 2018 16:35:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6603E8881D for ; Sat, 31 Mar 2018 16:35:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 68QMz-dsYuIE for ; Sat, 31 Mar 2018 16:35:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7A66E887E6 for ; Sat, 31 Mar 2018 16:35:55 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id CCFB12083E; Sat, 31 Mar 2018 18:35:49 +0200 (CEST) Received: from localhost (unknown [195.154.228.195]) by mail.bootlin.com (Postfix) with ESMTPSA id 9305220729; Sat, 31 Mar 2018 18:35:49 +0200 (CEST) From: Thomas Petazzoni To: Buildroot List , George Redivo Date: Sat, 31 Mar 2018 18:35:39 +0200 Message-Id: <20180331163543.6278-2-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> References: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> Subject: [Buildroot] [PATCH v2 1/5] support/scripts/graph-depends: remove global code and most global variables X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The graph-depends script had no main() function, and the main code was actually spread between the function definitions, which was a real mess. This commit moves the global code into a main() function, which allows to more easily follow the flow of the script. The argument parsing code is moved into a parse_args() function. Most of the global variables are removed, and are instead passed as argument when appropriate. This has the side-effect that the print_pkg_deps() function takes a lot of argument, but this is considered better than tons of global variables. The global variables that are removed are: max_depth, transitive, mode, root_colour, target_colour, host_colour, outfile, dict_deps, dict_version, stop_list, exclude_list, arrow_dir. The root_colour/target_colour/host_colour variables are entirely removed, and instead a single colours array is passed, and it's the function using the colors that actually uses the different entries in the array. The way the print_attrs() function determines if we're display the root node is not is changed. Instead of relying on the package name and the mode (which requires passing the root package name, and the mode), it relies on the depth: when the depth is 0, we're at the root node. Signed-off-by: Thomas Petazzoni --- support/scripts/graph-depends | 289 +++++++++++++++++++++--------------------- 1 file changed, 144 insertions(+), 145 deletions(-) diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index 85c9bf0a4f..d86d506f6f 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -31,96 +31,6 @@ import brpkgutil # Modes of operation: MODE_FULL = 1 # draw full dependency graph for all selected packages MODE_PKG = 2 # draw dependency graph for a given package -mode = 0 - -# Limit drawing the dependency graph to this depth. 0 means 'no limit'. -max_depth = 0 - -# Whether to draw the transitive dependencies -transitive = True - -parser = argparse.ArgumentParser(description="Graph packages dependencies") -parser.add_argument("--check-only", "-C", dest="check_only", action="store_true", default=False, - help="Only do the dependency checks (circular deps...)") -parser.add_argument("--outfile", "-o", metavar="OUT_FILE", dest="outfile", - help="File in which to generate the dot representation") -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("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append", - help="Do not graph past this package (can be given multiple times)." + - " Can be a package name or a glob, " + - " 'virtual' to stop on virtual packages, or " + - "'host' to stop on host packages.") -parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append", - help="Like --stop-on, but do not add PACKAGE to the graph.") -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=False) -parser.add_argument("--no-transitive", dest="transitive", action='store_false', - help="Draw (do not draw) transitive dependencies") -parser.add_argument("--direct", dest="direct", action='store_true', default=True, - help="Draw direct dependencies (the default)") -parser.add_argument("--reverse", dest="direct", action='store_false', - help="Draw reverse dependencies") -args = parser.parse_args() - -check_only = args.check_only - -if args.outfile is None: - outfile = sys.stdout -else: - if check_only: - sys.stderr.write("don't specify outfile and check-only at the same time\n") - sys.exit(1) - outfile = open(args.outfile, "w") - -if args.package is None: - mode = MODE_FULL -else: - mode = MODE_PKG - rootpkg = args.package - -max_depth = args.depth - -if args.stop_list is None: - stop_list = [] -else: - stop_list = args.stop_list - -if args.exclude_list is None: - exclude_list = [] -else: - exclude_list = args.exclude_list - -transitive = args.transitive - -if args.direct: - get_depends_func = brpkgutil.get_depends - arrow_dir = "forward" -else: - if mode == MODE_FULL: - sys.stderr.write("--reverse needs a package\n") - sys.exit(1) - get_depends_func = brpkgutil.get_rdepends - arrow_dir = "back" - -# 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 = [] @@ -145,7 +55,7 @@ def get_targets(): # 'dependencies', which contains tuples of the form (pkg1 -> # pkg2_on_which_pkg1_depends, pkg3 -> pkg4_on_which_pkg3_depends) and # the function finally returns this list. -def get_all_depends(pkgs): +def get_all_depends(pkgs, get_depends_func): dependencies = [] # Filter the packages for which we already have the dependencies @@ -175,7 +85,7 @@ def get_all_depends(pkgs): deps.add(dep) if len(deps) != 0: - newdeps = get_all_depends(deps) + newdeps = get_all_depends(deps, get_depends_func) if newdeps is not None: dependencies += newdeps @@ -193,35 +103,6 @@ TARGET_EXCEPTIONS = [ "target-post-image", ] -# In full mode, start with the result of get_targets() to get the main -# targets and then use get_all_depends() for all targets -if mode == MODE_FULL: - targets = get_targets() - dependencies = [] - allpkgs.append('all') - filtered_targets = [] - for tg in targets: - # Skip uninteresting targets - if tg in TARGET_EXCEPTIONS: - continue - dependencies.append(('all', tg)) - filtered_targets.append(tg) - deps = get_all_depends(filtered_targets) - if deps is not None: - dependencies += deps - rootpkg = 'all' - -# In pkg mode, start directly with get_all_depends() on the requested -# package -elif mode == MODE_PKG: - dependencies = get_all_depends([rootpkg]) - -# Make the dependencies a dictionnary { 'pkg':[dep1, dep2, ...] } -dict_deps = {} -for dep in dependencies: - if dep[0] not in dict_deps: - dict_deps[dep[0]] = [] - dict_deps[dep[0]].append(dep[1]) # Basic cache for the results of the is_dep() function, in order to # optimize the execution time. The cache is a dict of dict of boolean @@ -328,7 +209,7 @@ def check_circular_deps(deps): # This functions trims down the dependency list of all packages. # It applies in sequence all the dependency-elimination methods. -def remove_extra_deps(deps): +def remove_extra_deps(deps, transitive): for pkg in list(deps.keys()): if not pkg == 'all': deps[pkg] = remove_mandatory_deps(pkg, deps) @@ -338,32 +219,22 @@ def remove_extra_deps(deps): return deps -check_circular_deps(dict_deps) -if check_only: - sys.exit(0) - -dict_deps = remove_extra_deps(dict_deps) -dict_version = brpkgutil.get_version([pkg for pkg in allpkgs - if pkg != "all" and not pkg.startswith("root")]) - - # Print the attributes of a node: label and fill-color -def print_attrs(pkg): +def print_attrs(outfile, pkg, version, depth, colors): name = pkg_node_name(pkg) if pkg == 'all': label = 'ALL' else: label = pkg - if pkg == 'all' or (mode == MODE_PKG and pkg == rootpkg): - color = root_colour + if depth == 0: + color = colors[0] else: if pkg.startswith('host') \ or pkg.startswith('toolchain') \ or pkg.startswith('rootfs'): - color = host_colour + color = colors[2] else: - color = target_colour - version = dict_version.get(pkg) + color = colors[1] if version == "virtual": outfile.write("%s [label = <%s>]\n" % (name, label)) else: @@ -371,12 +242,16 @@ def print_attrs(pkg): outfile.write("%s [color=%s,style=filled]\n" % (name, color)) +done_deps = [] + + # Print the dependency graph of a package -def print_pkg_deps(depth, pkg): +def print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, + arrow_dir, depth, max_depth, pkg, colors): if pkg in done_deps: return done_deps.append(pkg) - print_attrs(pkg) + print_attrs(outfile, pkg, dict_version.get(pkg), depth, colors) if pkg not in dict_deps: return for p in stop_list: @@ -401,13 +276,137 @@ def print_pkg_deps(depth, pkg): break if add: outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) - print_pkg_deps(depth + 1, d) + print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, + arrow_dir, depth + 1, max_depth, d, colors) + + +def parse_args(): + parser = argparse.ArgumentParser(description="Graph packages dependencies") + parser.add_argument("--check-only", "-C", dest="check_only", action="store_true", default=False, + help="Only do the dependency checks (circular deps...)") + parser.add_argument("--outfile", "-o", metavar="OUT_FILE", dest="outfile", + help="File in which to generate the dot representation") + 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("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append", + help="Do not graph past this package (can be given multiple times)." + + " Can be a package name or a glob, " + + " 'virtual' to stop on virtual packages, or " + + "'host' to stop on host packages.") + parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append", + help="Like --stop-on, but do not add PACKAGE to the graph.") + 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=False) + parser.add_argument("--no-transitive", dest="transitive", action='store_false', + help="Draw (do not draw) transitive dependencies") + parser.add_argument("--direct", dest="direct", action='store_true', default=True, + help="Draw direct dependencies (the default)") + parser.add_argument("--reverse", dest="direct", action='store_false', + help="Draw reverse dependencies") + return parser.parse_args() + + +def main(): + args = parse_args() + + check_only = args.check_only + + if args.outfile is None: + outfile = sys.stdout + else: + if check_only: + sys.stderr.write("don't specify outfile and check-only at the same time\n") + sys.exit(1) + outfile = open(args.outfile, "w") + if args.package is None: + mode = MODE_FULL + else: + mode = MODE_PKG + rootpkg = args.package -# Start printing the graph data -outfile.write("digraph G {\n") + if args.stop_list is None: + stop_list = [] + else: + stop_list = args.stop_list + + if args.exclude_list is None: + exclude_list = [] + else: + exclude_list = args.exclude_list + + if args.direct: + get_depends_func = brpkgutil.get_depends + arrow_dir = "forward" + else: + if mode == MODE_FULL: + sys.stderr.write("--reverse needs a package\n") + sys.exit(1) + get_depends_func = brpkgutil.get_rdepends + arrow_dir = "back" + + # 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) + + # In full mode, start with the result of get_targets() to get the main + # targets and then use get_all_depends() for all targets + if mode == MODE_FULL: + targets = get_targets() + dependencies = [] + allpkgs.append('all') + filtered_targets = [] + for tg in targets: + # Skip uninteresting targets + if tg in TARGET_EXCEPTIONS: + continue + dependencies.append(('all', tg)) + filtered_targets.append(tg) + deps = get_all_depends(filtered_targets, get_depends_func) + if deps is not None: + dependencies += deps + rootpkg = 'all' + + # In pkg mode, start directly with get_all_depends() on the requested + # package + elif mode == MODE_PKG: + dependencies = get_all_depends([rootpkg], get_depends_func) + + # Make the dependencies a dictionnary { 'pkg':[dep1, dep2, ...] } + dict_deps = {} + for dep in dependencies: + if dep[0] not in dict_deps: + dict_deps[dep[0]] = [] + dict_deps[dep[0]].append(dep[1]) + + check_circular_deps(dict_deps) + if check_only: + sys.exit(0) + + dict_deps = remove_extra_deps(dict_deps, args.transitive) + dict_version = brpkgutil.get_version([pkg for pkg in allpkgs + if pkg != "all" and not pkg.startswith("root")]) + + # Start printing the graph data + outfile.write("digraph G {\n") + + print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, + arrow_dir, 0, args.depth, rootpkg, colours) + + outfile.write("}\n") -done_deps = [] -print_pkg_deps(0, rootpkg) -outfile.write("}\n") +if __name__ == "__main__": + sys.exit(main()) From patchwork Sat Mar 31 16:35:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 893827 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40D3yW5rkVz9s1r for ; Sun, 1 Apr 2018 02:36:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5E487895B2; Sat, 31 Mar 2018 16:35:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rws1FVYkADPL; Sat, 31 Mar 2018 16:35:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 8204C895C7; Sat, 31 Mar 2018 16:35:54 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 2FC8D1C16D3 for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2CECE8A80F for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m9qaard0FPtM for ; Sat, 31 Mar 2018 16:35:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D49B8A80C for ; Sat, 31 Mar 2018 16:35:51 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id E84CC20729; Sat, 31 Mar 2018 18:35:49 +0200 (CEST) Received: from localhost (unknown [195.154.228.195]) by mail.bootlin.com (Postfix) with ESMTPSA id C8A3C2066A; Sat, 31 Mar 2018 18:35:49 +0200 (CEST) From: Thomas Petazzoni To: Buildroot List , George Redivo Date: Sat, 31 Mar 2018 18:35:40 +0200 Message-Id: <20180331163543.6278-3-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> References: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> Subject: [Buildroot] [PATCH v2 2/5] support/scripts/graph-depends: use colors instead of colours X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The graph-depends was not very consistent in colors vs. colours: some parts were using colours, some parts were using colors. Let's settle on the US spelling, colors. This change the user-visble option --colours to --colors, but it is unlikely that a lot of users customize the colors through BR2_GRAPH_DEPS_OPTS, so this user interface change is considered reasonable. Signed-off-by: Thomas Petazzoni Reviewed-by: "Yann E. MORIN" --- docs/manual/common-usage.txt | 4 ++-- support/scripts/graph-depends | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt index a22da20188..e3d7578c85 100644 --- a/docs/manual/common-usage.txt +++ b/docs/manual/common-usage.txt @@ -224,12 +224,12 @@ The +graph-depends+ behaviour can be controlled by setting options in the * +--transitive+, +--no-transitive+, to draw (or not) the transitive dependencies. The default is to not draw transitive dependencies. -* +--colours R,T,H+, the comma-separated list of colours to draw the +* +--colors R,T,H+, the comma-separated list of colors to draw the root package (+R+), the target packages (+T+) and the host packages (+H+). Defaults to: +lightblue,grey,gainsboro+ -------------------------------- -BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colours=red,green,blue' make graph-depends +BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colors=red,green,blue' make graph-depends -------------------------------- === Graphing the build duration diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index d86d506f6f..dc265ae28c 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -297,9 +297,9 @@ def parse_args(): "'host' to stop on host packages.") parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append", help="Like --stop-on, but do not add PACKAGE to the graph.") - parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours", + parser.add_argument("--colors", "-c", metavar="COLOR_LIST", dest="colors", default="lightblue,grey,gainsboro", - help="Comma-separated list of the three colours to use" + + help="Comma-separated list of the three colors to use" + " to draw the top-level package, the target" + " packages, and the host packages, in this order." + " Defaults to: 'lightblue,grey,gainsboro'") @@ -353,12 +353,12 @@ def main(): get_depends_func = brpkgutil.get_rdepends arrow_dir = "back" - # Get the colours: we need exactly three colours, + # Get the colors: we need exactly three colors, # 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) + # We'll let 'dot' validate the colors... + colors = args.colors.split(',', 4) + if len(colors) != 3: + sys.stderr.write("Error: incorrect color list '%s'\n" % args.colors) sys.exit(1) # In full mode, start with the result of get_targets() to get the main @@ -403,7 +403,7 @@ def main(): outfile.write("digraph G {\n") print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, - arrow_dir, 0, args.depth, rootpkg, colours) + arrow_dir, 0, args.depth, rootpkg, colors) outfile.write("}\n") From patchwork Sat Mar 31 16:35:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 893828 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40D3yX4F5tz9s2R for ; Sun, 1 Apr 2018 02:36:04 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 850CB89643; Sat, 31 Mar 2018 16:36:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GQGTDOIytxvR; Sat, 31 Mar 2018 16:35:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 2F3F1895D8; Sat, 31 Mar 2018 16:35:55 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 667941C16D3 for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 63FF08A80C for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oJPnwaIuaI9h for ; Sat, 31 Mar 2018 16:35:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D32B8A76F for ; Sat, 31 Mar 2018 16:35:51 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 38815207EA; Sat, 31 Mar 2018 18:35:50 +0200 (CEST) Received: from localhost (unknown [195.154.228.195]) by mail.bootlin.com (Postfix) with ESMTPSA id 18C172066A; Sat, 31 Mar 2018 18:35:50 +0200 (CEST) From: Thomas Petazzoni To: Buildroot List , George Redivo Date: Sat, 31 Mar 2018 18:35:42 +0200 Message-Id: <20180331163543.6278-5-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> References: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> Subject: [Buildroot] [PATCH v2 4/5] support/scripts/graph-depends: add --flat-list option X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: George Redivo graph-depends currently spits out a graph in .dot format. However, as part of the upcoming introduction of -show-recursive-depends and -show-recursive-rdepends, we need graph-depends to be able to display a flat list. Signed-off-by: George Redivo [Thomas: - Rebase on top of graph-depends changes - Do not display the package name itself in the list, only its dependencies (or reverse dependencies) - Display the result on a single line, instead of one package per line, in order to match what -show-depends and -show-rdepends are doing today.] Signed-off-by: Thomas Petazzoni --- support/scripts/graph-depends | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index 3a60e478d4..a177296da2 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -248,11 +248,14 @@ done_deps = [] # Print the dependency graph of a package def print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, - arrow_dir, depth, max_depth, pkg, colors): + arrow_dir, draw_graph, depth, max_depth, pkg, colors): if pkg in done_deps: return done_deps.append(pkg) - print_attrs(outfile, pkg, dict_version.get(pkg), depth, colors) + if draw_graph: + print_attrs(outfile, pkg, dict_version.get(pkg), depth, colors) + elif depth != 0: + outfile.write("%s " % pkg) if pkg not in dict_deps: return for p in stop_list: @@ -276,9 +279,10 @@ def print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, add = False break if add: - outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) + if draw_graph: + outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, - arrow_dir, depth + 1, max_depth, d, colors) + arrow_dir, draw_graph, depth + 1, max_depth, d, colors) def parse_args(): @@ -314,6 +318,8 @@ def parse_args(): help="Draw reverse dependencies") parser.add_argument("--quiet", '-q', dest="quiet", action='store_true', help="Quiet") + parser.add_argument("--flat-list", '-f', dest="flat_list", action='store_true', default=False, + help="Do not draw graph, just print a flat list") return parser.parse_args() @@ -356,6 +362,8 @@ def main(): get_depends_func = brpkgutil.get_rdepends arrow_dir = "back" + draw_graph = not args.flat_list + # Get the colors: we need exactly three colors, # so no need not split more than 4 # We'll let 'dot' validate the colors... @@ -404,12 +412,16 @@ def main(): args.quiet) # Start printing the graph data - outfile.write("digraph G {\n") + if draw_graph: + outfile.write("digraph G {\n") print_pkg_deps(outfile, dict_deps, dict_version, stop_list, exclude_list, - arrow_dir, 0, args.depth, rootpkg, colors) + arrow_dir, draw_graph, 0, args.depth, rootpkg, colors) - outfile.write("}\n") + if draw_graph: + outfile.write("}\n") + else: + outfile.write("\n") if __name__ == "__main__": From patchwork Sat Mar 31 16:35:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 893825 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40D3yQ3zyDz9s1r for ; Sun, 1 Apr 2018 02:35:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9184588800; Sat, 31 Mar 2018 16:35:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fyA90uP00QT5; Sat, 31 Mar 2018 16:35:55 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C18B6887EA; Sat, 31 Mar 2018 16:35:55 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 792921C25DB for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7571B887E6 for ; Sat, 31 Mar 2018 16:35:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KkKHf4l6rKmk for ; Sat, 31 Mar 2018 16:35:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by fraxinus.osuosl.org (Postfix) with ESMTP id 631BD887E7 for ; Sat, 31 Mar 2018 16:35:52 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 5917820879; Sat, 31 Mar 2018 18:35:50 +0200 (CEST) Received: from localhost (unknown [195.154.228.195]) by mail.bootlin.com (Postfix) with ESMTPSA id 3A50020384; Sat, 31 Mar 2018 18:35:50 +0200 (CEST) From: Thomas Petazzoni To: Buildroot List , George Redivo Date: Sat, 31 Mar 2018 18:35:43 +0200 Message-Id: <20180331163543.6278-6-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> References: <20180331163543.6278-1-thomas.petazzoni@bootlin.com> Subject: [Buildroot] [PATCH v2 5/5] package/pkg-generic: add -show-recursive-(r)depends targets X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: George Redivo This commit adds the support for -show-recursive-depends and -show-recursive-rdepends which respectively show the list of all dependencies or reverse dependencies for a given package. The existing show-depends and show-rdepends only show the first-level dependencies, while show-recursive-depends and show-recursive-rdepends show recursively the dependencies. It is worth mentioning that while show-recursive-depends really shows all dependencies, show-recursive-rdepends is a bit limited because the reverse dependencies of host packages are not properly accounted for. But that's a limitation that already exists in show-rdepends, and that cannot easily be solved. Signed-off-by: George Redivo [Thomas: - split from the patch that was also changing graph-depends - rename show-rrdepends to show-recursive-rdepends - add show-recursive-depends - don't create GRAPHS_DIR.] Signed-off-by: Thomas Petazzoni --- Makefile | 4 ++++ package/pkg-generic.mk | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 9e2402d7d9..60a83932c8 100644 --- a/Makefile +++ b/Makefile @@ -1024,6 +1024,10 @@ help: @echo ' -build - Build up to the build step' @echo ' -show-depends - List packages on which depends' @echo ' -show-rdepends - List packages which have as a dependency' + @echo ' -show-recursive-depends' + @echo ' - Recursively list packages on which depends' + @echo ' -show-recursive-rdepends' + @echo ' - Recursively list packages which have as a dependency' @echo ' -graph-depends - Generate a graph of '\''s dependencies' @echo ' -graph-rdepends - Generate a graph of '\''s reverse dependencies' @echo ' -dirclean - Remove build directory' diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk index 6d82f7027e..24b55b9555 100644 --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -759,9 +759,17 @@ $(1)-show-version: $(1)-show-depends: @echo $$($(2)_FINAL_ALL_DEPENDENCIES) +$(1)-show-recursive-depends: + @cd "$$(CONFIG_DIR)" && \ + $$(TOPDIR)/support/scripts/graph-depends -p $(1) -f -q + $(1)-show-rdepends: @echo $$($(2)_RDEPENDENCIES) +$(1)-show-recursive-rdepends: + @cd "$$(CONFIG_DIR)" && \ + $$(TOPDIR)/support/scripts/graph-depends -p $(1) --reverse -f -q + $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES)) $$(info $(1))