pkgconfig: Fix code that make relative path

When subdir is '/foo/bar' and prefix '/foo' it was returning '/bar',
which is an absolute path. It was then constructing '-L${prefix}//bar'
with bogus double slash.

When subdir is '/fooo/bar' and prefix '/foo' it was returning 'o/bar'.
pull/6589/head
Xavier Claessens 5 years ago committed by Xavier Claessens
parent 302b486446
commit b3ab022777
  1. 8
      mesonbuild/modules/pkgconfig.py

@ -256,8 +256,12 @@ class PkgConfigModule(ExtensionModule):
prefix = prefix.as_posix() prefix = prefix.as_posix()
if isinstance(subdir, PurePath): if isinstance(subdir, PurePath):
subdir = subdir.as_posix() subdir = subdir.as_posix()
if subdir.startswith(prefix): try:
subdir = subdir.replace(prefix, '') if os.path.commonpath([prefix, subdir]) == prefix:
skip = len(prefix) + 1
subdir = subdir[skip:]
except ValueError:
pass
return subdir return subdir
def generate_pkgconfig_file(self, state, deps, subdirs, name, description, def generate_pkgconfig_file(self, state, deps, subdirs, name, description,

Loading…
Cancel
Save