Round out environment setup; restore mode stuff

This commit is contained in:
Eryn Wells 2014-03-06 00:16:14 -08:00
parent 637cd2d664
commit d054006625

View file

@ -15,19 +15,6 @@ LIB_DIR = Dir('#lib')
SRC_DIR = Dir('#src')
TEST_DIR = Dir('#test')
#
# SCons Command Line Options
#
AddOption('--show-build-cmds',
dest='build_cmds',
action='store_true',
help='Show build commands instead of friendly build messages')
AddOption('--mode',
dest='mode',
metavar='MODE',
help='The build mode')
#
# Environment Configuration
#
@ -38,14 +25,48 @@ def has_clang(env):
return any([cc_tail.startswith('clang'), cxx_tail.startswith('clang')])
default_env = SCons.Defaults.DefaultEnvironment()
default_env['CC'] = binaries.first(['clang', 'gcc'])
default_env['CXX'] = binaries.first(['clang++', 'g++'])
default_env.Replace(CC=binaries.first(['clang', 'gcc']),
CXX=binaries.first(['clang++', 'g++']))
default_env.Append(CCFLAGS=['-Wall', '-Wextra', '-pedantic'])
default_env.Append(CCFLAGS=['-Wall', '-Wextra', '-pedantic'],
CFLAGS=['-std=c99'],
CXXFLAGS=['-std=c++11'])
if has_clang(default_env):
# Only clang supports color.
default_env.Append(CCFLAGS=['-fcolor-diagnostics'])
default_env.Append(CFLAGS=['-std=c99'])
default_env.Append(CXXFLAGS=['-std=c++11'])
debug_env = default_env.Clone(MODE='debug',
CCFLAGS=['-O0', '-g'],
CPPDEFINES=['DEBUG'])
release_env = default_env.Clone(MODE='release',
CCFLAGS=['-O2'],
CPPDEFINES=['RELEASE'])
MODES = {
'debug': debug_env,
'release': release_env
}
#
# Command Line Options
#
def process_modes_option(option, opt, value, parser):
modes = value.split(',')
for m in modes:
setattr(parser.values, 'modes', set(modes))
AddOption('--show-build-cmds',
dest='build_cmds',
action='store_true',
help='Show build commands instead of friendly build messages')
AddOption('--modes',
type='string',
action='callback',
dest='modes',
metavar='MODES',
default=set(['debug']),
callback=process_modes_option,
help=('A comma separated list of modes. Choose from: {}. Default is '
'debug.').format(', '.join(MODES.keys())))