add boolean parameter use_system for searching boost

This boolean parameter is added to check_and_set_roots() and detect_lib_dirs()
when true it will first search the compiler library directories before checking
the standard lib directories. This is set to false when using BOOST_ROOT and
set to true when useing other system directories like /usr/local

Also simplify using a set to remove duplicate lib files

Also remove the part where you search the Cellar in homebrew, this is
unnescessary now that symlinks can be followed it should find boost
when searching /usr/local so no need to search the Cellar
pull/9063/head
Kevin Meagher 3 years ago committed by Daniel Mensinger
parent f781c30700
commit 3c3fa0a12c
  1. 34
      mesonbuild/dependencies/boost.py

@ -382,7 +382,7 @@ class BoostDependency(SystemDependency):
# Finally, look for paths from .pc files and from searching the filesystem
self.detect_roots()
def check_and_set_roots(self, roots: T.List[Path]) -> None:
def check_and_set_roots(self, roots: T.List[Path], use_system: bool) -> None:
roots = list(mesonlib.OrderedSet(roots))
for j in roots:
# 1. Look for the boost headers (boost/version.hpp)
@ -394,7 +394,7 @@ class BoostDependency(SystemDependency):
if not inc_dirs:
continue
lib_dirs = self.detect_lib_dirs(j)
lib_dirs = self.detect_lib_dirs(j, use_system)
self.is_found = self.run_check(inc_dirs, lib_dirs)
if self.is_found:
self.boost_root = j
@ -436,7 +436,7 @@ class BoostDependency(SystemDependency):
if paths and any([not x.is_absolute() for x in paths]):
raise DependencyException('boost_root path given in machine file must be absolute')
self.check_and_set_roots(paths)
self.check_and_set_roots(paths, use_system=False)
def run_check(self, inc_dirs: T.List[BoostIncludeDir], lib_dirs: T.List[Path]) -> bool:
mlog.debug(' - potential library dirs: {}'.format([x.as_posix() for x in lib_dirs]))
@ -532,16 +532,22 @@ class BoostDependency(SystemDependency):
candidates = [x for x in candidates if x.exists()]
return [self._include_dir_from_version_header(x) for x in candidates]
def detect_lib_dirs(self, root: Path) -> T.List[Path]:
def detect_lib_dirs(self, root: Path, use_system: bool) -> T.List[Path]:
# First check the system include paths. Only consider those within the
# given root path
if use_system:
system_dirs_t = self.clib_compiler.get_library_dirs(self.env)
system_dirs = [Path(x) for x in system_dirs_t]
system_dirs = [x.resolve() for x in system_dirs if x.exists()]
system_dirs = [x for x in system_dirs if mesonlib.path_is_in_root(x, root)]
system_dirs = list(mesonlib.OrderedSet(system_dirs))
# In addition to the system include paths, also look in "lib"
if system_dirs:
return system_dirs
# No system include paths were found --> fall back to manually looking
# for library dirs in root
dirs = [] # type: T.List[Path]
subdirs = [] # type: T.List[Path]
for i in root.iterdir():
@ -557,7 +563,7 @@ class BoostDependency(SystemDependency):
# Filter out paths that don't match the target arch to avoid finding
# the wrong libraries. See https://github.com/mesonbuild/meson/issues/7110
if not self.arch:
return system_dirs + dirs + subdirs
return dirs + subdirs
arch_list_32 = ['32', 'i386']
arch_list_64 = ['64']
@ -611,19 +617,16 @@ class BoostDependency(SystemDependency):
return libs
def detect_libraries(self, libdir: Path) -> T.List[BoostLibraryFile]:
libs = set() # type: T.Set[Path]
libs = set() # type: T.Set[BoostLibraryFile]
for i in libdir.iterdir():
if not i.is_file():
continue
if not any([i.name.startswith(x) for x in ['libboost_', 'boost_']]):
continue
libs.add(i.resolve())
libs.add(BoostLibraryFile(i.resolve()))
# Remove duplicate libraries caused by resolving symlinks
blibs = [BoostLibraryFile(i) for i in libs] # type: T.List[BoostLibraryFile]
return [x for x in blibs if x.is_boost()] # Filter out no boost libraries
return [x for x in libs if x.is_boost()] # Filter out no boost libraries
def detect_split_root(self, inc_dir: Path, lib_dir: Path) -> None:
boost_inc_dir = None
@ -679,11 +682,6 @@ class BoostDependency(SystemDependency):
else:
tmp = [] # type: T.List[Path]
# Homebrew
brew_boost = Path('/usr/local/Cellar/boost')
if brew_boost.is_dir():
tmp += [x for x in brew_boost.iterdir()]
# Add some default system paths
tmp += [Path('/opt/local')]
tmp += [Path('/usr/local/opt/boost')]
@ -695,7 +693,7 @@ class BoostDependency(SystemDependency):
tmp = [x.resolve() for x in tmp]
roots += tmp
self.check_and_set_roots(roots)
self.check_and_set_roots(roots, use_system=True)
def log_details(self) -> str:
res = ''

Loading…
Cancel
Save