aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-02-20 13:33:19 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-20 19:26:51 +0200
commit8842839bb4c8dadaba1808535928ede7527d5b53 (patch)
tree86c88bb459b0ad5327a1a364841f5cc47938c0bd /mesonbuild/dependencies
parent0c1c387703c04c8052161b7506c07f216329b232 (diff)
downloadmeson-8842839bb4c8dadaba1808535928ede7527d5b53.zip
meson-8842839bb4c8dadaba1808535928ede7527d5b53.tar.gz
meson-8842839bb4c8dadaba1808535928ede7527d5b53.tar.bz2
pkgconfig deps: Warn when a static library isn't found
A hard error makes this feature useless in most cases since a static library usually won't be found for every library, particularly system libraries like -lm. Instead, warn so the user can provide the static library if they wish. This feature will be expanded and made more extensible and more usable in the future. Closes https://github.com/mesonbuild/meson/issues/2785
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/base.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 66bc3b4..fefab3f 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -516,6 +516,7 @@ class PkgConfigDependency(ExternalDependency):
(self.name, out))
self.link_args = []
libpaths = []
+ static_libs_notfound = []
for lib in self._convert_mingw_paths(shlex.split(out)):
# If we want to use only static libraries, we have to look for the
# file ourselves instead of depending on the compiler to find it
@@ -524,13 +525,26 @@ class PkgConfigDependency(ExternalDependency):
if self.static:
if lib.startswith('-L'):
libpaths.append(lib[2:])
+ print(lib)
continue
+ # FIXME: try to handle .la files in static mode too?
elif lib.startswith('-l') and libpaths:
args = self.compiler.find_library(lib[2:], self.env, libpaths, libtype='static')
if not args or len(args) < 1:
- raise DependencyException('Static library not found for {!r}'
- ''.format(lib[2:]))
- lib = args[0]
+ if lib in static_libs_notfound:
+ continue
+ mlog.warning('Static library {!r} not found for dependency {!r}, may '
+ 'not be statically linked'.format(lib[2:], self.name))
+ static_libs_notfound.append(lib)
+ # Preserve the -l arg since we couldn't resolve it to
+ # a static library. Also need all previous -L args now.
+ for p in libpaths:
+ lp = '-L' + p
+ if lp not in self.link_args:
+ self.link_args.append(lp)
+ else:
+ # Replace -l arg with full path to static library
+ lib = args[0]
elif lib.endswith(".la"):
shared_libname = self.extract_libtool_shlib(lib)
shared_lib = os.path.join(os.path.dirname(lib), shared_libname)