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/ui.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'mesonbuild/dependencies/ui.py') 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