From 91caf7aa56ba622926f7056d4a42083a75c24e5a Mon Sep 17 00:00:00 2001 From: U2FsdGVkX1 Date: Sun, 4 Feb 2024 14:07:54 +0800 Subject: [PATCH 1/2] Fix ninja cannot find the library when libraries contain symlinks. --- mesonbuild/compilers/mixins/gnu.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 9c0c3f290531..ef7f120f8956 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -469,16 +469,13 @@ def _split_fetch_real_dirs(self, pathstr: str) -> T.List[str]: # paths under /lib would be considered not a "system path", # which is wrong and breaks things. Store everything, just to be sure. pobj = pathlib.Path(p) - unresolved = pobj.as_posix() if pobj.exists(): + resolved = pobj.resolve().as_posix() + if resolved not in result: + result.append(resolved) + unresolved = pobj.as_posix() if unresolved not in result: result.append(unresolved) - try: - resolved = pathlib.Path(p).resolve().as_posix() - if resolved not in result: - result.append(resolved) - except FileNotFoundError: - pass return result def get_compiler_dirs(self, env: 'Environment', name: str) -> T.List[str]: From 7a60218dcaf0e11694ff1cb0531168fe576dc390 Mon Sep 17 00:00:00 2001 From: U2FsdGVkX1 Date: Mon, 5 Feb 2024 17:24:21 +0800 Subject: [PATCH 2/2] Turn on strict mode, as it is no longer the default since Python 3.6 --- mesonbuild/compilers/mixins/gnu.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index ef7f120f8956..79f271607434 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -470,9 +470,12 @@ def _split_fetch_real_dirs(self, pathstr: str) -> T.List[str]: # which is wrong and breaks things. Store everything, just to be sure. pobj = pathlib.Path(p) if pobj.exists(): - resolved = pobj.resolve().as_posix() - if resolved not in result: - result.append(resolved) + try: + resolved = pobj.resolve(True).as_posix() + if resolved not in result: + result.append(resolved) + except FileNotFoundError: + pass unresolved = pobj.as_posix() if unresolved not in result: result.append(unresolved)