garyo edited this page Dec 13, 2014 · 1 revision

This lets you choose debug or release from the command line:

import glob

#get the mode flag from the command line
#default to 'release' if the user didn't specify
mymode = ARGUMENTS.get('mode', 'release')   #holds current mode

#check if the user has been naughty: only 'debug' or 'release' allowed
if not (mymode in ['debug', 'release']):
    print "Error: expected 'debug' or 'release', found: " + mymode

#tell the user what we're doing
print '**** Compiling in ' + mymode + ' mode...'

project = 'myprogram'        #holds the project name
buildroot = '../' + mymode   #holds the root of the build directory tree
debugcflags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd']   #extra compile flags for debug
releasecflags = ['-O2', '-EHsc', '-DNDEBUG', '/MD']         #extra compile flags for release

#From here on will be common to all projects

builddir = buildroot + '/' + project   #holds the build directory for this project
targetpath = builddir + '/' + project  #holds the path to the executable in the build directory

env = Environment()

#append the user's additional compile flags
#assume debugcflags and releasecflags are defined
if mymode == 'debug':

#specify the build directory
BuildDir('#' + builddir, "#.", duplicate=0)

env.Program(targetpath, source=map(lambda x: '#' + builddir + '/' + x, glob.glob('*.cpp')))
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.