tags:

views:

68

answers:

2

Hi All,

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
  /build
    /bin
    /obj
  /source
    /subdirs
    /..
  SConstruct

Basically, what I get now is my source directory is getting polluted with obj files. I'd rather have it all in one place.

The SConstruct file looks like this:

env.VariantDir('build', 'source', duplicate = 0)
env.Program('Hierarchy', source = ['source/sconstest.cpp', 'source/utils/IntUtil.cpp'])

I've read a few other similar questions on this site, but havn't found a good solution yet.

Thanks

+1  A: 

The VariantDir (also described in the user guide) tells scons to put generated files in a separate directory. In older versions of scons this function was named BuildDir.

You may also want to read up on avoiding duplicating the source directory (described both in the user guide and on the wiki).

Dave Bacher
yes, that's what i tried:env.VariantDir('build', 'source', duplicate = 0)env.Program('Hierarchy', source = ['source/sconstest.cpp', 'source/utils/IntUtil.cpp'])and this has absolutely no effect at all :(
Waldo Bronchart
A: 

The easiest way I've found is to use 2 files, a SConstruct file and a separate SConscript.

In the SConstruct you simply call the other file and specify the directory for the build output:

# content SConstruct
SConscript('main.scons', variant_dir='build', duplicate=0)

Then in 'main.scons' you do the meat of your build. You can forget about variant directories in this file.

# content of main.scons
env = Environment()
env.Program('Hierarchy',
            source = ['source/sconstest.cpp', 'source/utils/IntUtil.cpp'])
rq
Thanks, that worked. Although just having one file is much cleaner. I think I'll just have to live with it!
Waldo Bronchart