I\'ve been trying to get scons to output exe, obj, lib and dll files to a specific build directory.
My file structure looks like this:
/projectdir
It's not that tough to get VariantDir working using only one SConstruct file (for a small project), but it's very confusing as the configuration is different for the one-file and two-file use case.
Only SConstruct:
env = Environment()
env.VariantDir('build', 'src', duplicate=0)
files = Glob('build\*.c')
env.Program("build\program", files)
Notice how the source files are located in .\src
but .\build
is specified as the location. The output has to be also "prefixed" with .\build
otherwise the compiled program will reside in the directory of the SConstruct file.
When you execute the script SCons will compile the *.c
files from .\src
and put the resulting objects to .\build
.
No wonder they renamed BuildDir to VariantDir to try to avoid the confusion (without much success).