Parsing the include-structure of a cpp-project
-
dear gurus, i want to parse all h-files (may be also cpp-files) of my project to get out the dependency-graph. Do you have some idea how to do it? Are there any working components available? Thanks
I guess the source to do this must be available as part of doxygen, the Open Source C++ documentation generator available on Sourceforge and probably elsewhere. It obviously does a lot more than just a dependency-graph though so it might be more trouble to pull out what you need than to write it from scratch. You could look into starting out with Flex and Bison ( Windows versions of Unix Lex and Yacc also available as C++ sources ) to generate a simple parser that only processes
#include
s. On the other hand if you have VS2005 or better you could just turn on Show Includes in the Advanced options for your project and you'll get a build output window filled wiht the entire inclusion hierarchy. Makes you appreciate how fast even MS compilers really are when you see the hundreds of files that get included even in a relatively simple project. :)"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
I guess the source to do this must be available as part of doxygen, the Open Source C++ documentation generator available on Sourceforge and probably elsewhere. It obviously does a lot more than just a dependency-graph though so it might be more trouble to pull out what you need than to write it from scratch. You could look into starting out with Flex and Bison ( Windows versions of Unix Lex and Yacc also available as C++ sources ) to generate a simple parser that only processes
#include
s. On the other hand if you have VS2005 or better you could just turn on Show Includes in the Advanced options for your project and you'll get a build output window filled wiht the entire inclusion hierarchy. Makes you appreciate how fast even MS compilers really are when you see the hundreds of files that get included even in a relatively simple project. :)"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
Thanks for your points. I already work with doxygen. It's really good. Unfortunately I have only a graphical output. What I now need is a "graph-like" output-structure which I can parse by myself to automate physical-design issues Kind regards
If you're already familiar with doxygen then I'd suggest perhaps building a modified version that outputs xml to a file of your choice in parallel to its normal output. That way you can keep the existing doxygen parsing. All you need to find is the points in the code where doxygen processes
#include
s, make sure you've got a reasonable version of msxml.dll in memory and the rest is a little bit of COM, some tables of tag strings and should hopefully be straight forward. Of course if you can architect it as some sort of plugin/addon module/patch for doxygen then you can contribute it back to the community and make the world a little better for all your hard work :-D"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
If you're already familiar with doxygen then I'd suggest perhaps building a modified version that outputs xml to a file of your choice in parallel to its normal output. That way you can keep the existing doxygen parsing. All you need to find is the points in the code where doxygen processes
#include
s, make sure you've got a reasonable version of msxml.dll in memory and the rest is a little bit of COM, some tables of tag strings and should hopefully be straight forward. Of course if you can architect it as some sort of plugin/addon module/patch for doxygen then you can contribute it back to the community and make the world a little better for all your hard work :-D"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)