aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-10 04:27:23 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-10 12:42:52 -0700
commit47c68a59938c927b3879ecc0e237c2af0156e35a (patch)
tree3a994053ee4ad8d105236e0274380f3a78fbe7dd /mesonbuild/compilers/c.py
parent09ad29ec560f2a05108694d909de30b5e3e58357 (diff)
downloadmeson-47c68a59938c927b3879ecc0e237c2af0156e35a.zip
meson-47c68a59938c927b3879ecc0e237c2af0156e35a.tar.gz
meson-47c68a59938c927b3879ecc0e237c2af0156e35a.tar.bz2
find_library: Validate and sort globbed shared library files
We need to pick the library with the highest version, which is what the OpenBSD linker also does. https://github.com/mesonbuild/meson/issues/3570#issuecomment-403638752
Diffstat (limited to 'mesonbuild/compilers/c.py')
-rw-r--r--mesonbuild/compilers/c.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index b62155b..af3e2c4 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -866,12 +866,29 @@ class CCompiler(Compiler):
return patterns
@staticmethod
- def _get_trials_from_pattern(pattern, directory, libname):
+ def _sort_shlibs_openbsd(libs):
+ filtered = []
+ for lib in libs:
+ # Validate file as a shared library of type libfoo.so.X.Y
+ ret = lib.rsplit('.so.', maxsplit=1)
+ if len(ret) != 2:
+ continue
+ try:
+ float(ret[1])
+ except ValueError:
+ continue
+ filtered.append(lib)
+ float_cmp = lambda x: float(x.rsplit('.so.', maxsplit=1)[1])
+ return sorted(filtered, key=float_cmp, reverse=True)
+
+ @classmethod
+ def _get_trials_from_pattern(cls, pattern, directory, libname):
f = os.path.join(directory, pattern.format(libname))
+ # Globbing for OpenBSD
if '*' in pattern:
# NOTE: globbing matches directories and broken symlinks
# so we have to do an isfile test on it later
- return glob.glob(f)
+ return cls._sort_shlibs_openbsd(glob.glob(f))
return [f]
@staticmethod