[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Diagramming a makefile?
From: |
Reinier Post |
Subject: |
Re: Diagramming a makefile? |
Date: |
Tue, 15 Apr 2014 18:37:01 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Op di 15 apr 2014 04:00:16 GMT schreef address@hidden (Rakesh Sharma):
>
> Hello Reinier,
>
> Thanks for the pointers regarding the MAKAO utiliity as well as
> your local solution to handle the make -p output.
>
> Appears that MAKAO is a full-fledged attempt at generating the DAGs
> for a makefile. But for running your perl code we need the graphviz
> utility also to be able to generate DAGs.
http://www.win.tue.nl/~rp/bin/make2csv # generates the CSV file
http://www.win.tue.nl/~rp/bin/csvtrans # filters the CSV file
http://www.win.tue.nl/~rp/bin/csv2dot # creates the GraphViz file
They require the CPAN module Text::CSV_XS.
Example of use:
cd /tmp
wget http://ftp.gnu.org/gnu/make/make-4.0.tar.gz
tar xvf make-4.0.tar.gz
cd make-4.0/
./configure
make -prR | make2csv | sort -u > make-prR.csv
export DOT_A4='-Nshape=record -Ncolor=blue4 -Gnodesep=.15 -Gsize='7,10'
-Gratio=1 -Gcenter=1 -Grankdir=LR -Ecolor=green4 -Efontcolor=green4'
csv2dot -b make-prR.csv | dot $DOT_A4 -Tpdf > make-prR.pdf
To my surprise, dot doesn't choke on this graph.
But I usually filter the graph before feeding it to dot.
That is what csvtrans is for, e.g.
csvtrans -o rmarcs make-prR.csv | wc # count the nodes (976)
csvtrans -o 'io>0' make-prR.csv | wc # count the arcs (1364)
csvtrans -o 'out>0' make-prR.csv | dot $DOT_A4 -Tpdf > make-prR-w-deps.pdf
# omit all nodes without dependencies or recipes
MAKAO assumes you want to feed your graphs to Gephi (which can also
read this format) and do your filtering within Gephi, which is probably
a saner option: csvtrans is not so easy to use and it may contain bugs.
The same is true for make2csv; it's a quick hack and you may need
to modify it before it does exactly what you want.
make2csv's analysis is static: it just lists rules found in the input.
It doesn't expand variables and it doesn't do any inferencing.
MAKAO's analysis is dynamic: it instruments a run of make and produces
the rule invocations executed. Which means variables are expanded,
inferences followed, unused targets and rules omitted.
So the resulting graphs will usually be very different, especially
when variables, implicit rules, include, eval, etc. are used.
> Regards,
>
> Rakesh
--
Reinier Post
http://www.win.tue.nl/~rp/