Remove duplicate nodes
This commit is contained in:
+23
-9
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
"""graphdeps V0.06
|
"""graphdeps V0.07
|
||||||
Copyright (c) 2011 Michael P. Hayes, UC ECE, NZ
|
Copyright (c) 2011 Michael P. Hayes, UC ECE, NZ
|
||||||
|
|
||||||
Usage: graphdeps Makefile
|
Usage: graphdeps Makefile
|
||||||
@@ -41,6 +41,12 @@ def parse_rules (filename):
|
|||||||
|
|
||||||
def node_output (dotfile, name, options):
|
def node_output (dotfile, name, options):
|
||||||
|
|
||||||
|
if options.debug:
|
||||||
|
print >> sys.stderr, 'Node', name
|
||||||
|
|
||||||
|
if not options.fullpaths:
|
||||||
|
name = os.path.basename (name)
|
||||||
|
|
||||||
# Should check if creating a duplicate although graphviz will
|
# Should check if creating a duplicate although graphviz will
|
||||||
# weed them out.
|
# weed them out.
|
||||||
|
|
||||||
@@ -85,11 +91,8 @@ def edge_output (dotfile, target, dep, indirect):
|
|||||||
|
|
||||||
def dep_output (dotfile, target, dep, modules, options):
|
def dep_output (dotfile, target, dep, modules, options):
|
||||||
|
|
||||||
if not options.fullpaths:
|
if options.debug:
|
||||||
target = os.path.basename (target)
|
print >> sys.stderr, target, '::', dep
|
||||||
dep = os.path.basename (dep)
|
|
||||||
|
|
||||||
target = node_output (dotfile, target, options)
|
|
||||||
|
|
||||||
if dep == '':
|
if dep == '':
|
||||||
return
|
return
|
||||||
@@ -98,7 +101,7 @@ def dep_output (dotfile, target, dep, modules, options):
|
|||||||
if indirect:
|
if indirect:
|
||||||
dep = dep[1:]
|
dep = dep[1:]
|
||||||
|
|
||||||
dep = node_output (dotfile, dep, options)
|
# dep = node_output (dotfile, dep, options)
|
||||||
|
|
||||||
(file, ext) = os.path.splitext (target)
|
(file, ext) = os.path.splitext (target)
|
||||||
|
|
||||||
@@ -126,15 +129,22 @@ def target_output (dotfile, target, targets, modules, options, seen = {}):
|
|||||||
|
|
||||||
if not target or seen.has_key (target):
|
if not target or seen.has_key (target):
|
||||||
return
|
return
|
||||||
|
|
||||||
deps = targets[target]
|
deps = targets[target]
|
||||||
|
|
||||||
|
if options.debug:
|
||||||
|
print >> sys.stderr, target, ':', deps
|
||||||
|
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
if targets.has_key (dep) and target != dep:
|
if targets.has_key (dep) and target != dep:
|
||||||
target_output (dotfile, dep, targets, modules, options, seen)
|
target_output (dotfile, dep, targets, modules, options, seen)
|
||||||
|
|
||||||
|
target1 = node_output (dotfile, target, options)
|
||||||
|
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
dep_output (dotfile, target, dep, modules, options)
|
if dep != '':
|
||||||
|
dep_output (dotfile, target1, dep, modules, options)
|
||||||
|
|
||||||
|
seen[target] = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -159,6 +169,10 @@ def main(argv = None):
|
|||||||
dest = 'calls', default = False,
|
dest = 'calls', default = False,
|
||||||
help = 'show callgraph')
|
help = 'show callgraph')
|
||||||
|
|
||||||
|
parser.add_option('--debug', action = 'store_true',
|
||||||
|
dest = 'debug', default = False,
|
||||||
|
help = 'enable debugging')
|
||||||
|
|
||||||
parser.add_option('--fullpaths', action = 'store_true',
|
parser.add_option('--fullpaths', action = 'store_true',
|
||||||
dest = 'fullpaths', default = False,
|
dest = 'fullpaths', default = False,
|
||||||
help = 'show full paths')
|
help = 'show full paths')
|
||||||
|
|||||||
Reference in New Issue
Block a user