In a SCons script I create a base environment from which I derived others environments. Something like this :
base = Environment()
base['CXXFLAGS'] += ['-DBOOST_HAS_PTHREAD', '-D__STDC_CONSTANT_MACROS', '-DFILELOG_MAX_LEVEL=4', '-Wall']
opt = base.Clone()
opt['CXXFLAGS'] += ['-DNDEBUG', '-O3']
This way, I can create more environment (release/debug/instrumented/pgo) from the base environment. In the SCons documentation it's said that env.Clone() does a deep copy of env. But in fact it doesn't seem to work. because in the example, the base environment would have the -DNDEBUG and -O3 flags applied.
A I doing something wrong?
edit : Here is the real code. There is two print statements in this code and I think they should print the same things, but they don't. The output follows:
# -*- coding: utf-8 -*-
import os.path
import glob
local_env = Environment()
local_env['CXXFLAGS'] += ['-DBOOST_HAS_PTHREAD', '-D__STDC_CONSTANT_MACROS', '-DFILELOG_MAX_LEVEL=4', '-Wall']
local_env.Append(LIBS = ['pthread', 'boost_thread', 'boost_filesystem', 'boost_program_options', 'boost_iostreams'])
opt = local_env.Clone()
opt['CXXFLAGS'] += ['-DNDEBUG', '-O3']
print opt['CXXFLAGS']
instr = opt.Clone()
instr['CXXFLAGS'] += ['-fprofile-arcs']
instr['LIBS'] += ['gcov']
print opt['CXXFLAGS']
The output :
|| scons: Reading SConscript files ...
|| -DBOOST_HAS_PTHREAD -D__STDC_CONSTANT_MACROS -DFILELOG_MAX_LEVEL=4 -Wall -DNDEBUG -O3
|| -DBOOST_HAS_PTHREAD -D__STDC_CONSTANT_MACROS -DFILELOG_MAX_LEVEL=4 -Wall -DNDEBUG -O3 -fprofile-arcs
|| scons: done reading SConscript files.
|| scons: Building targets ...
|| scons: `.' is up to date.
|| scons: done building targets.
Edit 2:
It's a bug with SCons http://scons.tigris.org/issues/show_bug.cgi?id=2390
Edit 3:
Will be fixed in 1.3.1 and 2.0.1