Differences between revisions 4 and 5
Revision 4 as of 2007-09-18 03:16:53
Size: 1497
Editor: tur-cache1
Comment:
Revision 5 as of 2008-03-12 02:47:05
Size: 1497
Editor: localhost
Comment: converted to 1.6 markup
No differences found!


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

   1 import glob
   2 
   3 #get the mode flag from the command line
   4 #default to 'release' if the user didn't specify
   5 mymode = ARGUMENTS.get('mode', 'release')   #holds current mode
   6 
   7 #check if the user has been naughty: only 'debug' or 'release' allowed
   8 if not (mymode in ['debug', 'release']):
   9     print "Error: expected 'debug' or 'release', found: " + mymode
  10     Exit(1)
  11 
  12 #tell the user what we're doing
  13 print '**** Compiling in ' + mymode + ' mode...'
  14 
  15 project = 'myprogram'        #holds the project name
  16 buildroot = '../' + mymode   #holds the root of the build directory tree
  17 debugcflags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd']   #extra compile flags for debug
  18 releasecflags = ['-O2', '-EHsc', '-DNDEBUG', '/MD']         #extra compile flags for release
  19 
  20 #-------
  21 #From here on will be common to all projects
  22 
  23 builddir = buildroot + '/' + project   #holds the build directory for this project
  24 targetpath = builddir + '/' + project  #holds the path to the executable in the build directory
  25 
  26 env = Environment()
  27 
  28 #append the user's additional compile flags
  29 #assume debugcflags and releasecflags are defined
  30 if mymode == 'debug':
  31     env.Append(CCFLAGS=debugcflags)
  32 else:
  33     env.Append(CCFLAGS=releasecflags)
  34 
  35 #specify the build directory
  36 BuildDir('#' + builddir, "#.", duplicate=0)
  37 
  38 env.Program(targetpath, source=map(lambda x: '#' + builddir + '/' + x, glob.glob('*.cpp')))

SconstructShortMsvcWin32DebugRelease (last edited 2008-03-12 02:47:05 by localhost)