Disallow language keyword for unsupported deps.

Also, document it in the manual.
pull/1895/head
Elliott Sales de Andrade 8 years ago
parent edb260b4f4
commit d9f01ffcea
  1. 1
      docs/markdown/Reference-manual.md
  2. 5
      mesonbuild/dependencies/__init__.py
  3. 8
      mesonbuild/dependencies/base.py

@ -193,6 +193,7 @@ Finds an external dependency with the given name with `pkg-config` if possible a
- `fallback` specifies a subproject fallback to use in case the dependency is not found in the system. The value is an array `['subproj_name', 'subproj_dep']` where the first value is the name of the subproject and the second is the variable name in that subproject that contains the value of [`declare_dependency`](#declare_dependency).
- `default_options` *(added 0.37.0)* an array of option values that override those set in the project's `default_options` invocation (like `default_options` in [`project()`](#project), they only have effect when Meson is run for the first time, and command line arguments override any default options in build files)
- `method` defines the way the dependency is detected, the default is `auto` but can be overridden to be e.g. `qmake` for Qt development, and different dependencies support different values for this (though `auto` will work on all of them)
- `language` *(added 0.42.0)* defines what language-specific dependency to find if it's available for multiple languages.
The returned object also has methods that are documented in the [object methods section](#dependency-object) below.

@ -15,7 +15,7 @@
from .base import ( # noqa: F401
Dependency, DependencyException, DependencyMethods, ExternalProgram,
ExternalDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency,
PkgConfigDependency, find_external_dependency, get_dep_identifier, packages)
PkgConfigDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language)
from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency
from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency)
from .platform import AppleFrameworks
@ -47,3 +47,6 @@ packages.update({
'wxwidgets': WxDependency,
'vulkan': VulkanDependency,
})
_packages_accept_language.update({
'mpi',
})

@ -26,8 +26,9 @@ from .. import mesonlib
from ..mesonlib import MesonException, Popen_safe, flatten, version_compare_many
# This must be defined in this file to avoid cyclical references.
# These must be defined in this file to avoid cyclical references.
packages = {}
_packages_accept_language = set()
class DependencyException(MesonException):
@ -610,10 +611,15 @@ def find_external_dependency(name, env, kwargs):
raise DependencyException('Keyword "method" must be a string.')
lname = name.lower()
if lname in packages:
if lname not in _packages_accept_language and 'language' in kwargs:
raise DependencyException('%s dependency does not accept "language" keyword argument' % (lname, ))
dep = packages[lname](env, kwargs)
if required and not dep.found():
raise DependencyException('Dependency "%s" not found' % name)
return dep
if 'language' in kwargs:
# Remove check when PkgConfigDependency supports language.
raise DependencyException('%s dependency does not accept "language" keyword argument' % (lname, ))
pkg_exc = None
pkgdep = None
try:

Loading…
Cancel
Save