diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-10-03 15:25:25 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-10-03 17:56:47 +0200 |
commit | 8103af1d76883dd2091afe7a5043a81571ba1bd0 (patch) | |
tree | 4f49ba4fd0ebbabe62bb65daff959f3fe9908630 | |
parent | 8d3fcb3dc4d7204a4646807f8b5191d79fb291e5 (diff) | |
download | meson-8103af1d76883dd2091afe7a5043a81571ba1bd0.zip meson-8103af1d76883dd2091afe7a5043a81571ba1bd0.tar.gz meson-8103af1d76883dd2091afe7a5043a81571ba1bd0.tar.bz2 |
cmake: fix detection of libraries with .so version
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 24 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 773e2ec..3e94933 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -22,7 +22,7 @@ from .traceparser import CMakeTraceParser, CMakeGeneratorTarget from .. import mlog from ..environment import Environment from ..mesonlib import MachineChoice -from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, is_header +from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header from subprocess import Popen, PIPE from typing import Any, List, Dict, Optional, TYPE_CHECKING from threading import Thread @@ -117,6 +117,7 @@ def _generated_file_key(fname: str) -> str: class ConverterTarget: lang_cmake_to_meson = {val.lower(): key for key, val in language_map.items()} + rm_so_version = re.compile(r'(\.[0-9]+)+$') def __init__(self, target: CMakeTarget, env: Environment): self.env = env @@ -211,15 +212,30 @@ class ConverterTarget: mlog.warning('CMake: Target', mlog.bold(self.name), 'not found in CMake trace. This can lead to build errors') # Fix link libraries + def try_resolve_link_with(path: str) -> Optional[str]: + basename = os.path.basename(path) + candidates = [basename, ConverterTarget.rm_so_version.sub('', basename)] + for i in lib_suffixes: + if not basename.endswith('.' + i): + continue + new_basename = basename[:-len(i) - 1] + new_basename = ConverterTarget.rm_so_version.sub('', new_basename) + new_basename = '{}.{}'.format(new_basename, i) + candidates += [new_basename] + for i in candidates: + if i in output_target_map: + return output_target_map[i] + return None + temp = [] for i in self.link_libraries: # Let meson handle this arcane magic if ',-rpath,' in i: continue if not os.path.isabs(i): - basename = os.path.basename(i) - if basename in output_target_map: - self.link_with += [output_target_map[basename]] + link_with = try_resolve_link_with(i) + if link_with: + self.link_with += [link_with] continue temp += [i] diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 2c9508b..b79fa41 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -39,7 +39,7 @@ Also add corresponding autodetection code in environment.py.""" header_suffixes = ('h', 'hh', 'hpp', 'hxx', 'H', 'ipp', 'moc', 'vapi', 'di') obj_suffixes = ('o', 'obj', 'res') -lib_suffixes = ('a', 'lib', 'dll', 'dylib', 'so') +lib_suffixes = ('a', 'lib', 'dll', 'dll.a', 'dylib', 'so') # Mapping of language to suffixes of files that should always be in that language # This means we can't include .h headers here since they could be C, C++, ObjC, etc. lang_suffixes = { |