views:

204

answers:

4

Hello, I'm currently using an IDE which builds c++ projects for several platforms (win32, windows mobile, symbian etc). This IDE doesn't keep a build dependency list and simply rebuilds the entire project every time. This wastes a lot of our time, which made us consider implementing a smarter build process: cpp files will be recompiled only if they're modify dates have been updated or if headers they include (recursively) have been updated.

I found a perl script called cinclude2dot.pl, which outputs include dependencies from a project's directory. This output may be used by graphviz to create a dependency tree. The problems are: (a) this script isn't reliable (it doesn't parse "/*" comments), and (b) it runs on a single directory and our headers and sources are placed in multiple directories.

My questions: 1. Is there a similar script/batch/program that can output header dependencies more efficiently? 2. Is there anything other than modify dates and include dependencies that I should consider when coding a "smarter" build process?

Other insights will be great too! thanks!

+2  A: 

If your IDE builds your project with GCC, then you can use GCC's built-in dependency generation. It outputs rules suitable for inclusion in a standard makefile.

These are activated by passing the -M family of flags on the GCC command line. See the documentation in the GCC manual.

However, maybe it's worth considering switching to a better IDE (if that's a possibility) that can do this sort of thing for you, rather than spending your time trying to graft the functionality on to what seems like an underpowered IDE.

Nick Meyer
+1  A: 

gcc can do this using the -MM option, and you can then use those dependencies in a makefile, as explained here. Even if you don't want to use gcc to compile your actual project, you might use it to compute the dependency tree.

Martin B
A: 

I also noticed the /showIncludes option in cl.exe (i'm using VS2008 for win32 and win mobile debug builds) The "problem" is that cl.exe compiles my .cpp, where I just want it to display the #include statements. Is there any flag that causes cl.exe not to compile the code, but only display the include list?

frust99
A: 

Thanks for help your help!

I found an open source program called "fastdep". it's poorly documented, but after playing with it for a few hours, I finally got what I need.

frust99