diff --git a/etc/graphdeps.py b/etc/graphdeps.py index 19747ae..b9d4c7d 100755 --- a/etc/graphdeps.py +++ b/etc/graphdeps.py @@ -1,5 +1,5 @@ #!/usr/bin/python -"""graphdeps V0.05 +"""graphdeps V0.06 Copyright (c) 2011 Michael P. Hayes, UC ECE, NZ Usage: graphdeps Makefile @@ -74,10 +74,13 @@ def op_output (dotfile, op, name): dotfile.write ('\t"' + op + '"\t[shape=rectangle,label="' + name + '"];\n') -def edge_output (dotfile, target, dep): +def edge_output (dotfile, target, dep, indirect): # dotfile.write ('\t"' + target + '" ->\t"' + dep + '"\t[dir=back];\n') - dotfile.write ('\t"' + target + '" ->\t"' + dep + '";\n') + if indirect: + dotfile.write ('\t"' + target + '" ->\t"' + dep + '"\t[style="dashed"];\n') + else: + dotfile.write ('\t"' + target + '" ->\t"' + dep + '";\n') def dep_output (dotfile, target, dep, modules, options): @@ -91,12 +94,16 @@ def dep_output (dotfile, target, dep, modules, options): if dep == '': return + indirect = (dep[0] == '@') + if indirect: + dep = dep[1:] + dep = node_output (dotfile, dep, options) (file, ext) = os.path.splitext (target) if not options.showops: - edge_output (dotfile, target, dep) + edge_output (dotfile, target, dep, indirect) else: if ext == '.o': op = 'Compiler' @@ -108,11 +115,11 @@ def dep_output (dotfile, target, dep, modules, options): op = '' if op == '': - edge_output (dotfile, target, dep) + edge_output (dotfile, target, dep, indirect) else: op_output (dotfile, op + target, op) - edge_output (dotfile, target, op + target) - edge_output (dotfile, op + target, dep) + edge_output (dotfile, target, op + target, indirect) + edge_output (dotfile, op + target, dep, indirect) def target_output (dotfile, target, targets, modules, options, seen = {}): diff --git a/etc/makemake.py b/etc/makemake.py index 4bd39fe..f7c14b8 100755 --- a/etc/makemake.py +++ b/etc/makemake.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""makemake V0.05 +"""makemake V0.06 Copyright (c) 2010 Michael P. Hayes, UC ECE, NZ This program tries to make a Makefile from a template. Given a C file @@ -267,7 +267,7 @@ def functions_find (gcc, filepath, functiondeps = {}): matches = re.findall (r'.*gimple_assign > sys.stderr, command @@ -344,7 +344,7 @@ def deps_print (target, depsdir, options, record = {}): deps = depsdir[target] - print >> sys.stderr, target + ': ', deps + # print >> sys.stderr, target + ': ', deps deps = [dep for dep in deps if os.path.basename (dep) not in options.exclude] for dep in deps: @@ -362,6 +362,33 @@ def deps_print (target, depsdir, options, record = {}): print os.path.relpath (target) + ': ' + ' '.join (deps) + '\n' +def callgraph_print (target, depsdir, options, record = {}): + + if record.has_key (target): + return + if not depsdir.has_key (target): + return + + deps = depsdir[target] + + # print >> sys.stderr, target + ': ', deps + + deps = [dep for dep in deps if dep not in options.exclude] + for dep in deps: + # Have recursion + if target == dep: + continue + + if dep[0] == '@': + dep = dep[1:] + + deps_print (dep, depsdir, options, record) + + record[target] = True + + print os.path.relpath (target) + ': ' + ' '.join (deps) + '\n' + + class Usage (Exception): def __init__(self, msg): @@ -499,7 +526,7 @@ def main(argv = None): if options.calls: for cfile in cfilelist: functions_find (gcc, cfile, functiondeps) - deps_print ('main', functiondeps, options) + callgraph_print ('main', functiondeps, options) if options.files: deps_print (outfile, filedeps, options)