diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-10-03 17:02:44 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-10-03 17:04:44 +0200 |
commit | 66c129c52f8af07107c6a5f91853f44ab08525a2 (patch) | |
tree | b18479a399bfaf258929b1c4fa44d96d2d6a1148 | |
parent | 73d52266b5cf8e6b62d715328f0c66b1734c3026 (diff) | |
download | meson-66c129c52f8af07107c6a5f91853f44ab08525a2.zip meson-66c129c52f8af07107c6a5f91853f44ab08525a2.tar.gz meson-66c129c52f8af07107c6a5f91853f44ab08525a2.tar.bz2 |
cache all gnulike_default_include_dirs invocations
-rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 998b86c..f4ce5b9 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -84,14 +84,13 @@ gnu_color_args = { } # type: typing.Dict[str, typing.List[str]] -# TODO: The result from calling compiler should be cached. So that calling this -# function multiple times don't add latency. -def gnulike_default_include_dirs(compiler: typing.List[str], lang: str) -> typing.List[str]: +@functools.lru_cache(maxsize=None) +def gnulike_default_include_dirs(compiler: typing.Tuple[str], lang: str) -> typing.List[str]: if lang == 'cpp': lang = 'c++' env = os.environ.copy() env["LC_ALL"] = 'C' - cmd = compiler + ['-x{}'.format(lang), '-E', '-v', '-'] + cmd = list(compiler) + ['-x{}'.format(lang), '-E', '-v', '-'] p = subprocess.Popen( cmd, stdin=subprocess.DEVNULL, @@ -171,7 +170,7 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta): return gnulike_instruction_set_args.get(instruction_set, None) def get_default_include_dirs(self) -> typing.List[str]: - return gnulike_default_include_dirs(self.exelist, self.language) + return gnulike_default_include_dirs(tuple(self.exelist), self.language) @abc.abstractmethod def openmp_flags(self) -> typing.List[str]: |