aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-07-19 14:22:32 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-07-19 14:22:32 +0300
commitf90d3c19fd00fe62c1b815357f76a5891f338ea4 (patch)
tree401ecc65ce49d36075b8e9148ea0e753ed64ab22
parentc1fc55e6f6acf8289e673301be2c474e946ce305 (diff)
downloadmeson-useargsintests.zip
meson-useargsintests.tar.gz
meson-useargsintests.tar.bz2
Use option args in find_library.useargsintests
-rw-r--r--mesonbuild/compilers/c.py18
-rw-r--r--mesonbuild/compilers/fortran.py4
-rw-r--r--mesonbuild/compilers/vala.py2
-rw-r--r--mesonbuild/dependencies/base.py2
-rw-r--r--mesonbuild/dependencies/boost.py4
-rw-r--r--mesonbuild/dependencies/dev.py6
-rw-r--r--mesonbuild/interpreter.py3
-rw-r--r--mesonbuild/modules/python.py2
-rwxr-xr-xrun_unittests.py2
9 files changed, 23 insertions, 20 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index af3e2c4..aae98cb 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -898,12 +898,14 @@ class CCompiler(Compiler):
return f
return None
- def find_library_real(self, libname, env, extra_dirs, code, libtype):
+ def find_library_real(self, libname, env, extra_dirs, code, extra_args, libtype):
+ if not isinstance(extra_args, list):
+ extra_args = [extra_args]
# First try if we can just add the library as -l.
# Gcc + co seem to prefer builtin lib dirs to -L dirs.
# Only try to find std libs if no extra dirs specified.
if not extra_dirs:
- args = ['-l' + libname]
+ args = extra_args + ['-l' + libname]
if self.links(code, env, extra_args=args):
return args
# Not found or we want to use a specific libtype? Try to find the
@@ -936,19 +938,19 @@ class CCompiler(Compiler):
# symbols from the main C file.
extra_link_args = self.get_link_whole_for([trial])
extra_link_args = self.linker_to_compiler_args(extra_link_args)
- if self.links(code, env, extra_args=extra_link_args):
+ if self.links(code, env, extra_args=(extra_args + extra_link_args)):
return [trial]
return None
- def find_library_impl(self, libname, env, extra_dirs, code, libtype):
+ def find_library_impl(self, libname, env, extra_dirs, code, extra_args, libtype):
# These libraries are either built-in or invalid
if libname in self.ignore_libs:
return []
if isinstance(extra_dirs, str):
extra_dirs = [extra_dirs]
- key = (tuple(self.exelist), libname, tuple(extra_dirs), code, libtype)
+ key = (tuple(self.exelist), libname, tuple(extra_dirs), code, tuple(extra_args), libtype)
if key not in self.find_library_cache:
- value = self.find_library_real(libname, env, extra_dirs, code, libtype)
+ value = self.find_library_real(libname, env, extra_dirs, code, extra_args, libtype)
self.find_library_cache[key] = value
else:
value = self.find_library_cache[key]
@@ -956,9 +958,9 @@ class CCompiler(Compiler):
return None
return value[:]
- def find_library(self, libname, env, extra_dirs, libtype='default'):
+ def find_library(self, libname, env, extra_dirs, extra_args, libtype='default'):
code = 'int main(int argc, char **argv) { return 0; }'
- return self.find_library_impl(libname, env, extra_dirs, code, libtype)
+ return self.find_library_impl(libname, env, extra_dirs, code, extra_args, libtype)
def thread_flags(self, env):
if for_haiku(self.is_cross, env):
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index d6e41e3..3d24419 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -185,11 +185,11 @@ class FortranCompiler(Compiler):
def find_library_impl(self, *args):
return CCompiler.find_library_impl(self, *args)
- def find_library(self, libname, env, extra_dirs, libtype='default'):
+ def find_library(self, libname, env, extra_dirs, extra_args, libtype='default'):
code = '''program main
call exit(0)
end program main'''
- return self.find_library_impl(libname, env, extra_dirs, code, libtype)
+ return self.find_library_impl(libname, env, extra_dirs, code, extra_args, libtype)
def thread_flags(self, env):
return CCompiler.thread_flags(self, env)
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py
index 6194d1a..ca621b7 100644
--- a/mesonbuild/compilers/vala.py
+++ b/mesonbuild/compilers/vala.py
@@ -74,7 +74,7 @@ class ValaCompiler(Compiler):
return ['--debug']
return []
- def find_library(self, libname, env, extra_dirs):
+ def find_library(self, libname, env, extra_dirs, extra_args):
if extra_dirs and isinstance(extra_dirs, str):
extra_dirs = [extra_dirs]
# Valac always looks in the default vapi dir, so only search there if
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 0fe702f..dc1498a 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -634,7 +634,7 @@ class PkgConfigDependency(ExternalDependency):
continue
if self.clib_compiler:
args = self.clib_compiler.find_library(lib[2:], self.env,
- list(libpaths), libtype)
+ list(libpaths), [], libtype)
# If the project only uses a non-clib language such as D, Rust,
# C#, Python, etc, all we can do is limp along by adding the
# arguments as-is and then adding the libpaths at the end.
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 59d8070..126a9f7 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -352,7 +352,7 @@ class BoostDependency(ExternalDependency):
return None
def find_libraries_with_abi_tag(self, tag):
-
+ extra_args = []
# All modules should have the same tag
self.lib_modules = {}
@@ -361,7 +361,7 @@ class BoostDependency(ExternalDependency):
for module in self.requested_modules:
libname = 'boost_' + module + tag
- args = self.clib_compiler.find_library(libname, self.env, self.extra_lib_dirs())
+ args = self.clib_compiler.find_library(libname, self.env, self.extra_lib_dirs(), extra_args)
if args is None:
mlog.debug("Couldn\'t find library '{}' for boost module '{}' (ABI tag = '{}')".format(libname, module, tag))
all_found = False
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 4ea3385..9971aed 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -36,8 +36,8 @@ class GTestDependency(ExternalDependency):
def detect(self):
self.version = '1.something_maybe'
- gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
- gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, [])
+ gtest_detect = self.clib_compiler.find_library("gtest", self.env, [], [])
+ gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, [], [])
if gtest_detect and (not self.main or gtest_main_detect):
self.is_found = True
self.compile_args = []
@@ -83,7 +83,7 @@ class GMockDependency(ExternalDependency):
self.version = '1.something_maybe'
# GMock may be a library or just source.
# Work with both.
- gmock_detect = self.clib_compiler.find_library("gmock", self.env, [])
+ gmock_detect = self.clib_compiler.find_library("gmock", self.env, [], [])
if gmock_detect:
self.is_found = True
self.compile_args = []
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 1607904..9d19aac 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1443,7 +1443,8 @@ class CompilerHolder(InterpreterObject):
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, self.environment, search_dirs)
+ extra_args = self.determine_args(kwargs)
+ linkargs = self.compiler.find_library(libname, self.environment, search_dirs, extra_args)
if required and not linkargs:
raise InterpreterException('{} library {!r} not found'.format(self.compiler.get_display_language(), libname))
lib = dependencies.ExternalLibrary(libname, linkargs, self.environment,
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 9a90fe9..f821711 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -123,7 +123,7 @@ class PythonDependency(ExternalDependency):
libname += self.variables['ABIFLAGS']
libdirs = []
- largs = self.clib_compiler.find_library(libname, environment, libdirs)
+ largs = self.clib_compiler.find_library(libname, environment, libdirs, [])
self.is_found = largs is not None
diff --git a/run_unittests.py b/run_unittests.py
index dd109aa..f07bccd 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -542,7 +542,7 @@ class InternalTests(unittest.TestCase):
f.write('')
with open(os.path.join(tmpdir, 'libfoo.so.70.0.so.1'), 'w') as f:
f.write('')
- found = cc.find_library_real('foo', env, [tmpdir], '', 'default')
+ found = cc.find_library_real('foo', env, [tmpdir], '', [], 'default')
self.assertEqual(os.path.basename(found[0]), 'libfoo.so.54.0')
def test_find_library_patterns(self):