dependencies: Use DependencyFactory for cups

pull/6540/head
Dylan Baker 5 years ago
parent a1f03881c1
commit 4cc890e70a
  1. 4
      mesonbuild/dependencies/__init__.py
  2. 43
      mesonbuild/dependencies/misc.py
  3. 1
      test cases/frameworks/20 cups/meson.build

@ -24,7 +24,7 @@ from .dev import ValgrindDependency, gmock_factory, gtest_factory, llvm_factory
from .coarrays import CoarrayDependency
from .mpi import MPIDependency
from .scalapack import ScalapackDependency
from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, CupsDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency, pcap_factory, python3_factory)
from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, LibWmfDependency, LibGCryptDependency, GpgmeDependency, ShadercDependency, cups_factory, pcap_factory, python3_factory)
from .platform import AppleFrameworks
from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, vulkan_factory
@ -53,7 +53,7 @@ packages.update({
'python3': python3_factory,
'threads': ThreadDependency,
'pcap': pcap_factory,
'cups': CupsDependency,
'cups': cups_factory,
'libwmf': LibWmfDependency,
'libgcrypt': LibGCryptDependency,
'gpgme': GpgmeDependency,

@ -26,9 +26,8 @@ from ..mesonlib import listify
from .base import (
DependencyException, DependencyMethods, ExternalDependency,
ExtraFrameworkDependency, PkgConfigDependency,
CMakeDependency, ConfigToolDependency, process_method_kw,
DependencyFactory,
PkgConfigDependency, CMakeDependency, ConfigToolDependency,
process_method_kw, DependencyFactory,
)
class NetCDFDependency(ExternalDependency):
@ -330,36 +329,13 @@ class PcapDependencyConfigTool(ConfigToolDependency):
return v
class CupsDependency(ExternalDependency):
def __init__(self, environment, kwargs):
super().__init__('cups', environment, kwargs)
@classmethod
def _factory(cls, environment, kwargs):
methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
candidates.append(functools.partial(PkgConfigDependency, 'cups', environment, kwargs))
if DependencyMethods.CONFIG_TOOL in methods:
candidates.append(functools.partial(ConfigToolDependency.factory,
'cups', environment, None,
kwargs, ['cups-config'],
'cups-config', CupsDependency.tool_finish_init))
class CupsDependencyConfigTool(ConfigToolDependency):
if DependencyMethods.EXTRAFRAMEWORK in methods:
if mesonlib.is_osx():
candidates.append(functools.partial(
ExtraFrameworkDependency, 'cups', environment, kwargs))
if DependencyMethods.CMAKE in methods:
candidates.append(functools.partial(CMakeDependency, 'Cups', environment, kwargs))
return candidates
tools = ['cups-config']
tool_name = 'cups-config'
@staticmethod
def tool_finish_init(ctdep):
def finish_init(ctdep):
ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
ctdep.link_args = ctdep.get_config_value(['--ldflags', '--libs'], 'link_args')
@ -544,6 +520,13 @@ class CursesDependency(ExternalDependency):
return [DependencyMethods.AUTO, DependencyMethods.PKGCONFIG]
cups_factory = DependencyFactory(
'cups',
[DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK, DependencyMethods.CMAKE],
configtool_class=CupsDependencyConfigTool,
cmake_name='Cups',
)
pcap_factory = DependencyFactory(
'pcap',
[DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL],

@ -14,6 +14,7 @@ test('cupstest', e)
# options
dep = dependency('cups', version : '>=1.4', method : 'cups-config')
dep = dependency('cups', version : '>=1.4', method : 'config-tool')
dep = dependency('cups', version : '>=1.4', method : 'cmake')
# check we can apply a version constraint
dependency('cups', version: '>=@0@'.format(dep.version()), method: 'pkg-config', required: false)

Loading…
Cancel
Save