Improve the configuration cache accuracy

This commit is contained in:
Thomas Nagy 2019-06-25 11:51:44 +02:00
parent 9b3ab4b874
commit 173f410e3f
2 changed files with 18 additions and 6 deletions

View File

@ -524,7 +524,7 @@ def run_build(self, *k, **kw):
Though this function returns *0* by default, the build may set an attribute named *retval* on the
build context object to return a particular value. See :py:func:`waflib.Tools.c_config.test_exec_fun` for example.
This function also provides a limited cache. To use it, provide the following option::
This function also features a cache which can be enabled by the following option::
def options(opt):
opt.add_option('--confcache', dest='confcache', default=0,
@ -535,10 +535,22 @@ def run_build(self, *k, **kw):
$ waf configure --confcache
"""
lst = [str(v) for (p, v) in kw.items() if p != 'env']
h = Utils.h_list(lst)
buf = []
for key in sorted(kw.keys()):
if key != 'env':
v = kw[key]
if hasattr(v, '__call__'):
buf.append(Utils.h_fun(v))
else:
buf.append(str(v))
h = Utils.h_list(buf)
dir = self.bldnode.abspath() + os.sep + (not Utils.is_win32 and '.' or '') + 'conf_check_' + Utils.to_hex(h)
cachemode = kw.get('confcache', getattr(Options.options, 'confcache', None))
if not cachemode and os.path.exists(dir):
shutil.rmtree(dir)
try:
os.makedirs(dir)
except OSError:
@ -549,7 +561,6 @@ def run_build(self, *k, **kw):
except OSError:
self.fatal('cannot use the configuration test folder %r' % dir)
cachemode = getattr(Options.options, 'confcache', None)
if cachemode == 1:
try:
proj = ConfigSet.ConfigSet(os.path.join(dir, 'cache_run_build'))
@ -589,7 +600,7 @@ def run_build(self, *k, **kw):
else:
ret = getattr(bld, 'retval', 0)
finally:
if cachemode == 1:
if cachemode:
# cache the results each time
proj = ConfigSet.ConfigSet()
proj['cache_run_build'] = ret

View File

@ -224,6 +224,7 @@ def check_endianness(self):
def check_msg(self):
return tmp[0]
self.check(fragment=ENDIAN_FRAGMENT, features='c grep_for_endianness',
msg='Checking for endianness', define='ENDIANNESS', tmp=tmp, okmsg=check_msg)
msg='Checking for endianness', define='ENDIANNESS', tmp=tmp,
okmsg=check_msg, confcache=None)
return tmp[0]