This could be achieved using the SCons VariantDir() function, which will place the build targets in a subdirectory.
Here's an example:
VariantDir('buildA', '.', duplicate=0)
VariantDir('buildB', '.', duplicate=0)
env.Library('libraryA', 'buildA/source.c', CCFLAGS=['-DCONFIG_X'])
env.Library('libraryB', 'buildB/source.c', CCFLAGS=['-DCONFIG_Y'])
This will build a different version of source.c
in both buildA
and buildB
. Although the actual source.c
source file is not in those build directories, you refer to it as if it was, so SCons
knows where to put the output.
There's a better description for the VariantDir() function in the SCons man pages.