After trying to automatically convert my solutions to Scons scripts, which did not work at all, I decided to start from scratch.
I easily got the bare build and link done on one of my modules. And I tried to gradually introduce 'features' in my build : namely Precompiled header (PCH) support, and Debug information generation.
Adding both was easy, using the Scons man page as a reference, I used a construct like this one :
env['PCHSTOP'] = "precompiled.h"env['PCH'] = env.PCH( os.path.join(builddir, 'precompiled.cpp') )[0]
env['PDB'] = os.path.join( builddir, "%s.pdb" % BASE_NAME )
Using this setup, it works fine out-of-the-box, but Scons msvc tool uses the /Z7 compiler flag to create the debug information. This has the effect to store debug informations in every built obj file, and according to Scons man page (at CCPDBFLAGS information), allow parallel builds to work fast & correctly.
This duplication of debug information lead my, simple, build directory to grow from about 33Mb (using my existing reference MSVC vcproj to build) to about 60Mb, almost 100% bigger...
I took a look at using /Zi instead of /Z7, to have a single PDB containing my debug information, and it took some to figure out how to have it work with PCH altogether.
According to Scons man page, all you have to do is ::
env['CCPDBFLAGS'] = ['${(PDB and "/Zi /Fd%s" % File(PDB)) or ""}']
Using this setup, I had two problems :
- the linker complained about LNK4203 errors, preventing debugging information to be linked.
- when doing a partial build of the project, the compiler complained about a C2859 error, indicating that the PDB file was not the one generated with the PCH, and instructing me to rebuild all.
I changed the PDB flags to instruct the compiler to use an intermediate PDB file :
env['CCPDBFLAGS'] = ['${(PDB and "/Fd%s_incremental.pdb /Zi" % File(PDB)) or ""}']
And now everything works fine.