Use stash/revert/commit pattern for transactional configuration

Apply that pattern when relevant. That allows correct behavior if tools are
loaded inside a transaction.
This commit is contained in:
Gustavo Jose de Sousa 2016-03-21 18:59:13 -03:00 committed by Thomas Nagy
parent 85e403516c
commit d46f541099
5 changed files with 13 additions and 3 deletions

View File

@ -81,7 +81,9 @@ def configure(conf):
if conf.env['CC']:
conf.end_msg(conf.env.get_flat('CC'))
conf.env['COMPILER_CC'] = compiler
conf.env.commit()
break
conf.env.revert()
conf.end_msg(False)
else:
conf.fatal('could not configure a C compiler!')

View File

@ -82,7 +82,9 @@ def configure(conf):
if conf.env['CXX']:
conf.end_msg(conf.env.get_flat('CXX'))
conf.env['COMPILER_CXX'] = compiler
conf.env.commit()
break
conf.env.revert()
conf.end_msg(False)
else:
conf.fatal('could not configure a C++ compiler!')

View File

@ -58,7 +58,9 @@ def configure(conf):
if conf.env.D:
conf.end_msg(conf.env.get_flat('D'))
conf.env['COMPILER_D'] = compiler
conf.env.commit()
break
conf.env.revert()
conf.end_msg(False)
else:
conf.fatal('could not configure a D compiler!')

View File

@ -44,7 +44,9 @@ def configure(conf):
if conf.env['FC']:
conf.end_msg(conf.env.get_flat('FC'))
conf.env.COMPILER_FORTRAN = compiler
conf.env.commit()
break
conf.env.revert()
conf.end_msg(False)
else:
conf.fatal('could not configure a Fortran compiler!')

View File

@ -410,12 +410,14 @@ def check_boost(self, *k, **kw):
self.env["CXXFLAGS_%s" % var] += cxxflags
try:
try_link()
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
exc = None
break
except Errors.ConfigurationError as e:
self.env.revert()
exc = e
else:
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
exc = None
self.env.commit()
break
if exc is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)