From 30854e14fe2d038ab0cfd0f91131883699493d2e Mon Sep 17 00:00:00 2001 From: Niklas Claesson Date: Fri, 9 Feb 2018 21:18:53 +0100 Subject: [PATCH] Only remove substring if it is part of string Fixes #2661 --- mesonbuild/backend/backends.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 3f1e4ced7..b25382486 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -323,9 +323,12 @@ class Backend: if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']: continue absdir = os.path.split(libpath)[0] - rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] - assert(not os.path.isabs(rel_to_src)) - paths.append(os.path.join(self.build_to_src, rel_to_src)) + if absdir.startswith(self.environment.get_source_dir()): + rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] + assert not os.path.isabs(rel_to_src), 'rel_to_src: {} is absolute'.format(rel_to_src) + paths.append(os.path.join(self.build_to_src, rel_to_src)) + else: + paths.append(absdir) return paths def determine_rpath_dirs(self, target):