diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-11-29 10:23:57 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-12-03 10:06:11 +0530 |
commit | 390f0b8b522a7c73880349a250400a2802927b66 (patch) | |
tree | 447ba82ec439b6761d88236d5ce0f1cc77865ba4 /mesonbuild | |
parent | 554b484468c74621168f7bb7faf7110e7e72ebd5 (diff) | |
download | meson-390f0b8b522a7c73880349a250400a2802927b66.zip meson-390f0b8b522a7c73880349a250400a2802927b66.tar.gz meson-390f0b8b522a7c73880349a250400a2802927b66.tar.bz2 |
dependencies: Convert /c/foo/bar paths to C:/foo/bar
MSVC cannot handle MinGW-esque /c/foo paths, convert them to C:/foo.
We cannot resolve other paths starting with / like /home/foo so leave
them as-is so the user gets an error/warning from the compiler/linker.
These paths are commonly found in pkg-config files generated using
Autotools inside MinGW/MSYS and MinGW/MSYS2 environments.
Currently this is only done for PkgConfigDependency.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/dependencies/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index a720232..81b93c4 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -22,6 +22,7 @@ import shlex import shutil import textwrap from enum import Enum +from pathlib import PurePath from .. import mlog from .. import mesonlib @@ -424,6 +425,20 @@ class PkgConfigDependency(ExternalDependency): self.link_args = [] libpaths = [] for lib in shlex.split(out): + # MSVC cannot handle MinGW-esque /c/foo paths, convert them to C:/foo. + # We cannot resolve other paths starting with / like /home/foo so leave + # them as-is so the user gets an error/warning from the compiler/linker. + if self.compiler.id == 'msvc': + # Library search path + if lib.startswith('-L/'): + pargs = PurePath(lib[2:]).parts + if len(pargs) > 1 and len(pargs[1]) == 1: + lib = '-L{}:/{}'.format(pargs[1], '/'.join(pargs[2:])) + # Full path to library or .la file + elif lib.startswith('/'): + pargs = PurePath(lib).parts + if len(pargs) > 1 and len(pargs[1]) == 1: + lib = '{}:/{}'.format(pargs[1], '/'.join(pargs[2:])) # 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 # with -lfoo or foo.lib. However, we can only do this if we already |