From 773cc7b4b0540fd9a88d89f4179a3ffad11276ae Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 8 Jan 2020 15:25:35 -0800 Subject: [PATCH] dependencies: Use DependencyFactory for gpgme --- mesonbuild/dependencies/__init__.py | 4 ++-- mesonbuild/dependencies/misc.py | 29 ++++++++++------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index 503c8696a..14eb50bbf 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -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, GpgmeDependency, ShadercDependency, cups_factory, libgcrypt_factory, libwmf_factory, pcap_factory, python3_factory) +from .misc import (BlocksDependency, CursesDependency, NetCDFDependency, OpenMPDependency, ThreadDependency, ShadercDependency, cups_factory, gpgme_factory, libgcrypt_factory, libwmf_factory, pcap_factory, python3_factory) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, vulkan_factory @@ -56,7 +56,7 @@ packages.update({ 'cups': cups_factory, 'libwmf': libwmf_factory, 'libgcrypt': libgcrypt_factory, - 'gpgme': GpgmeDependency, + 'gpgme': gpgme_factory, 'shaderc': ShadercDependency, # From platform: diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index df167b206..cd4fcb134 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -378,28 +378,13 @@ class LibGCryptDependencyConfigTool(ConfigToolDependency): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] -class GpgmeDependency(ExternalDependency): - def __init__(self, environment, kwargs): - super().__init__('gpgme', 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, 'gpgme', environment, kwargs)) - - if DependencyMethods.CONFIG_TOOL in methods: - candidates.append(functools.partial(ConfigToolDependency.factory, - 'gpgme', environment, None, kwargs, ['gpgme-config'], - 'gpgme-config', - GpgmeDependency.tool_finish_init)) +class GpgmeDependencyConfigTool(ConfigToolDependency): - return candidates + tools = ['gpgme-config'] + tool_name = 'gpg-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(['--libs'], 'link_args') ctdep.version = ctdep.get_config_value(['--version'], 'version')[0] @@ -499,6 +484,12 @@ cups_factory = DependencyFactory( cmake_name='Cups', ) +gpgme_factory = DependencyFactory( + 'gpgme', + [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL], + configtool_class=GpgmeDependencyConfigTool, +) + libgcrypt_factory = DependencyFactory( 'libgcrypt', [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL],