Exclude ConfigSet from altering ConfigurationContext.run_build caches #2273

This commit is contained in:
Thomas Nagy 2019-12-20 07:55:36 +01:00
parent 13d9c8566c
commit ce2e5ca9a2
1 changed files with 16 additions and 9 deletions

View File

@ -508,23 +508,27 @@ def find_binary(self, filenames, exts, paths):
@conf @conf
def run_build(self, *k, **kw): def run_build(self, *k, **kw):
""" """
Create a temporary build context to execute a build. A reference to that build Create a temporary build context to execute a build. A temporary reference to that build
context is kept on self.test_bld for debugging purposes, and you should not rely context is kept on self.test_bld for debugging purposes.
on it too much (read the note on the cache below). The arguments to this function are passed to a single task generator for that build.
The parameters given in the arguments to this function are passed as arguments for Only three parameters are mandatory:
a single task generator created in the build. Only three parameters are obligatory:
:param features: features to pass to a task generator created in the build :param features: features to pass to a task generator created in the build
:type features: list of string :type features: list of string
:param compile_filename: file to create for the compilation (default: *test.c*) :param compile_filename: file to create for the compilation (default: *test.c*)
:type compile_filename: string :type compile_filename: string
:param code: code to write in the filename to compile :param code: input file contents
:type code: string :type code: string
Though this function returns *0* by default, the build may set an attribute named *retval* on the Though this function returns *0* by default, the build may bind 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. build context object to return a particular value. See :py:func:`waflib.Tools.c_config.test_exec_fun` for example.
This function also features a cache which can be enabled by the following option:: The temporary builds creates a temporary folder; the name of that folder is calculated
by hashing input arguments to this function, with the exception of :py:class:`waflib.ConfigSet.ConfigSet`
objects which are used for both reading and writing values.
This function also features a cache which is disabled by default; that cache relies
on the hash value calculated as indicated above::
def options(opt): def options(opt):
opt.add_option('--confcache', dest='confcache', default=0, opt.add_option('--confcache', dest='confcache', default=0,
@ -538,7 +542,10 @@ def run_build(self, *k, **kw):
buf = [] buf = []
for key in sorted(kw.keys()): for key in sorted(kw.keys()):
v = kw[key] v = kw[key]
if hasattr(v, '__call__'): if isinstance(v, ConfigSet.ConfigSet):
# values are being written to, so they are excluded from contributing to the hash
continue
elif hasattr(v, '__call__'):
buf.append(Utils.h_fun(v)) buf.append(Utils.h_fun(v))
else: else:
buf.append(str(v)) buf.append(str(v))