From 0a6cbcce0378f9aa12cff37b222e9e85cc0f874e Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 15:27:42 +0000 Subject: Fix typos --- mesonbuild/dependencies/base.py | 2 +- mesonbuild/dependencies/misc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index e29d4de..01df9d0 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -75,7 +75,7 @@ class Dependency: raise DependencyException('method {!r} is invalid'.format(method)) method = DependencyMethods(method) - # This sets per-too config methods which are deprecated to to the new + # This sets per-tool config methods which are deprecated to to the new # generic CONFIG_TOOL value. if method in [DependencyMethods.SDLCONFIG, DependencyMethods.CUPSCONFIG, DependencyMethods.PCAPCONFIG, DependencyMethods.LIBWMFCONFIG]: diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 9614f1f..cf3b51b 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -923,7 +923,7 @@ class LibWmfDependency(ExternalDependency): 'libwmf', environment, None, kwargs, ['libwmf-config'], 'libwmf-config') if ctdep.found(): self.config = ctdep.config - self.type_name = 'config-too' + self.type_name = 'config-tool' self.version = ctdep.version self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') self.link_args = ctdep.get_config_value(['--libs'], 'link_args') -- cgit v1.1 From 8efdcca93063fb224c53ae2d6f57b8dacf082456 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 14:04:45 +0000 Subject: Make Dependency.get_methods() a static method Since this is only consulted while constructing the Dependency object, it's result doesn't depend on the instance (and it would make no sense if it did) --- mesonbuild/dependencies/base.py | 9 ++++++--- mesonbuild/dependencies/misc.py | 12 ++++++++---- mesonbuild/dependencies/ui.py | 12 ++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 01df9d0..fa50761 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -115,7 +115,8 @@ class Dependency: As an example, gtest-all.cc when using GTest.""" return self.sources - def get_methods(self): + @staticmethod + def get_methods(): return [DependencyMethods.AUTO] def get_name(self): @@ -308,7 +309,8 @@ class ConfigToolDependency(ExternalDependency): return [] return shlex.split(out) - def get_methods(self): + @staticmethod + def get_methods(): return [DependencyMethods.AUTO, DependencyMethods.CONFIG_TOOL] def get_configtool_variable(self, variable_name): @@ -535,7 +537,8 @@ class PkgConfigDependency(ExternalDependency): mlog.debug('Got pkgconfig variable %s : %s' % (variable_name, variable)) return variable - def get_methods(self): + @staticmethod + def get_methods(): return [DependencyMethods.PKGCONFIG] def check_pkgconfig(self): diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index cf3b51b..e46fb84 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -792,7 +792,8 @@ class Python3Dependency(ExternalDependency): self.version = sysconfig.get_config_var('py_version') self.is_found = True - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_windows(): return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSCONFIG] elif mesonlib.is_osx(): @@ -839,7 +840,8 @@ class PcapDependency(ExternalDependency): except Exception as e: mlog.debug('Pcap not found via pcap-config. Trying next, error was:', str(e)) - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_osx(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK] else: @@ -893,7 +895,8 @@ class CupsDependency(ExternalDependency): return mlog.log('Dependency', mlog.bold('cups'), 'found:', mlog.red('NO')) - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_osx(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK] else: @@ -932,7 +935,8 @@ class LibWmfDependency(ExternalDependency): except Exception as e: mlog.debug('cups not found via libwmf-config. Trying next, error was:', str(e)) - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_osx(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK] else: diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index c066c31..00cd56d 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -67,7 +67,8 @@ class GLDependency(ExternalDependency): self.version = '1' return - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_osx() or mesonlib.is_windows(): return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] else: @@ -337,7 +338,8 @@ class QtBaseDependency(ExternalDependency): else: return qvars['QT_INSTALL_BINS'] - def get_methods(self): + @staticmethod + def get_methods(): return [DependencyMethods.PKGCONFIG, DependencyMethods.QMAKE] def get_exe_args(self, compiler): @@ -420,7 +422,8 @@ class SDL2Dependency(ExternalDependency): return mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO')) - def get_methods(self): + @staticmethod + def get_methods(): if mesonlib.is_osx(): return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK] else: @@ -526,5 +529,6 @@ class VulkanDependency(ExternalDependency): self.link_args.append(lib) return - def get_methods(self): + @staticmethod + def get_methods(): return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] -- cgit v1.1 From 153a7fb33240dc04f459147b418f58e30d448d56 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 21:10:51 +0000 Subject: Fix unpickling of dynamic subclasses of ConfigToolDependency This code isn't used as present: the actual objects we use and which get pickled are either static subclasses of ConfigToolDependency, or special purpos subclasses of Dependency which get attributes copied from an instance of a dynamic subclass of ConfigToolDependency which is then discarded. This is fortunate, as it doesn't work: the pickled reduction is a call to the dynamic subclass's constructor, but the superclass constructors rely on the environment object being fully initialized, which hasn't happened yet during unpickling. Avoid this by having a pickled reduction which is just a call to create the dynamic subclass object, and relying on the default __setstate__ behavior to unpickle the object's __dict__. --- mesonbuild/dependencies/base.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index fa50761..20a234d 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -236,14 +236,17 @@ class ConfigToolDependency(ExternalDependency): # instantiated and returned. The reduce function (method) is also # attached, since python's pickle module won't be able to do anything # with this dynamically generated class otherwise. - def reduce(_): - return (cls.factory, - (name, environment, language, kwargs, tools, tool_name)) + def reduce(self): + return (cls._unpickle, (), self.__dict__) sub = type('{}Dependency'.format(name.capitalize()), (cls, ), {'tools': tools, 'tool_name': tool_name, '__reduce__': reduce}) return sub(name, environment, language, kwargs) + @classmethod + def _unpickle(cls): + return cls.__new__(cls) + def find_config(self, versions=None): """Helper method that searchs for config tool binaries in PATH and returns the one that best matches the given version requirements. -- cgit v1.1 From c59ec8749661f242c6a15634cdb32fab65eda7c8 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 10 Jan 2018 18:03:26 +0000 Subject: Create GL dependency objects via a factory function Create GL dependency objects via a factory function, so they can be the correct type of object (e.g. a PkgConfigDependency when it's found by pkg-config) Factor out method: kwarg processing, so it can be used by the factory before the dependency object is constructed --- mesonbuild/dependencies/base.py | 39 +++++++++++++++++++++++++-------------- mesonbuild/dependencies/ui.py | 24 +++++++++++------------- 2 files changed, 36 insertions(+), 27 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 20a234d..04ca706 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -61,15 +61,8 @@ class DependencyMethods(Enum): class Dependency: - def __init__(self, type_name, kwargs): - self.name = "null" - self.version = 'none' - self.language = None # None means C-like - self.is_found = False - self.type_name = type_name - self.compile_args = [] - self.link_args = [] - self.sources = [] + @classmethod + def _process_method_kw(cls, kwargs): method = kwargs.get('method', 'auto') if method not in [e.value for e in DependencyMethods]: raise DependencyException('method {!r} is invalid'.format(method)) @@ -88,14 +81,27 @@ class Dependency: # Set the detection method. If the method is set to auto, use any available method. # If method is set to a specific string, allow only that detection method. if method == DependencyMethods.AUTO: - self.methods = self.get_methods() - elif method in self.get_methods(): - self.methods = [method] + methods = cls.get_methods() + elif method in cls.get_methods(): + methods = [method] else: raise DependencyException( 'Unsupported detection method: {}, allowed methods are {}'.format( method.value, - mlog.format_list([x.value for x in [DependencyMethods.AUTO] + self.get_methods()]))) + mlog.format_list([x.value for x in [DependencyMethods.AUTO] + cls.get_methods()]))) + + return methods + + def __init__(self, type_name, kwargs): + self.name = "null" + self.version = 'none' + self.language = None # None means C-like + self.is_found = False + self.type_name = type_name + self.compile_args = [] + self.link_args = [] + self.sources = [] + self.methods = self._process_method_kw(kwargs) def __repr__(self): s = '<{0} {1}: {2}>' @@ -890,7 +896,12 @@ def find_external_dependency(name, env, kwargs): 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) + # Create the dependency object using a factory class method, if one + # exists, otherwise it is just constructed directly. + if getattr(packages[lname], '_factory', None): + dep = packages[lname]._factory(env, kwargs) + else: + dep = packages[lname](env, kwargs) if required and not dep.found(): raise DependencyException('Dependency "%s" not found' % name) return dep diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 00cd56d..bc332fc 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -38,19 +38,6 @@ from .base import ConfigToolDependency class GLDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('gl', environment, None, kwargs) - if DependencyMethods.PKGCONFIG in self.methods: - try: - pcdep = PkgConfigDependency('gl', environment, kwargs) - if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return - except Exception: - pass if DependencyMethods.SYSTEM in self.methods: if mesonlib.is_osx(): self.is_found = True @@ -67,6 +54,17 @@ class GLDependency(ExternalDependency): self.version = '1' return + @classmethod + def _factory(cls, environment, kwargs): + if DependencyMethods.PKGCONFIG in cls._process_method_kw(kwargs): + try: + pcdep = PkgConfigDependency('gl', environment, kwargs) + if pcdep.found(): + return pcdep + except Exception: + pass + return GLDependency(environment, kwargs) + @staticmethod def get_methods(): if mesonlib.is_osx() or mesonlib.is_windows(): -- cgit v1.1 From 3748f5465afd868d9b3aca89850e6775cc67ca14 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 13 Jan 2018 21:12:39 +0000 Subject: Same for SDL2 --- mesonbuild/dependencies/ui.py | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index bc332fc..f1ee738 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -380,46 +380,38 @@ class Qt5Dependency(QtBaseDependency): class SDL2Dependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('sdl2', environment, None, kwargs) - kwargs['required'] = False - if DependencyMethods.PKGCONFIG in self.methods: + + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + if DependencyMethods.PKGCONFIG in methods: try: pcdep = PkgConfigDependency('sdl2', environment, kwargs) if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return + return pcdep except Exception as e: mlog.debug('SDL 2 not found via pkgconfig. Trying next, error was:', str(e)) - if DependencyMethods.CONFIG_TOOL in self.methods: + if DependencyMethods.CONFIG_TOOL in methods: try: ctdep = ConfigToolDependency.factory( 'sdl2', environment, None, kwargs, ['sdl2-config'], 'sdl2-config') if ctdep.found(): - self.type_name = 'config-tool' - self.config = ctdep.config - self.version = ctdep.version - self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - self.links_args = ctdep.get_config_value(['--libs'], 'link_args') - self.is_found = True - return + ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') + ctdep.links_args = ctdep.get_config_value(['--libs'], 'link_args') + return ctdep except Exception as e: mlog.debug('SDL 2 not found via sdl2-config. Trying next, error was:', str(e)) - if DependencyMethods.EXTRAFRAMEWORK in self.methods: + if DependencyMethods.EXTRAFRAMEWORK in methods: if mesonlib.is_osx(): - fwdep = ExtraFrameworkDependency('sdl2', False, None, self.env, - self.language, kwargs) + fwdep = ExtraFrameworkDependency('sdl2', False, None, environment, + kwargs.get('language', None), kwargs) if fwdep.found(): - self.is_found = True - self.compile_args = fwdep.get_compile_args() - self.link_args = fwdep.get_link_args() - self.version = '2' # FIXME - return + fwdep.version = '2' # FIXME + return fwdep mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.red('NO')) + return SDL2Dependency(environment, kwargs) + @staticmethod def get_methods(): if mesonlib.is_osx(): -- cgit v1.1 From 57cb59787112aac395343e98f5cc4686560e74c9 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 13 Jan 2018 21:24:48 +0000 Subject: Same for Vulkan --- mesonbuild/dependencies/ui.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index f1ee738..a6307c4 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -449,20 +449,6 @@ class VulkanDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('vulkan', environment, None, kwargs) - if DependencyMethods.PKGCONFIG in self.methods: - try: - pcdep = PkgConfigDependency('vulkan', environment, kwargs) - if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return - except Exception: - pass - if DependencyMethods.SYSTEM in self.methods: try: self.vulkan_sdk = os.environ['VULKAN_SDK'] @@ -519,6 +505,18 @@ class VulkanDependency(ExternalDependency): self.link_args.append(lib) return + @classmethod + def _factory(cls, environment, kwargs): + if DependencyMethods.PKGCONFIG in cls._process_method_kw(kwargs): + try: + pcdep = PkgConfigDependency('vulkan', environment, kwargs) + if pcdep.found(): + return pcdep + except Exception: + pass + + return VulkanDependency(environment, kwargs) + @staticmethod def get_methods(): return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] -- cgit v1.1 From 638095125d98233c66832830e57433bd16c13573 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 18:50:51 +0000 Subject: Same for pcap --- mesonbuild/dependencies/misc.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index e46fb84..fc4bea5 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -811,35 +811,31 @@ class Python3Dependency(ExternalDependency): class PcapDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('pcap', environment, None, kwargs) - kwargs['required'] = False - if DependencyMethods.PKGCONFIG in self.methods: + + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + if DependencyMethods.PKGCONFIG in methods: try: pcdep = PkgConfigDependency('pcap', environment, kwargs) if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return + return pcdep except Exception as e: mlog.debug('Pcap not found via pkgconfig. Trying next, error was:', str(e)) - if DependencyMethods.CONFIG_TOOL in self.methods: + if DependencyMethods.CONFIG_TOOL in methods: try: ctdep = ConfigToolDependency.factory( 'pcap', environment, None, kwargs, ['pcap-config'], 'pcap-config') if ctdep.found(): - self.config = ctdep.config - self.type_name = 'config-tool' - self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - self.link_args = ctdep.get_config_value(['--libs'], 'link_args') - self.version = self.get_pcap_lib_version() - self.is_found = True - return + ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') + ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args') + ctdep.version = cls.get_pcap_lib_version(ctdep) + return ctdep except Exception as e: mlog.debug('Pcap not found via pcap-config. Trying next, error was:', str(e)) + return PcapDependency(environment, kwargs) + @staticmethod def get_methods(): if mesonlib.is_osx(): @@ -847,9 +843,10 @@ class PcapDependency(ExternalDependency): else: return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL] - def get_pcap_lib_version(self): - return self.compiler.get_return_value('pcap_lib_version', 'string', - '#include ', self.env, [], [self]) + @staticmethod + def get_pcap_lib_version(ctdep): + return ctdep.compiler.get_return_value('pcap_lib_version', 'string', + '#include ', ctdep.env, [], [ctdep]) class CupsDependency(ExternalDependency): -- cgit v1.1 From cdf241420c97bff8ed5a959234ae536396e1f5ce Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 18:54:15 +0000 Subject: Same for cups --- mesonbuild/dependencies/misc.py | 43 ++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index fc4bea5..0983aa9 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -852,45 +852,36 @@ class PcapDependency(ExternalDependency): class CupsDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('cups', environment, None, kwargs) - kwargs['required'] = False - if DependencyMethods.PKGCONFIG in self.methods: + + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + if DependencyMethods.PKGCONFIG in methods: try: pcdep = PkgConfigDependency('cups', environment, kwargs) if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return + return pcdep except Exception as e: mlog.debug('cups not found via pkgconfig. Trying next, error was:', str(e)) - if DependencyMethods.CONFIG_TOOL in self.methods: + if DependencyMethods.CONFIG_TOOL in methods: try: ctdep = ConfigToolDependency.factory( 'cups', environment, None, kwargs, ['cups-config'], 'cups-config') if ctdep.found(): - self.config = ctdep.config - self.type_name = 'config-tool' - self.version = ctdep.version - self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - self.link_args = ctdep.get_config_value(['--ldflags', '--libs'], 'link_args') - self.is_found = True - return + ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') + ctdep.link_args = ctdep.get_config_value(['--ldflags', '--libs'], 'link_args') + return ctdep except Exception as e: mlog.debug('cups not found via cups-config. Trying next, error was:', str(e)) - if DependencyMethods.EXTRAFRAMEWORK in self.methods: + if DependencyMethods.EXTRAFRAMEWORK in methods: if mesonlib.is_osx(): - fwdep = ExtraFrameworkDependency('cups', False, None, self.env, - self.language, kwargs) + fwdep = ExtraFrameworkDependency('cups', False, None, environment, + kwargs.get('language', None), kwargs) if fwdep.found(): - self.is_found = True - self.compile_args = fwdep.get_compile_args() - self.link_args = fwdep.get_link_args() - self.version = fwdep.get_version() - return - mlog.log('Dependency', mlog.bold('cups'), 'found:', mlog.red('NO')) + return fwdep + mlog.log('Dependency', mlog.bold('cups'), 'found:', mlog.red('NO')) + + return CupsDependency(environment, kwargs) @staticmethod def get_methods(): -- cgit v1.1 From 227ad7605b1c019f4022e12a50e91b1ce88e2914 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 14 Jan 2018 18:59:16 +0000 Subject: Same for libwmf --- mesonbuild/dependencies/misc.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 0983aa9..0570e88 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -894,35 +894,31 @@ class CupsDependency(ExternalDependency): class LibWmfDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('libwmf', environment, None, kwargs) - if DependencyMethods.PKGCONFIG in self.methods: + + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + if DependencyMethods.PKGCONFIG in methods: try: kwargs['required'] = False pcdep = PkgConfigDependency('libwmf', environment, kwargs) if pcdep.found(): - self.type_name = 'pkgconfig' - self.is_found = True - self.compile_args = pcdep.get_compile_args() - self.link_args = pcdep.get_link_args() - self.version = pcdep.get_version() - self.pcdep = pcdep - return + return pcdep except Exception as e: mlog.debug('LibWmf not found via pkgconfig. Trying next, error was:', str(e)) - if DependencyMethods.CONFIG_TOOL in self.methods: + if DependencyMethods.CONFIG_TOOL in methods: try: ctdep = ConfigToolDependency.factory( 'libwmf', environment, None, kwargs, ['libwmf-config'], 'libwmf-config') if ctdep.found(): - self.config = ctdep.config - self.type_name = 'config-tool' - self.version = ctdep.version - self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - self.link_args = ctdep.get_config_value(['--libs'], 'link_args') - self.is_found = True - return + ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') + ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args') + return ctdep except Exception as e: mlog.debug('cups not found via libwmf-config. Trying next, error was:', str(e)) + return LibWmfDependency(environment, kwargs) + @staticmethod def get_methods(): if mesonlib.is_osx(): -- cgit v1.1