aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Meagher <11620178+kjmeagher@users.noreply.github.com>2021-07-16 08:38:59 -0500
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-08-04 19:29:05 +0200
commit3c3fa0a12c68da8966410ad9bacd1148dc8bd65d (patch)
treee50359c868cbe1f5dec3dbf9287eb9b83b87f5c2
parentf781c30700923359a8dd17849bd00faaf9360719 (diff)
downloadmeson-3c3fa0a12c68da8966410ad9bacd1148dc8bd65d.zip
meson-3c3fa0a12c68da8966410ad9bacd1148dc8bd65d.tar.gz
meson-3c3fa0a12c68da8966410ad9bacd1148dc8bd65d.tar.bz2
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
-rw-r--r--mesonbuild/dependencies/boost.py44
1 files changed, 21 insertions, 23 deletions
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 26ec6fd..5935b61 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/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
- 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 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))
+
+ 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 = ''