aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-03-17 20:55:19 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-03-17 20:55:19 +0200
commit8b6848ebc3e146427bdf501208bd5ecb57316dc4 (patch)
treec604d340ae96c8d48d66204f38d4bc4836a4ccd2 /mesonbuild/interpreter.py
parenta3004652eaa8eef877ccf009e7a6ec8e32ad3475 (diff)
downloadmeson-8b6848ebc3e146427bdf501208bd5ecb57316dc4.zip
meson-8b6848ebc3e146427bdf501208bd5ecb57316dc4.tar.gz
meson-8b6848ebc3e146427bdf501208bd5ecb57316dc4.tar.bz2
Add dir support for find_library and remove deprecated standalone version. Closes #450.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py47
1 files changed, 9 insertions, 38 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 2ade18a..35cbc3e 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -27,8 +27,6 @@ from functools import wraps
import importlib
-find_lib_deprecation_printed = False
-
class InterpreterException(coredata.MesonException):
pass
@@ -762,8 +760,14 @@ class CompilerHolder(InterpreterObject):
required = kwargs.get('required', True)
if not isinstance(required, bool):
raise InterpreterException('required must be boolean.')
- linkarg = self.compiler.find_library(libname)
- lib = dependencies.ExternalLibrary(libname, linkarg)
+ search_dirs = kwargs.get('dirs', [])
+ for i in search_dirs:
+ if not os.path.isabs(i):
+ raise InvalidCode('Search directory %s is not an absolute path.' % i)
+ linkargs = self.compiler.find_library(libname, search_dirs)
+ if required and linkargs is None:
+ raise InterpreterException('Library %s not found'.format(libname))
+ lib = dependencies.ExternalLibrary(libname, linkargs)
return ExternalLibraryHolder(lib)
class ModuleState:
@@ -1542,40 +1546,7 @@ class Interpreter():
return progobj
def func_find_library(self, node, args, kwargs):
- global find_lib_deprecation_printed
- if not find_lib_deprecation_printed:
- find_lib_deprecation_printed = True
- mlog.log(mlog.red('DEPRECATION:'), 'find_library() is deprecated, use the corresponding method in compiler object instead.')
- self.validate_arguments(args, 1, [str])
- required = kwargs.get('required', True)
- if not isinstance(required, bool):
- raise InvalidArguments('"required" argument must be a boolean.')
- libname = args[0]
- # We do not cache found libraries because they can come
- # and go between invocations wildly. As an example we
- # may find the 64 bit version but need instead the 32 bit
- # one that is not installed. If we cache the found path
- # then we will never found the new one if it get installed.
- # This causes a bit of a slowdown as libraries are rechecked
- # on every regen, but since it is a fast operation it should be
- # ok.
- 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)
- if required and not libobj.found():
- raise InvalidArguments('External library "%s" not found.' % libname)
- return libobj
+ mlog.log(mlog.red('DEPRECATION:'), 'find_library() is removed, use the corresponding method in compiler object instead.')
def func_dependency(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])