aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-06-19 09:31:32 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-20 11:27:08 +0000
commitd73748815014b8b4bbbd7fe7fb8b50b8a75aecfc (patch)
treedc535b92cd6f496fbc6cb4153fad7449f286d45a /mesonbuild/dependencies/base.py
parentebda6ef9c801278bd15a6499c80fff26071feded (diff)
downloadmeson-d73748815014b8b4bbbd7fe7fb8b50b8a75aecfc.zip
meson-d73748815014b8b4bbbd7fe7fb8b50b8a75aecfc.tar.gz
meson-d73748815014b8b4bbbd7fe7fb8b50b8a75aecfc.tar.bz2
dependencies: Don't assume self.compiler is a C compiler
All dependencies were using find_library, has_header, get_define, etc on self.compiler assuming that it's a compiler that outputs and consumes C-like libraries. This is not true for D (and in the future, for Rust) since although they can consume C libraries, they do not use the C ecosystem. For such purposes, we now have self.clib_compiler. Nothing uses self.compiler anymore as a result, and it has been removed.
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index eb8ce0d..a5356a8 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -27,6 +27,7 @@ from pathlib import PurePath
from .. import mlog
from .. import mesonlib
+from ..compilers import clib_langs, clike_langs
from ..mesonlib import MesonException, OrderedSet
from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify
@@ -219,6 +220,7 @@ class ExternalDependency(Dependency):
self.want_cross = not kwargs['native']
else:
self.want_cross = self.env.is_cross_build()
+ self.clib_compiler = None
# Set the compiler that will be used by this dependency
# This is only used for configuration checks
if self.want_cross:
@@ -229,19 +231,20 @@ class ExternalDependency(Dependency):
# else try to pick something that looks usable.
if self.language:
if self.language not in compilers:
- m = self.name.capitalize() + ' requires a {} compiler'
+ m = self.name.capitalize() + ' requires a {0} compiler, but ' \
+ '{0} is not in the list of project languages'
raise DependencyException(m.format(self.language.capitalize()))
- self.compiler = compilers[self.language]
+ self.clib_compiler = compilers[self.language]
else:
- # Try to find a compiler that this dependency can use for compiler
- # checks. It's ok if we don't find one.
- for lang in ('c', 'cpp', 'objc', 'objcpp', 'fortran', 'd'):
- self.compiler = compilers.get(lang, None)
- if self.compiler:
+ # Try to find a compiler that can find C libraries for
+ # running compiler.find_library()
+ for lang in clib_langs:
+ self.clib_compiler = compilers.get(lang, None)
+ if self.clib_compiler:
break
def get_compiler(self):
- return self.compiler
+ return self.clib_compiler
def get_partial_dependency(self, *, compile_args=False, link_args=False,
links=False, includes=False, sources=False):
@@ -603,12 +606,11 @@ class PkgConfigDependency(ExternalDependency):
libpaths.add(lib[2:])
continue
elif lib.startswith('-l'):
- if self.compiler:
- args = self.compiler.find_library(lib[2:], self.env,
- list(libpaths), libtype)
- # If no compiler is set on the dependency, the project only
- # uses a non-clike language such as Rust, C#, Python, etc. In
- # this case, all we can do is limp along.
+ if self.clib_compiler:
+ args = self.clib_compiler.find_library(lib[2:], self.env,
+ 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.
else:
args = None
if args: