Tweak formatting of base dependency file.

pull/1631/head
Elliott Sales de Andrade 8 years ago
parent d3caadb675
commit 8731e00ada
  1. 35
      mesonbuild/dependencies/base.py

@ -12,24 +12,28 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# This file contains the detection logic for external # This file contains the detection logic for external dependencies.
# dependencies. Mostly just uses pkg-config but also contains # Custom logic for several other packages are in separate files.
# custom logic for packages that don't provide them.
# Currently one file, should probably be split into a
# package before this gets too big.
import os
import shutil
import stat
import sys import sys
import os, stat, shutil
from enum import Enum from enum import Enum
from .. import mlog from .. import mlog
from .. import mesonlib from .. import mesonlib
from ..mesonlib import MesonException, flatten, version_compare_many, Popen_safe from ..mesonlib import MesonException, Popen_safe, flatten, version_compare_many
# This must be defined in this file to avoid cyclical references.
packages = {}
class DependencyException(MesonException): class DependencyException(MesonException):
'''Exceptions raised while trying to find dependencies''' '''Exceptions raised while trying to find dependencies'''
class DependencyMethods(Enum): class DependencyMethods(Enum):
# Auto means to use whatever dependency checking mechanisms in whatever order meson thinks is best. # Auto means to use whatever dependency checking mechanisms in whatever order meson thinks is best.
AUTO = 'auto' AUTO = 'auto'
@ -44,6 +48,7 @@ class DependencyMethods(Enum):
# Detect using the sysconfig module. # Detect using the sysconfig module.
SYSCONFIG = 'sysconfig' SYSCONFIG = 'sysconfig'
class Dependency: class Dependency:
def __init__(self, type_name, kwargs): def __init__(self, type_name, kwargs):
self.name = "null" self.name = "null"
@ -59,7 +64,10 @@ class Dependency:
elif method in self.get_methods(): elif method in self.get_methods():
self.methods = [method] self.methods = [method]
else: else:
raise MesonException('Unsupported detection method: {}, allowed methods are {}'.format(method.value, mlog.format_list(map(lambda x: x.value, [DependencyMethods.AUTO] + self.get_methods())))) raise MesonException(
'Unsupported detection method: {}, allowed methods are {}'.format(
method.value,
mlog.format_list(map(lambda x: x.value, [DependencyMethods.AUTO] + self.get_methods()))))
def __repr__(self): def __repr__(self):
s = '<{0} {1}: {2}>' s = '<{0} {1}: {2}>'
@ -94,6 +102,7 @@ class Dependency:
def get_pkgconfig_variable(self, variable_name): def get_pkgconfig_variable(self, variable_name):
raise MesonException('Tried to get a pkg-config variable from a non-pkgconfig dependency.') raise MesonException('Tried to get a pkg-config variable from a non-pkgconfig dependency.')
class InternalDependency(Dependency): class InternalDependency(Dependency):
def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps): def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps):
super().__init__('internal', {}) super().__init__('internal', {})
@ -115,6 +124,7 @@ class InternalDependency(Dependency):
def get_version(self): def get_version(self):
return self.version return self.version
class PkgConfigDependency(Dependency): class PkgConfigDependency(Dependency):
# The class's copy of the pkg-config path. Avoids having to search for it # The class's copy of the pkg-config path. Avoids having to search for it
# multiple times in the same Meson invocation. # multiple times in the same Meson invocation.
@ -489,6 +499,7 @@ class ExternalProgram:
def get_name(self): def get_name(self):
return self.name return self.name
class ExternalLibrary(Dependency): class ExternalLibrary(Dependency):
# TODO: Add `language` support to all Dependency objects so that languages # TODO: Add `language` support to all Dependency objects so that languages
# can be exposed for dependencies that support that (i.e., not pkg-config) # can be exposed for dependencies that support that (i.e., not pkg-config)
@ -596,6 +607,7 @@ def get_dep_identifier(name, kwargs, want_cross):
identifier += (key, value) identifier += (key, value)
return identifier return identifier
def find_external_dependency(name, environment, kwargs): def find_external_dependency(name, environment, kwargs):
required = kwargs.get('required', True) required = kwargs.get('required', True)
if not isinstance(required, bool): if not isinstance(required, bool):
@ -627,8 +639,3 @@ def find_external_dependency(name, environment, kwargs):
raise pkg_exc raise pkg_exc
mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO'))
return pkgdep return pkgdep
# This has to be at the end so the classes it references
# are defined.
packages = {}

Loading…
Cancel
Save