Make Scons "debug" and "optimization" options independent
This commit is contained in:
parent
31c7c36921
commit
ef0d68a2e0
1 changed files with 58 additions and 26 deletions
84
SConstruct
84
SConstruct
|
|
@ -150,32 +150,39 @@ opts.AddVariables(
|
||||||
)
|
)
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
|
defaults.cxxFlags = ''
|
||||||
|
defaults.ccFlags = ''
|
||||||
|
defaults.noOptimizeCcFlags = ''
|
||||||
|
defaults.optimizeCcFlags = ''
|
||||||
|
defaults.debugCcFlags = ''
|
||||||
|
defaults.noDebugCcFlags = ''
|
||||||
|
defaults.debugLinkFlags = ''
|
||||||
|
defaults.noDebugLinkFlags = ''
|
||||||
|
|
||||||
if env['CC'] == 'gcc':
|
if env['CC'] == 'gcc':
|
||||||
defaults.cxxFlags = '-ftemplate-depth-128'
|
defaults.cxxFlags = '-ftemplate-depth-128'
|
||||||
defaults.ccFlags = '-Wall -g'
|
defaults.ccFlags = '-Wall'
|
||||||
defaults.debugCcFlags = '-O0 -fno-inline'
|
defaults.debugCcFlags = '-g'
|
||||||
defaults.releaseCcFlags = '-O3 -finline-functions -Wno-inline -DNDEBUG'
|
defaults.noOptimizeCcFlags = '-O0 -fno-inline'
|
||||||
defaults.debugLinkFlags = ''
|
defaults.optimizeCcFlags = '-O3 -DNDEBUG -finline-functions -Wno-inline'
|
||||||
|
|
||||||
elif env['CC'] == 'cl': # Visual Studio
|
elif env['CC'] == 'cl': # Visual Studio
|
||||||
defaults.cxxFlags = '/EHsc'
|
defaults.cxxFlags = '/EHsc'
|
||||||
defaults.ccFlags = ' '.join(['/nologo', '/Zi', '/W3', '/Zc:wchar_t', '/Zc:forScope',
|
defaults.ccFlags = ' '.join(['/nologo', '/Zi', '/W3', '/Zc:wchar_t', '/Zc:forScope',
|
||||||
'/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS'])
|
'/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS'])
|
||||||
defaults.debugCcFlags = '/Od /Ob0 /MD' # note: MDd breaks the Python module
|
defaults.debugCcFlags = '/MD' # note: MDd breaks the Python module
|
||||||
defaults.releaseCcFlags = '/O2 /MD /DNDEBUG'
|
defaults.noOptimizeCcFlags = '/Od /Ob0'
|
||||||
|
defaults.optimizeCcFlags = '/O2 /DNDEBUG'
|
||||||
defaults.debugLinkFlags = '/DEBUG'
|
defaults.debugLinkFlags = '/DEBUG'
|
||||||
|
|
||||||
elif env['CC'] == 'icc':
|
elif env['CC'] == 'icc':
|
||||||
defaults.cxxFlags = '-ftemplate-depth-128'
|
defaults.cxxFlags = '-ftemplate-depth-128'
|
||||||
defaults.ccFlags = '-Wcheck -g -vec-report0'
|
defaults.ccFlags = '-Wcheck -vec-report0'
|
||||||
defaults.debugCcFlags = '-O0 -fno-inline'
|
defaults.debugCcFlags = '-g'
|
||||||
defaults.releaseCcFlags = '-O3 -finline-functions -DNDEBUG'
|
defaults.noOptimizeCcFlags = '-O0 -fno-inline'
|
||||||
defaults.debugLinkFlags = ''
|
defaults.optimizeCcFlags = '-O3 -finline-functions -DNDEBUG'
|
||||||
else:
|
else:
|
||||||
print "Warning: Unrecognized C compiler '%s'" % env['CC']
|
print "WARNING: Unrecognized C compiler '%s'" % env['CC']
|
||||||
defaults.cxxFlags = ''
|
|
||||||
defaults.ccFlags = ''
|
|
||||||
defaults.debugCcFlags = ''
|
|
||||||
defaults.releaseCcFlags = ''
|
|
||||||
defaults.debugLinkFlags = ''
|
|
||||||
|
|
||||||
# **************************************
|
# **************************************
|
||||||
# *** Read user-configurable options ***
|
# *** Read user-configurable options ***
|
||||||
|
|
@ -263,8 +270,9 @@ opts.AddVariables(
|
||||||
'Compilation options for the Fortran 90 compiler.',
|
'Compilation options for the Fortran 90 compiler.',
|
||||||
'-O3'),
|
'-O3'),
|
||||||
BoolVariable(
|
BoolVariable(
|
||||||
'debug',
|
'debug_verbose',
|
||||||
"""Enable extra printing code to aid in debugging.""",
|
"""Enable extra printing to aid in debugging. This code is marked
|
||||||
|
by the preprocessor macros DEBUG_MODE and DEBUG_MODE_ENABLED.""",
|
||||||
False),
|
False),
|
||||||
BoolVariable(
|
BoolVariable(
|
||||||
'coverage',
|
'coverage',
|
||||||
|
|
@ -446,15 +454,31 @@ opts.AddVariables(
|
||||||
defaults.ccFlags),
|
defaults.ccFlags),
|
||||||
BoolVariable(
|
BoolVariable(
|
||||||
'optimize',
|
'optimize',
|
||||||
"""Enable extra compiler optimizations specified by the "release_flags" variable,
|
"""Enable extra compiler optimizations specified by the "optimize_flags" variable,
|
||||||
instead of the flags specified by the "debug_flags" variable""",
|
instead of the flags specified by the "debug_flags" variable""",
|
||||||
True),
|
True),
|
||||||
('release_flags',
|
('optimize_flags',
|
||||||
'Additional compiler flags passed to the C/C++ compiler when optimize=yes.',
|
'Additional compiler flags passed to the C/C++ compiler when optimize=yes.',
|
||||||
defaults.releaseCcFlags),
|
defaults.optimizeCcFlags),
|
||||||
('debug_flags',
|
('no_optimize_flags',
|
||||||
'Additional compiler flags passed to the C/C++ compiler when optimize=no.',
|
'Additional compiler flags passed to the C/C++ compiler when optimize=no.',
|
||||||
|
defaults.noOptimizeCcFlags),
|
||||||
|
BoolVariable(
|
||||||
|
'debug',
|
||||||
|
"""Enable compiler debugging symbols.""",
|
||||||
|
True),
|
||||||
|
('debug_flags',
|
||||||
|
'Additional compiler flags passed to the C/C++ compiler when debug=yes.',
|
||||||
defaults.debugCcFlags),
|
defaults.debugCcFlags),
|
||||||
|
('no_debug_flags',
|
||||||
|
'Additional compiler flags passed to the C/C++ compiler when debug=no.',
|
||||||
|
defaults.noDebugCcFlags),
|
||||||
|
('debug_linker_flags',
|
||||||
|
'Additional options passed to the linker when debug=yes',
|
||||||
|
defaults.debugLinkFlags),
|
||||||
|
('no_debug_linker_flags',
|
||||||
|
'Additional options passed to the linker when debug=yes',
|
||||||
|
defaults.noDebugLinkFlags),
|
||||||
BoolVariable(
|
BoolVariable(
|
||||||
'build_thread_safe',
|
'build_thread_safe',
|
||||||
"""Cantera can be built so that it is thread safe. Doing so
|
"""Cantera can be built so that it is thread safe. Doing so
|
||||||
|
|
@ -785,11 +809,19 @@ env['inst_mandir'] = pjoin(instRoot, 'man1')
|
||||||
env['inst_matlab_dir'] = pjoin(instRoot, 'matlab', 'toolbox')
|
env['inst_matlab_dir'] = pjoin(instRoot, 'matlab', 'toolbox')
|
||||||
|
|
||||||
env['CXXFLAGS'] = listify(env['cxx_flags'])
|
env['CXXFLAGS'] = listify(env['cxx_flags'])
|
||||||
|
|
||||||
if env['optimize']:
|
if env['optimize']:
|
||||||
env['CCFLAGS'] = listify(env['cc_flags']) + listify(env['release_flags'])
|
env['CCFLAGS'] = listify(env['cc_flags']) + listify(env['optimize_flags'])
|
||||||
else:
|
else:
|
||||||
env['CCFLAGS'] = listify(env['cc_flags']) + listify(env['debug_flags'])
|
env['CCFLAGS'] = listify(env['cc_flags']) + listify(env['no_optimize_flags'])
|
||||||
env['LINKFLAGS'] += listify(defaults.debugLinkFlags)
|
|
||||||
|
if env['debug']:
|
||||||
|
env['CCFLAGS'] += listify(env['debug_flags'])
|
||||||
|
env['LINKFLAGS'] += listify(env['debug_linker_flags'])
|
||||||
|
else:
|
||||||
|
env['CCFLAGS'] += listify(env['no_debug_flags'])
|
||||||
|
env['LINKFLAGS'] += listify(env['no_debug_linker_flags'])
|
||||||
|
|
||||||
|
|
||||||
if env['coverage']:
|
if env['coverage']:
|
||||||
if env['CC'] == 'gcc':
|
if env['CC'] == 'gcc':
|
||||||
|
|
@ -820,7 +852,7 @@ def cdefine(definevar, configvar, comp=True, value=1):
|
||||||
else:
|
else:
|
||||||
configh[definevar] = None
|
configh[definevar] = None
|
||||||
|
|
||||||
cdefine('DEBUG_MODE', 'debug')
|
cdefine('DEBUG_MODE', 'debug_verbose')
|
||||||
|
|
||||||
# Need to test all of these to see what platform.system() returns
|
# Need to test all of these to see what platform.system() returns
|
||||||
configh['SOLARIS'] = 1 if env['OS'] == 'Solaris' else None
|
configh['SOLARIS'] = 1 if env['OS'] == 'Solaris' else None
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue