How to implement dependency checking for C/C++ sources
I started adding support for a 3rd party toolchain (IAR Compiler) to Visual Studio 2005.
So far I've managed to implement the required msbuild tasks (Compile, Link and Assemble) and开发者_如何学编程 the Visual Studio Add-in to support the *.proj file.
The next hurdle is handling dependencies for the headers. I'm not sure what the best way to go about this is.
The IAR compiler provides a command line switch to get the list of header files a source depends on, but how should I provide this information to Visual Studio/MSBuild?
Add all the headers your source files uses in a given project into the 'header files' pseudo folder that you see when you expand the project node. That defines the dependency of source on headers.
It really is up to the compiler to do the header file dependency check. It's impractical to specify includes in your msbuild file. Plus some files can be included based on #defines and so on.
You would have to make the compilation target you created depend on another target, which generated the input and output files and put them in item lists. Then reference those item lists on the inputs and output attributes of your compilation target.
Is that what you're looking for?
dan/MSBuild
精彩评论