diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-11-30 12:40:20 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-12-03 10:06:11 +0530 |
commit | 133df3b045c8b70b2750fac5961dc85cea2e19b2 (patch) | |
tree | d86912f00ec14545ba1ef2887886cff741cef281 /mesonbuild/dependencies/base.py | |
parent | b2feae98339556eb053d3493bc925f3ceb30ec3b (diff) | |
download | meson-133df3b045c8b70b2750fac5961dc85cea2e19b2.zip meson-133df3b045c8b70b2750fac5961dc85cea2e19b2.tar.gz meson-133df3b045c8b70b2750fac5961dc85cea2e19b2.tar.bz2 |
dependencies: Pass language to PkgConfigDependency
Also try harder to find a compiler that dependencies can use.
This means that in C++-only projects we will use the C++ compiler for
compiler checks, which can be important.
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r-- | mesonbuild/dependencies/base.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 81b93c4..7249b01 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -157,9 +157,6 @@ class ExternalDependency(Dependency): self.name = type_name # default self.is_found = False self.language = language - if language and language not in self.env.coredata.compilers: - m = self.name.capitalize() + ' requires a {} compiler' - raise DependencyException(m.format(language.capitalize())) self.version_reqs = kwargs.get('version', None) self.required = kwargs.get('required', True) self.silent = kwargs.get('silent', False) @@ -177,7 +174,20 @@ class ExternalDependency(Dependency): compilers = self.env.coredata.cross_compilers else: compilers = self.env.coredata.compilers - self.compiler = compilers.get(self.language or 'c', None) + # Set the compiler for this dependency if a language is specified, + # else try to pick something that looks usable. + if self.language: + if self.language not in compilers: + m = self.name.capitalize() + ' requires a {} compiler' + raise DependencyException(m.format(self.language.capitalize())) + self.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: + break def get_compiler(self): return self.compiler @@ -309,8 +319,8 @@ class PkgConfigDependency(ExternalDependency): # multiple times in the same Meson invocation. class_pkgbin = None - def __init__(self, name, environment, kwargs): - super().__init__('pkgconfig', environment, None, kwargs) + def __init__(self, name, environment, kwargs, language=None): + super().__init__('pkgconfig', environment, language, kwargs) self.name = name self.is_libtool = False # Store a copy of the pkg-config path on the object itself so it is @@ -428,7 +438,7 @@ class PkgConfigDependency(ExternalDependency): # MSVC cannot handle MinGW-esque /c/foo paths, convert them to C:/foo. # We cannot resolve other paths starting with / like /home/foo so leave # them as-is so the user gets an error/warning from the compiler/linker. - if self.compiler.id == 'msvc': + if self.compiler and self.compiler.id == 'msvc': # Library search path if lib.startswith('-L/'): pargs = PurePath(lib[2:]).parts |