All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/6] support/graph-depends: use argparse to parse argv[]
Date: Sun, 13 Apr 2014 22:42:38 +0200	[thread overview]
Message-ID: <6e53d567f4b2087188a43cb2602b4096972c8c20.1397421554.git.yann.morin.1998@free.fr> (raw)
In-Reply-To: <cover.1397421554.git.yann.morin.1998@free.fr>

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

Currently, we are using a crude, ad-hoc parsing of argv[].
This is a limiting factor to adding new options.

Use argparse instead, and introduce a single argument for now:
  --package, -p PACKAGE

In the (near) future, we'll be able to add more option arguments,
such as depth-limiting for big graphs.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/pkg-generic.mk        |  2 +-
 support/scripts/graph-depends | 23 +++++++++++++----------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index b3a4c17..080ee56 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -495,7 +495,7 @@ $(1)-show-depends:
 $(1)-graph-depends:
 			@$(INSTALL) -d $(O)/graphs
 			@cd "$(CONFIG_DIR)"; \
-			$(TOPDIR)/support/scripts/graph-depends $(1) \
+			$(TOPDIR)/support/scripts/graph-depends -p $(1) \
 			|dot -T$(BR_GRAPH_OUT) -o $(O)/graphs/$$(@).$(BR_GRAPH_OUT)
 
 $(1)-dirclean:		$$($(2)_TARGET_DIRCLEAN)
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index ac24086..fc3cadd 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -1,13 +1,13 @@
 #!/usr/bin/python
 
 # Usage (the graphviz package must be installed in your distribution)
-#  ./support/scripts/graph-depends [package-name] > test.dot
+#  ./support/scripts/graph-depends [-p package-name] > test.dot
 #  dot -Tpdf test.dot -o test.pdf
 #
 # With no arguments, graph-depends will draw a complete graph of
-# dependencies for the current configuration. With an argument,
-# graph-depends will draw a graph of dependencies for the given
-# package name.
+# dependencies for the current configuration.
+# If '-p <package-name>' is specified, graph-depends will draw a graph
+# of dependencies for the given package name.
 #
 # Limitations
 #
@@ -21,6 +21,7 @@
 
 import sys
 import subprocess
+import argparse
 
 # In FULL_MODE, we draw the full dependency graph for all selected
 # packages
@@ -31,14 +32,16 @@ PKG_MODE  = 2
 
 mode = 0
 
-if len(sys.argv) == 1:
+parser = argparse.ArgumentParser(description="Graph pacakges dependencies")
+parser.add_argument("--package", '-p', metavar="PACKAGE",
+                    help="Graph the dependencies of PACKAGE")
+args = parser.parse_args()
+
+if args.package == None:
     mode = FULL_MODE
-elif len(sys.argv) == 2:
-    mode = PKG_MODE
-    rootpkg  = sys.argv[1]
 else:
-    print "Usage: graph-depends [package-name]"
-    sys.exit(1)
+    mode = PKG_MODE
+    rootpkg = args.package
 
 allpkgs = []
 
-- 
1.8.3.2

  parent reply	other threads:[~2014-04-13 20:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-13 20:42 [Buildroot] [PATCH 0/6] Misc graphs enhancements (branch yem/graphs) Yann E. MORIN
2014-04-13 20:42 ` [Buildroot] [PATCH 1/6] Makefile: rename non-user-facing variable Yann E. MORIN
2014-04-14 19:18   ` Samuel Martin
2014-04-13 20:42 ` Yann E. MORIN [this message]
2014-04-14 19:20   ` [Buildroot] [PATCH 2/6] support/graph-depends: use argparse to parse argv[] Samuel Martin
2014-04-14 19:46     ` Yann E. MORIN
2014-04-13 20:42 ` [Buildroot] [PATCH 3/6] support/graph-depends: add option to limit the depth of the graph Yann E. MORIN
2014-04-14 19:29   ` Samuel Martin
2014-04-14 19:48     ` Yann E. MORIN
2014-04-13 20:42 ` [Buildroot] [PATCH 4/6] manual: document BR2_GRAPH_DEPTH Yann E. MORIN
2014-04-14 19:31   ` Samuel Martin
2014-04-13 20:42 ` [Buildroot] [PATCH 5/6] support/graph-depends: don't show toolchain dependency for all packages Yann E. MORIN
2014-04-14 19:00   ` Thomas Petazzoni
2014-04-14 19:03     ` Thomas Petazzoni
2014-04-14 19:42   ` Samuel Martin
2014-04-13 20:42 ` [Buildroot] [PATCH 6/6] graphs: make graphs with lots of packages nicer to look at Yann E. MORIN
2014-04-14 20:15 ` [Buildroot] [PATCH 0/6] Misc graphs enhancements (branch yem/graphs) Thomas Petazzoni
2014-04-14 20:22   ` Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e53d567f4b2087188a43cb2602b4096972c8c20.1397421554.git.yann.morin.1998@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.