I have written a checker which checks for a single module of Qt4 library using Qt4 tool. I'm trying to save environment in the begining of the test and restore it in the end of the test but it doesn't works.
Here is a simple SConstruct to reproduce this issue:
def CheckQt4Module(context,module):
context.Message("Checking for %s module..."%module)
oldEnv = context.env
try: context.env['QTDIR']
except KeyError: context.env.Tool('qt4')
context.env.EnableQt4Modules([module])
test_src="""
#include <%s>
int main() {
return 0;
}
"""%module
res = context.TryLink(test_src,".cpp")
context.env = oldEnv
context.Result(res)
return res
env=Environment(LIBS=[])
print env['LIBS']
conf = Configure(env, custom_tests={"CheckQt4Module": CheckQt4Module})
conf.CheckQt4Module("QtNetwork")
env = conf.Finish()
print env['LIBS']
When I run scons I got the following output:
vestnik@vestnik-laptop:~/Development/tests/scons$ scons
scons: Reading SConscript files ...
[]
Checking for QtNetwork module...yes
['$QT4_LIB', 'QtNetwork', 'QtCore']
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
I've tried to use Clone() method but my environment is still modified.
Does somebody know how to backup scons environment and then restore it?
edit: Correct way to do it is to use Clone method of the environment object but it looks like it doesn't work due to a bug in the scons 1.2.0. It's discussed here