mongodb/mongo — pull request #167 by djcsdy (2012-01-31 15:28:15+00:00)
Title: Always use the 32-bit Microsoft toolchain when building with --32 on Windows

For some reason on my 64-bit Windows 7 system, I can’t build a 32-bit Mongo (with `scons --32 -j8`) because SCons 2.1.0 insists on using the 64-bit toolchain. This happens even if I try to build in an x86 Visual Studio Command Prompt – SCons is still picking up a 64-bit toolchain from somewhere.

I’m not entirely sure why this is, but I suspect that SCons distinguishes between the toolchain that comes with Visual Studio, and otherwise identical copies of the same toolchain from other sources, such as from the Windows 7 SDK.

The SCons documentation is very vague about what `MSVS_ARCH` actually does. OTOH, it is quite clear that `TARGET_ARCH` should be set to the architecture that we are building for, and currently Mongo’s `Sconstruct` makes no effort to do that.

Therefore, the attached commit changes `SConstruct` so that, when building with `--32` or `--64`, `TARGET_ARCH` and `MSVS_ARCH` are set to `x86` or `x64` as appropriate. This fixes the problem for me so that SCons now picks up the correct toolchain.

While I was there I also changed the logic that defaults to 64-bit if the current directory is named `mongo-64`, so that it has no effect if the build is run with `--32`. It doesn’t make much sense to me to make a 64-bit build when the user has explicitly asked for 32-bit.