aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-04-13 03:17:42 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-04-13 03:17:42 +0530
commiteb07ad867e97b6baaef2f1d7de080092c0a36ccc (patch)
tree720730d3d614fd196214ff249e8f4334600fcb4a /mesonbuild
parentc04862e24c94000a4e8a7b9c1012178b3b6195d8 (diff)
downloadmeson-eb07ad867e97b6baaef2f1d7de080092c0a36ccc.zip
meson-eb07ad867e97b6baaef2f1d7de080092c0a36ccc.tar.gz
meson-eb07ad867e97b6baaef2f1d7de080092c0a36ccc.tar.bz2
PkgConfigDependency: Cache the output of pkg-config
This halves the configure time in gst-build, the aggregate of all GStreamer repositories. We can't do this to Popen_safe because we can't be sure that other programs have no side-effects and will always return the same output for the same arguments and environment.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/base.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 0375102..8b07a21 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,19 @@ class PkgConfigDependency(ExternalDependency):
return s.format(self.__class__.__name__, self.name, self.is_found,
self.version_reqs)
- def _call_pkgbin(self, args, env=None):
+ def _call_pkgbin_real(self, args, env):
if not env:
env = os.environ
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):
+ targs = tuple(args)
+ cache = PkgConfigDependency.pkgbin_cache
+ if (self.pkgbin, targs, env) not in cache:
+ cache[(self.pkgbin, targs, env)] = self._call_pkgbin_real(args, env)
+ return cache[(self.pkgbin, targs, env)]
+
def _convert_mingw_paths(self, args):
'''
Both MSVC and native Python on Windows cannot handle MinGW-esque /c/foo