From 7650f328284f24c2f70dcfb1689ae8fc22c04cf1 Mon Sep 17 00:00:00 2001 From: fghzxm Date: Mon, 9 May 2022 12:53:58 +0800 Subject: [PATCH] dependencies/boost.py: ignore unknown files If we encounter a file under the Boost library directory that doesn't look like a Boost library binary, we should ignore it. We log a warning for each file we ignore, except for ones we know are safe to ignore (e. g. PDB files from the SourceForge Windows distribution). This should avoid polluting the log. Fixes #8325. --- mesonbuild/dependencies/boost.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 544e844f2..8c552f521 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -13,6 +13,7 @@ # limitations under the License. import re +import dataclasses import functools import typing as T from pathlib import Path @@ -83,6 +84,10 @@ if T.TYPE_CHECKING: # 2.4 Ensure that all libraries have the same boost tag (and are thus compatible) # 3. Select the libraries matching the requested modules +@dataclasses.dataclass(eq=False, order=False) +class UnknownFileException(Exception): + path: Path + @functools.total_ordering class BoostIncludeDir(): def __init__(self, path: Path, version_int: int): @@ -152,7 +157,7 @@ class BoostLibraryFile(): elif self.nvsuffix in ['a', 'lib']: self.static = True else: - raise DependencyException(f'Unable to process library extension "{self.nvsuffix}" ({self.path})') + raise UnknownFileException(self.path) # boost_.lib is the dll import library if self.basename.startswith('boost_') and self.nvsuffix == 'lib': @@ -623,8 +628,15 @@ class BoostDependency(SystemDependency): continue if not any([i.name.startswith(x) for x in ['libboost_', 'boost_']]): continue + # Windows binaries from SourceForge ship with PDB files alongside + # DLLs (#8325). Ignore them. + if i.name.endswith('.pdb'): + continue - libs.add(BoostLibraryFile(i.resolve())) + try: + libs.add(BoostLibraryFile(i.resolve())) + except UnknownFileException as e: + mlog.warning('Boost: ignoring unknown file {} under lib directory'.format(e.path.name)) return [x for x in libs if x.is_boost()] # Filter out no boost libraries