I wanted to be able to write out a dot image with a given file name, so I could generate CFG images for certain functions during the course of a 'make'.
I came up with the appended.
Tom
diff --git a/gccutils.py b/gccutils.py index fa21012..bb891b1 100644 --- a/gccutils.py +++ b/gccutils.py @@ -37,7 +37,7 @@ def get_variables_as_dict(): result[var.decl.name] = var return result
-def invoke_dot(dot): +def write_dot_image(dot, basename): from subprocess import Popen, PIPE
if 1: @@ -53,10 +53,12 @@ def invoke_dot(dot): # Presumably a font selection/font metrics issue fmt = 'svg'
- p = Popen(['dot', '-T%s' % fmt, '-o', 'test.%s' % fmt], + p = Popen(['dot', '-T%s' % fmt, '-o', '%s.%s' % (basename, fmt)], stdin=PIPE) p.communicate(dot.encode('ascii'))
+def invoke_dot(dot): + write_dot_image(dot, 'test') p = Popen(['xdg-open', 'test.%s' % fmt]) p.communicate()
gcc-python-plugin@lists.stg.fedorahosted.org