Skip to content

Commit

Permalink
pkgconfig: Fix code that make relative path
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
xclaesse committed Feb 5, 2020
1 parent 302b486 commit b3ab022
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mesonbuild/modules/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@ def _make_relative(self, prefix, subdir):
prefix = prefix.as_posix()
if isinstance(subdir, PurePath):
subdir = subdir.as_posix()
if subdir.startswith(prefix):
subdir = subdir.replace(prefix, '')
try:
if os.path.commonpath([prefix, subdir]) == prefix:
skip = len(prefix) + 1
subdir = subdir[skip:]
except ValueError:
pass
return subdir

def generate_pkgconfig_file(self, state, deps, subdirs, name, description,
Expand Down

0 comments on commit b3ab022

Please sign in to comment.