summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-03-12 02:18:36 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-03-12 02:18:36 +0530
commit891b7d1356b329e0a4a833c9071527f4b6b59942 (patch)
tree0fff4da70f00957e23c82fe6b128973065a0bc9c
parent6f8e541f5525d0d0947a5e3cb6707a0d99234db0 (diff)
downloadmeson-nirbheek/use-extprog-pkgconfig.tar.gz
PkgConfigDependency: Search for pkg-config with ExternalProgramnirbheek/use-extprog-pkgconfig
Strawberry Perl on Windows ships with a Perl implementation of pkg-config embedded inside a BAT file. True horror of horrors, but people do use it, so search for pkg-config with ExternalProgram which has the right Windows-specific cases to deal with that. Closes https://github.com/mesonbuild/meson/issues/3221
-rw-r--r--mesonbuild/dependencies/base.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index b6d19831d..03751027b 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -381,9 +381,7 @@ class PkgConfigDependency(ExternalDependency):
pkgname = environment.cross_info.config['binaries']['pkgconfig']
potential_pkgbin = ExternalProgram(pkgname, silent=True)
if potential_pkgbin.found():
- # FIXME, we should store all pkg-configs in ExternalPrograms.
- # However that is too destabilizing a change to do just before release.
- self.pkgbin = potential_pkgbin.get_command()[0]
+ self.pkgbin = potential_pkgbin
PkgConfigDependency.class_pkgbin = self.pkgbin
else:
mlog.debug('Cross pkg-config %s not found.' % potential_pkgbin.name)
@@ -405,7 +403,7 @@ class PkgConfigDependency(ExternalDependency):
self.type_string = 'Native'
mlog.debug('Determining dependency {!r} with pkg-config executable '
- '{!r}'.format(name, self.pkgbin))
+ '{!r}'.format(name, self.pkgbin.get_path()))
ret, self.version = self._call_pkgbin(['--modversion', name])
if ret != 0:
if self.required:
@@ -464,7 +462,7 @@ class PkgConfigDependency(ExternalDependency):
def _call_pkgbin(self, args, env=None):
if not env:
env = os.environ
- p, out = Popen_safe([self.pkgbin] + args, env=env)[0:2]
+ p, out = Popen_safe(self.pkgbin.get_command() + args, env=env)[0:2]
return p.returncode, out.strip()
def _convert_mingw_paths(self, args):
@@ -609,21 +607,23 @@ class PkgConfigDependency(ExternalDependency):
pkgbin = os.environ[evar].strip()
else:
pkgbin = 'pkg-config'
- try:
- p, out = Popen_safe([pkgbin, '--version'])[0:2]
- if p.returncode != 0:
- # Set to False instead of None to signify that we've already
- # searched for it and not found it
+ pkgbin = ExternalProgram(pkgbin, silent=True)
+ if pkgbin.found():
+ try:
+ p, out = Popen_safe(pkgbin.get_command() + ['--version'])[0:2]
+ if p.returncode != 0:
+ mlog.warning('Found pkg-config {!r} but couldn\'t run it'
+ ''.format(' '.join(pkgbin.get_command())))
+ # Set to False instead of None to signify that we've already
+ # searched for it and not found it
+ pkgbin = False
+ except (FileNotFoundError, PermissionError):
pkgbin = False
- except (FileNotFoundError, PermissionError):
+ else:
pkgbin = False
- if pkgbin and not os.path.isabs(pkgbin) and shutil.which(pkgbin):
- # Sometimes shutil.which fails where Popen succeeds, so
- # only find the abs path if it can be found by shutil.which
- pkgbin = shutil.which(pkgbin)
if not self.silent:
if pkgbin:
- mlog.log('Found pkg-config:', mlog.bold(pkgbin),
+ mlog.log('Found pkg-config:', mlog.bold(pkgbin.get_path()),
'(%s)' % out.strip())
else:
mlog.log('Found Pkg-config:', mlog.red('NO'))