support/graph-depends: use argparse to parse argv[]
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> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
22d05901c3
commit
3d37950ec1
|
@ -495,7 +495,7 @@ $(1)-show-depends:
|
||||||
$(1)-graph-depends:
|
$(1)-graph-depends:
|
||||||
@$(INSTALL) -d $(O)/graphs
|
@$(INSTALL) -d $(O)/graphs
|
||||||
@cd "$(CONFIG_DIR)"; \
|
@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)
|
|dot -T$(BR_GRAPH_OUT) -o $(O)/graphs/$$(@).$(BR_GRAPH_OUT)
|
||||||
|
|
||||||
$(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
|
$(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# Usage (the graphviz package must be installed in your distribution)
|
# 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
|
# dot -Tpdf test.dot -o test.pdf
|
||||||
#
|
#
|
||||||
# With no arguments, graph-depends will draw a complete graph of
|
# With no arguments, graph-depends will draw a complete graph of
|
||||||
# dependencies for the current configuration. With an argument,
|
# dependencies for the current configuration.
|
||||||
# graph-depends will draw a graph of dependencies for the given
|
# If '-p <package-name>' is specified, graph-depends will draw a graph
|
||||||
# package name.
|
# of dependencies for the given package name.
|
||||||
#
|
#
|
||||||
# Limitations
|
# Limitations
|
||||||
#
|
#
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
|
||||||
# In FULL_MODE, we draw the full dependency graph for all selected
|
# In FULL_MODE, we draw the full dependency graph for all selected
|
||||||
# packages
|
# packages
|
||||||
|
@ -31,14 +32,16 @@ PKG_MODE = 2
|
||||||
|
|
||||||
mode = 0
|
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
|
mode = FULL_MODE
|
||||||
elif len(sys.argv) == 2:
|
|
||||||
mode = PKG_MODE
|
|
||||||
rootpkg = sys.argv[1]
|
|
||||||
else:
|
else:
|
||||||
print "Usage: graph-depends [package-name]"
|
mode = PKG_MODE
|
||||||
sys.exit(1)
|
rootpkg = args.package
|
||||||
|
|
||||||
allpkgs = []
|
allpkgs = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue