cache all gnulike_default_include_dirs invocations

pull/5953/head
Daniel Mensinger 5 years ago
parent 73d52266b5
commit 66c129c52f
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 9
      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]:

Loading…
Cancel
Save