[pypy-commit] pypy default: Be more explicit about cases where pkg-config is not installed
arigo
noreply at buildbot.pypy.org
Mon Oct 20 13:38:10 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r74016:bd51c131833c
Date: 2014-10-20 13:37 +0200
http://bitbucket.org/pypy/pypy/changeset/bd51c131833c/
Log: Be more explicit about cases where pkg-config is not installed
diff --git a/rpython/translator/platform/linux.py b/rpython/translator/platform/linux.py
--- a/rpython/translator/platform/linux.py
+++ b/rpython/translator/platform/linux.py
@@ -26,11 +26,13 @@
def _include_dirs_for_libffi(self):
return self._pkg_config("libffi", "--cflags-only-I",
- ['/usr/include/libffi'])
+ ['/usr/include/libffi'],
+ check_result_dir=True)
def _library_dirs_for_libffi(self):
return self._pkg_config("libffi", "--libs-only-L",
- ['/usr/lib/libffi'])
+ ['/usr/lib/libffi'],
+ check_result_dir=True)
class Linux(BaseLinux):
diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -74,15 +74,36 @@
cwd=str(exe_name.dirpath()))
return exe_name
- def _pkg_config(self, lib, opt, default):
+ def _pkg_config(self, lib, opt, default, check_result_dir=False):
try:
ret, out, err = _run_subprocess("pkg-config", [lib, opt])
- except OSError:
+ except OSError, e:
+ err = str(e)
ret = 1
if ret:
- return default
- # strip compiler flags
- return [entry[2:] for entry in out.split()]
+ result = default
+ else:
+ # strip compiler flags
+ result = [entry[2:] for entry in out.split()]
+ #
+ if not result:
+ pass # if pkg-config explicitly returned nothing, then
+ # we assume it means no options are needed
+ elif check_result_dir:
+ # check that at least one of the results is a valid dir
+ for check in result:
+ if os.path.isdir(check):
+ break
+ else:
+ if ret:
+ msg = ("running 'pkg-config %s %s' failed:\n%s\n"
+ "and the default %r is not a valid directory" % (
+ lib, opt, err.rstrip(), default))
+ else:
+ msg = ("'pkg-config %s %s' returned no valid directory:\n"
+ "%s\n%s" % (lib, opt, out.rstrip(), err.rstrip()))
+ raise ValueError(msg)
+ return result
def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
shared=False, headers_to_precompile=[],
More information about the pypy-commit
mailing list