From 7ce29e1eda0425205770b9952aa476126d73e7d2 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Wed, 28 Oct 2020 11:19:50 -0500 Subject: [PATCH] Relax restrictions on detecting boost dependency This does two things: * allows the library files to be symlinks * searches `lib` and `lib64` in `BOOST_ROOT` even if it finds lib directories from the compiler The first condition is needed for the homebrew on macOS because boost and boost python are provided in seperate packages and are put together in /usr/local/lib with symlinks to the library files. The both conditions are needed for high performace computing environments where dependencies are often provided in nonstandard directories with symlinks A test case was added which looks for boost libraries in seperate directories which have been symlinked to BOOST_ROOT/lib --- mesonbuild/dependencies/boost.py | 20 +++++++++---------- .../lib/boost_python-vc142-mt-gd-x32-0_3.lib | 0 .../lib/boost_python-vc142-mt-gd-x64-0_3.lib | 0 .../0.3.0/lib/libboost_python.so.0.3.0 | 0 .../boost/0.3.0/include/boost/version.hpp | 3 +++ .../lib/boost_regex-vc142-mt-gd-x32-0_3.lib | 0 .../lib/boost_regex-vc142-mt-gd-x64-0_3.lib | 0 .../boost/0.3.0/lib/libboost_regex.so.0.3.0 | 0 .../35 boost symlinks/boost/include/boost | 1 + .../lib/boost_python-vc142-mt-gd-x32-0_3.lib | 1 + .../lib/boost_python-vc142-mt-gd-x64-0_3.lib | 1 + .../lib/boost_regex-vc142-mt-gd-x32-0_3.lib | 1 + .../lib/boost_regex-vc142-mt-gd-x64-0_3.lib | 1 + .../boost/lib/libboost_python.so.0.3.0 | 1 + .../boost/lib/libboost_regex.so.0.3.0 | 1 + .../frameworks/35 boost symlinks/meson.build | 6 ++++++ .../35 boost symlinks/nativefile.ini.in | 2 ++ 17 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x32-0_3.lib create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x64-0_3.lib create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/libboost_python.so.0.3.0 create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/include/boost/version.hpp create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x32-0_3.lib create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x64-0_3.lib create mode 100644 test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/libboost_regex.so.0.3.0 create mode 120000 test cases/frameworks/35 boost symlinks/boost/include/boost create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x32-0_3.lib create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x64-0_3.lib create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x32-0_3.lib create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x64-0_3.lib create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/libboost_python.so.0.3.0 create mode 120000 test cases/frameworks/35 boost symlinks/boost/lib/libboost_regex.so.0.3.0 create mode 100644 test cases/frameworks/35 boost symlinks/meson.build create mode 100644 test cases/frameworks/35 boost symlinks/nativefile.ini.in diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 4e5af907e..6b594f892 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -541,11 +541,7 @@ class BoostDependency(SystemDependency): 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 + # In addition to the system include paths, also look in "lib" dirs = [] # type: T.List[Path] subdirs = [] # type: T.List[Path] for i in root.iterdir(): @@ -561,7 +557,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 dirs + subdirs + return system_dirs + dirs + subdirs arch_list_32 = ['32', 'i386'] arch_list_64 = ['64'] @@ -615,15 +611,19 @@ class BoostDependency(SystemDependency): return libs def detect_libraries(self, libdir: Path) -> T.List[BoostLibraryFile]: - libs = [] # type: T.List[BoostLibraryFile] + libs = [] # type: T.List[Path] for i in libdir.iterdir(): - if not i.is_file() or i.is_symlink(): + if not i.is_file(): continue if not any([i.name.startswith(x) for x in ['libboost_', 'boost_']]): continue - libs += [BoostLibraryFile(i)] - return [x for x in libs if x.is_boost()] # Filter out no boost libraries + libs += [i.resolve()] + + # Remove duplicate libraries caused by resolving symlinks + blibs = [BoostLibraryFile(i) for i in set(libs)] # type: T.List[BoostLibraryFile] + + return [x for x in blibs 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 diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x32-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x32-0_3.lib new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x64-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x64-0_3.lib new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/libboost_python.so.0.3.0 b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost-python/0.3.0/lib/libboost_python.so.0.3.0 new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/include/boost/version.hpp b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/include/boost/version.hpp new file mode 100644 index 000000000..77d994846 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/include/boost/version.hpp @@ -0,0 +1,3 @@ +#define BOOST_VERSION 300 + +#error This is not a real version of boost diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x32-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x32-0_3.lib new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x64-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x64-0_3.lib new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/libboost_regex.so.0.3.0 b/test cases/frameworks/35 boost symlinks/boost/Cellar/boost/0.3.0/lib/libboost_regex.so.0.3.0 new file mode 100644 index 000000000..e69de29bb diff --git a/test cases/frameworks/35 boost symlinks/boost/include/boost b/test cases/frameworks/35 boost symlinks/boost/include/boost new file mode 120000 index 000000000..8acd7e291 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/include/boost @@ -0,0 +1 @@ +../Cellar/boost/0.3.0/include/boost \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x32-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x32-0_3.lib new file mode 120000 index 000000000..7ba5b3da0 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x32-0_3.lib @@ -0,0 +1 @@ +../Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x32-0_3.lib \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x64-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x64-0_3.lib new file mode 120000 index 000000000..f4585ab35 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/boost_python-vc142-mt-gd-x64-0_3.lib @@ -0,0 +1 @@ +../Cellar/boost-python/0.3.0/lib/boost_python-vc142-mt-gd-x64-0_3.lib \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x32-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x32-0_3.lib new file mode 120000 index 000000000..eb7204d84 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x32-0_3.lib @@ -0,0 +1 @@ +../Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x32-0_3.lib \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x64-0_3.lib b/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x64-0_3.lib new file mode 120000 index 000000000..fb4fc1446 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/boost_regex-vc142-mt-gd-x64-0_3.lib @@ -0,0 +1 @@ +../Cellar/boost/0.3.0/lib/boost_regex-vc142-mt-gd-x64-0_3.lib \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/libboost_python.so.0.3.0 b/test cases/frameworks/35 boost symlinks/boost/lib/libboost_python.so.0.3.0 new file mode 120000 index 000000000..f75f655be --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/libboost_python.so.0.3.0 @@ -0,0 +1 @@ +../Cellar/boost-python/0.3.0/lib/libboost_python.so.0.3.0 \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/boost/lib/libboost_regex.so.0.3.0 b/test cases/frameworks/35 boost symlinks/boost/lib/libboost_regex.so.0.3.0 new file mode 120000 index 000000000..d248bc77e --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/boost/lib/libboost_regex.so.0.3.0 @@ -0,0 +1 @@ +../Cellar/boost/0.3.0/lib/libboost_regex.so.0.3.0 \ No newline at end of file diff --git a/test cases/frameworks/35 boost symlinks/meson.build b/test cases/frameworks/35 boost symlinks/meson.build new file mode 100644 index 000000000..b49a143ef --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/meson.build @@ -0,0 +1,6 @@ +project('boosttestsymlinks', 'cpp') + +dep = dependency('boost', modules : ['regex', 'python'], required: false) + +assert(dep.found(), 'expected to find a fake version of boost') +assert(dep.version() == '0.3.0', 'expected to find version 0.3.0') diff --git a/test cases/frameworks/35 boost symlinks/nativefile.ini.in b/test cases/frameworks/35 boost symlinks/nativefile.ini.in new file mode 100644 index 000000000..54510d7e0 --- /dev/null +++ b/test cases/frameworks/35 boost symlinks/nativefile.ini.in @@ -0,0 +1,2 @@ +[properties] +boost_root = '@MESON_TEST_ROOT@/boost'