From d83de3ee56beb0df45086275b35d55f423071581 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 17 May 2015 00:58:38 +0300 Subject: [PATCH] Can specify custom search directories in find_library. --- environment.py | 5 +++-- interpreter.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/environment.py b/environment.py index 08256c4aa..b58af2a69 100644 --- a/environment.py +++ b/environment.py @@ -547,8 +547,9 @@ class Environment(): def get_datadir(self): return self.coredata.datadir - def find_library(self, libname): - dirs = mesonlib.get_library_dirs() + def find_library(self, libname, dirs): + if dirs is None: + dirs = mesonlib.get_library_dirs() suffixes = [self.get_shared_lib_suffix(), self.get_static_lib_suffix()] prefix = self.get_shared_lib_prefix() for d in dirs: diff --git a/interpreter.py b/interpreter.py index 2aae94459..e8bfecfaf 100644 --- a/interpreter.py +++ b/interpreter.py @@ -1228,7 +1228,18 @@ class Interpreter(): if libname in self.coredata.ext_libs and\ self.coredata.ext_libs[libname].found(): return ExternalLibraryHolder(self.coredata.ext_libs[libname]) - result = self.environment.find_library(libname) + if 'dirs' in kwargs: + search_dirs = kwargs['dirs'] + if not isinstance(search_dirs, list): + search_dirs = [search_dirs] + for i in search_dirs: + if not isinstance(i, str): + raise InvalidCode('Directory entry is not a string.') + if not os.path.isabs(i): + raise InvalidCode('Search directory %s is not an absolute path.' % i) + else: + search_dirs = None + result = self.environment.find_library(libname, search_dirs) extlib = dependencies.ExternalLibrary(libname, result) libobj = ExternalLibraryHolder(extlib) self.coredata.ext_libs[libname] = extlib