views:

93

answers:

1

Hi, so I'm writing a VS2008 C# Add-In to automate AspectC++ weaving in C++ projects. I'm generating the C++ source files (now woven with aspects), but I can't figure out how to compile them as part of the pre-build step. Is there a convenient way to specify new source within the IDTExtensibility2, EnvDTE90, or VslangProj90 namespaces? I've tried using the VCProject and VCProjectEngine interfaces as well as marking the files for inclusion programmatically via the 'ExcludedFromBuild = false' flag. No luck.

I noticed that the commercial AspectC++ Add-In bypasses cl.exe by putting a wrapper around it and the ac++.exe aspect compiler. So they must call their own cl.exe which then calls ac++.exe before preparing the generated source files for the real compiler. That seems like a hack to me, is there not a better way? I'm really stumped on this one, any help would be appreciated.

+1  A: 

Why not just include the generated file into the project that you then build?

1800 INFORMATION
When I do it manually, it works, but from within the Pre-Build event it doesn't. As far as I can tell, the 'ExcludedFromBuild = false' method is the only one to ensure that the file is now included in the project. The .AddFile() function of the VCProject interface indicates that the generated files are indeed part of the project... but for some reason they aren't compiled. I'm thinking that the files to be compiled are determined before the Pre-Build step...
Lake
actually with some testing I got them to include and compile... it's still a hack, but whatever...
Lake
For clarity, I've since learned that the VCProject and Project interfaces are not necessarily equal. The Project (or ProjectItem rather) interface allows you to exclude items from build, but the VCProject, in general, does not. This may be a bug. Also, when you have multiple platforms, the ActiveConfiguration doesn't help you (just config name, not platform), so you'll need to specify this some other way or you'll be excluding items from the wrong configuration.
Lake