It you want your build directory in another directory tree, try this:
1 import glob
2 env = Environment()
3
4 #variable to hold the build directory (relative)
5 mybuilddir = '../debug/myprogram'
6
7 #set up an alternate build directory
8 BuildDir('#' + mybuilddir, "#.", duplicate=0)
9
10 #target is myprogram.exe (win32) in the current directory
11 #lambda translates source file names relative to build directory
12 env.Program('myprogram', source=map(lambda x: '#' + mybuilddir + '/' + x, glob.glob('*.cpp')))
this assumes that your dir tree looks like this
...\Debug
\myprogram
\hisprogram
\herprogram
...\myprogram
...\hisprogram
...\herprogramNote that you can use absolute path names for mybuilddir
errata: don't need Split() for source files
In the above situations, the target file 'myprogram.exe' is placed in the currect directory. If you want the target file to also be put into the build directory, try this:
1 import glob
2 env = Environment()
3
4 #variable to hold the build directory (relative)
5 mybuilddir = '../debug/myprogram'
6
7 #set up an alternate build directory
8 BuildDir('#' + mybuilddir, "#.", duplicate=0)
9
10 #target is myprogram.exe (win32) in the build directory
11 #lambda translates source file names relative to build directory
12 env.Program(mybuilddir + '/myprogram', source=map(lambda x: '#' + mybuilddir + '/' + x, glob.glob('*.cpp')))
Assuming that the project name is the same as the executable name is the same as the build directory name...
1 import glob
2
3 #project name is the root name for the executable and build directory
4 project = 'myproject'
5
6 #buildroot is where all project build directories reside
7 buildroot = '../debug'
8
9 #-------
10 #From here on will be common to all projects
11
12 #holds the project build directory
13 builddir = buildroot + '/' + project
14 #holds the path to the target file in the project build directory
15 targetpath = builddir + '/' + project
16
17 env = Environment()
18
19 #define the build directory for scons
20 BuildDir('#' + builddir, "#.", duplicate=0)
21
22 env.Program(targetpath, source=map(lambda x: '#' + builddir + '/' + x, glob.glob('*.cpp')))
