aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-04-14 22:05:37 +0300
committerGitHub <noreply@github.com>2018-04-14 22:05:37 +0300
commit798d841348d01c1e96e9a9ea1f1f689dbfa5518a (patch)
tree5942abb2f7678746a5aa4036dd10b59f65c2e985 /mesonbuild
parent0535f38af99825731ef3dbd49937bc03bd097337 (diff)
parent3acda1d9982176636ba45bcca41a847f4b6f6af2 (diff)
downloadmeson-798d841348d01c1e96e9a9ea1f1f689dbfa5518a.zip
meson-798d841348d01c1e96e9a9ea1f1f689dbfa5518a.tar.gz
meson-798d841348d01c1e96e9a9ea1f1f689dbfa5518a.tar.bz2
Merge pull request #3396 from mesonbuild/nirbheek/cache-pkgconfig
PkgConfigDependency: Cache the output of pkg-config
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/base.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 0375102..4127081 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -362,6 +362,8 @@ class PkgConfigDependency(ExternalDependency):
# The class's copy of the pkg-config path. Avoids having to search for it
# multiple times in the same Meson invocation.
class_pkgbin = None
+ # We cache all pkg-config subprocess invocations to avoid redundant calls
+ pkgbin_cache = {}
def __init__(self, name, environment, kwargs, language=None):
super().__init__('pkgconfig', environment, language, kwargs)
@@ -459,12 +461,22 @@ class PkgConfigDependency(ExternalDependency):
return s.format(self.__class__.__name__, self.name, self.is_found,
self.version_reqs)
- def _call_pkgbin(self, args, env=None):
- if not env:
- env = os.environ
+ def _call_pkgbin_real(self, args, env):
p, out = Popen_safe(self.pkgbin.get_command() + args, env=env)[0:2]
return p.returncode, out.strip()
+ def _call_pkgbin(self, args, env=None):
+ if env is None:
+ fenv = env
+ env = os.environ
+ else:
+ fenv = frozenset(env.items())
+ targs = tuple(args)
+ cache = PkgConfigDependency.pkgbin_cache
+ if (self.pkgbin, targs, fenv) not in cache:
+ cache[(self.pkgbin, targs, fenv)] = self._call_pkgbin_real(args, env)
+ return cache[(self.pkgbin, targs, fenv)]
+
def _convert_mingw_paths(self, args):
'''
Both MSVC and native Python on Windows cannot handle MinGW-esque /c/foo