diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-04-21 16:05:24 +0530 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-04-21 10:15:18 -0700 |
commit | 723884a369efa6fb5b825d76c4f81ba124358e2d (patch) | |
tree | bdce88809e17e715e1563f57dff4e340b57dd736 | |
parent | af9d1f8f15a57a99af376bd6b30730ff9b9812b1 (diff) | |
download | meson-723884a369efa6fb5b825d76c4f81ba124358e2d.zip meson-723884a369efa6fb5b825d76c4f81ba124358e2d.tar.gz meson-723884a369efa6fb5b825d76c4f81ba124358e2d.tar.bz2 |
Expose the implementation language for external libraries
Ideally, all dependency objects should support this, but it's a lot of
work and isn't supported by all dependency types (like frameworks and
pkg-config), so for now just enable it for external libraries.
-rw-r--r-- | mesonbuild/dependencies.py | 18 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 9 |
2 files changed, 13 insertions, 14 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index 39bf2b1..04a22f9 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -51,6 +51,7 @@ class DependencyMethods(Enum): class Dependency: def __init__(self, type_name, kwargs): self.name = "null" + self.language = None self.is_found = False self.type_name = type_name method = DependencyMethods(kwargs.get('method', 'auto')) @@ -570,11 +571,12 @@ class ExternalProgram: return self.name class ExternalLibrary(Dependency): - # TODO: Add `lang` to the parent Dependency object so that dependencies can - # be expressed for languages other than C-like - def __init__(self, name, link_args=None, language=None, silent=False): + # TODO: Add `language` support to all Dependency objects so that languages + # can be exposed for dependencies that support that (i.e., not pkg-config) + def __init__(self, name, link_args, language, silent=False): super().__init__('external', {}) self.name = name + self.language = language self.is_found = False self.link_args = [] self.lang_args = [] @@ -582,9 +584,13 @@ class ExternalLibrary(Dependency): self.is_found = True if not isinstance(link_args, list): link_args = [link_args] - if language: - self.lang_args = {language: link_args} - else: + self.lang_args = {language: link_args} + # We special-case Vala for now till the Dependency object gets + # proper support for exposing the language it was written in. + # Without this, vala-specific link args will end up in the C link + # args list if you link to a Vala library. + # This hack use to be in CompilerHolder.find_library(). + if language != 'vala': self.link_args = link_args if not silent: if self.is_found: diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ed08987..0eb392d 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -982,14 +982,7 @@ class CompilerHolder(InterpreterObject): if required and not linkargs: l = self.compiler.language.capitalize() raise InterpreterException('{} library {!r} not found'.format(l, libname)) - # If this is set to None, the library and link arguments are for - # a C-like compiler. Otherwise, it's for some other language that has - # a find_library implementation. We do this because it's easier than - # maintaining a list of languages that can consume C libraries. - lang = None - if self.compiler.language == 'vala': - lang = 'vala' - lib = dependencies.ExternalLibrary(libname, linkargs, language=lang) + lib = dependencies.ExternalLibrary(libname, linkargs, self.compiler.language) return ExternalLibraryHolder(lib) def has_argument_method(self, args, kwargs): |