aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2019-02-19 19:34:20 +0100
committerDaniel Mensinger <daniel@mensinger-ka.de>2019-04-28 14:31:49 +0200
commitc9bd84fd25dd24999ac2d20b616e91efb9038905 (patch)
tree75adff6c68e678cbf5ffb459dedafd2bfd8605c0 /mesonbuild/compilers/compilers.py
parentcbdf9d06471ed9b682e94f5d9f4084ee35358778 (diff)
downloadmeson-c9bd84fd25dd24999ac2d20b616e91efb9038905.zip
meson-c9bd84fd25dd24999ac2d20b616e91efb9038905.tar.gz
meson-c9bd84fd25dd24999ac2d20b616e91efb9038905.tar.bz2
Cache compile results in coredata
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 87a83e5..169a973 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -875,8 +875,6 @@ class Compiler:
# Libraries that are internal compiler implementations, and must not be
# manually searched.
internal_libs = ()
- # Cache for the result of compiler checks which can be cached
- compiler_check_cache = {}
def __init__(self, exelist, version, **kwargs):
if isinstance(exelist, str):
@@ -1148,16 +1146,16 @@ class Compiler:
return os.path.join(dirname, 'output.' + suffix)
@contextlib.contextmanager
- def compile(self, code, extra_args=None, mode='link', want_output=False):
+ def compile(self, code, extra_args=None, mode='link', want_output=False, cdata: coredata.CoreData = None):
if extra_args is None:
textra_args = None
extra_args = []
else:
textra_args = tuple(extra_args)
- key = (code, textra_args, mode)
+ key = (tuple(self.exelist), self.version, code, textra_args, mode)
if not want_output:
- if key in self.compiler_check_cache:
- p = self.compiler_check_cache[key]
+ if cdata is not None and key in cdata.compiler_check_cache:
+ p = cdata.compiler_check_cache[key]
mlog.debug('Using cached compile:')
mlog.debug('Cached command line: ', ' '.join(p.commands), '\n')
mlog.debug('Code:\n', code)
@@ -1206,8 +1204,15 @@ class Compiler:
p.input_name = srcname
if want_output:
p.output_name = output
- else:
- self.compiler_check_cache[key] = p
+ elif cdata is not None:
+ # Remove all attributes except the following
+ # This way the object can be serialized
+ tokeep = ['args', 'commands', 'input_name', 'output_name',
+ 'pid', 'returncode', 'stdo', 'stde', 'text_mode']
+ todel = [x for x in vars(p).keys() if x not in tokeep]
+ for i in todel:
+ delattr(p, i)
+ cdata.compiler_check_cache[key] = p
yield p
except (PermissionError, OSError):
# On Windows antivirus programs and the like hold on to files so