I have a project meson based, and I am able to generate using ninja a dot file
ninja -t graph myExecutable | dot -Tpng -ograph.png
Now I would like to filter the dot file to exclude all the obj files in order to have only the library and the executable. Is it possible to filter the generated dot file?
this is an example of the output of ninja -t graph myExecutable that i need to filter
digraph ninja {
rankdir="LR"
node [fontsize=10, shape=box, height=0.25]
edge [fontsize=10]
"0x55f191f3ea60" [label="myexec"]
"0x55f191f3e9f0" [label="c_LINKER", shape=ellipse]
"0x55f191f3e9f0" -> "0x55f191f3ea60"
"0x55f191f3e6a0" -> "0x55f191f3e9f0" [arrowhead=none]
"0x55f191f3d5d0" -> "0x55f191f3e9f0" [arrowhead=none]
"0x55f191f3e6a0" [label="myexec.p/src_myexec.c.o"]
"0x55f191f3e730" -> "0x55f191f3e6a0" [label=" c_COMPILER"]
"0x55f191f3e730" [label="../src/myexec.c"]
"0x55f191f3d5d0" [label="subprojects/mylib/libmylib.so.p/libmylib.so.symbols"]
"0x55f191f3d6d0" -> "0x55f191f3d5d0" [label=" SHSYM"]
"0x55f191f3d6d0" [label="subprojects/mylib/libmylib.so"]
"0x55f191f3d220" -> "0x55f191f3d6d0" [label=" c_LINKER"]
"0x55f191f3d220" [label="subprojects/mylib/libmylib.so.p/src_library.c.o"]
"0x55f191f3d320" -> "0x55f191f3d220" [label=" c_COMPILER"]
"0x55f191f3d320" [label="../subprojects/mylib/src/library.c"]
}
~
I would like to remove all *.c *.o reference
Here is a gvpr program (part of the Graphviz system - https://www.graphviz.org/pdf/gvpr.1.pdf) that will delete all nodes with labels that end in .o or .c.
It takes your ninja output and produces a filtered input suitable as input to dot.
Note:
gvpr -c 'N{if($.label=="@(*.[co])")delete($G,$);}' ninja.gv |dot -Tpng >ninja.png
or
ninja -t graph myExecutable | gvpr -c 'N{if($.label=="@(*.[co])")delete($G,$);}' |dot -Tpng >ninja.png