I am currently trying to make a build system around Scons, which would use Boost Wave driver as a custom C++ code preprocessor. After preprocessing the code is compiled with MSVC. At the moment I launch wave for each source file seen by Scons, from within the Sconscript file. This works, but has an issue - it's pretty slow because it doesn't take advantage of the Scons compilation cache.
How would you recommend to integrate a custom preprocessing step into SCons build system, in a way that the compilation cache is used? Obviously I also need proper #include dependencies scanning, parallel compilation etc. I'm not very experienced with SCons, so I'm looking for someone to point me in the right direction.
My current two areas of research are:
To use the scons cache you have to have a target. scons caches the target based on the contributing files and build command.
Even without a builder, you can write yourself a Command processor a bit like this.
out_cc = env.Command('file.wave.cpp', 'file.cpp', 'wave command < $SOURCE > $TARGET')
env.Program('myprog', ['this.cc', 'that.cc', out_cc])
This will use the cache.
You can add a builder if you like, so you can do that in all one step. Builders are nice for where you'll use the same command in multiple places or have more complex requirements than can be described with a simple Command. However, they aren't essential for the cache to work.
Edit: Updated to include liosan's solution for wave taking .cpp files and producing .cpp files and hence getting the include dependencies right. Desperate for reputation I am...