diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-03-12 02:18:36 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-03-12 22:25:33 +0200 |
commit | 28b19c78d6f9e12f9fc0f79748adbfed613eafc9 (patch) | |
tree | 79bf82efcfd9e10956138dcb40cc950c5833539d | |
parent | 7bf29b8efdb1234e3a0ff68586821ee54f91903a (diff) | |
download | meson-28b19c78d6f9e12f9fc0f79748adbfed613eafc9.zip meson-28b19c78d6f9e12f9fc0f79748adbfed613eafc9.tar.gz meson-28b19c78d6f9e12f9fc0f79748adbfed613eafc9.tar.bz2 |
PkgConfigDependency: Search for pkg-config with ExternalProgram
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.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index b6d1983..0375102 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')) |