aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-01-07 15:12:58 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-01-29 09:11:24 -0800
commitf85d6cee6abd5d3f763240bcd0ab4e18daf60c95 (patch)
tree247ce9671d0393b02bbedbdb84cd21d7abdd26fb /mesonbuild
parentd0c7b5169303fb0a394201d90be1e74426d7b2d9 (diff)
downloadmeson-f85d6cee6abd5d3f763240bcd0ab4e18daf60c95.zip
meson-f85d6cee6abd5d3f763240bcd0ab4e18daf60c95.tar.gz
meson-f85d6cee6abd5d3f763240bcd0ab4e18daf60c95.tar.bz2
dependencies/base: Split process_method_kw out of Dependency
I want to use this in a new class as well, that doesn't descend from Dependency.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/base.py67
-rw-r--r--mesonbuild/dependencies/dev.py8
-rw-r--r--mesonbuild/dependencies/misc.py16
-rw-r--r--mesonbuild/dependencies/ui.py8
4 files changed, 50 insertions, 49 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index e9d1f89..7e563d6 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -70,38 +70,6 @@ class DependencyMethods(Enum):
class Dependency:
- @classmethod
- def _process_method_kw(cls, kwargs):
- method = kwargs.get('method', 'auto')
- if isinstance(method, DependencyMethods):
- return method
- if method not in [e.value for e in DependencyMethods]:
- raise DependencyException('method {!r} is invalid'.format(method))
- method = DependencyMethods(method)
-
- # 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]:
- mlog.warning(textwrap.dedent("""\
- Configuration method {} has been deprecated in favor of
- 'config-tool'. This will be removed in a future version of
- meson.""".format(method)))
- method = DependencyMethods.CONFIG_TOOL
-
- # 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:
- 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] + cls.get_methods()])))
-
- return methods
@classmethod
def _process_include_type_kw(cls, kwargs) -> str:
@@ -125,7 +93,7 @@ class Dependency:
# If None, self.link_args will be used
self.raw_link_args = None
self.sources = []
- self.methods = self._process_method_kw(kwargs)
+ self.methods = process_method_kw(self.get_methods(), kwargs)
self.include_type = self._process_include_type_kw(kwargs)
self.ext_deps = [] # type: T.List[Dependency]
@@ -2405,3 +2373,36 @@ def strip_system_libdirs(environment, for_machine: MachineChoice, link_args):
"""
exclude = {'-L{}'.format(p) for p in environment.get_compiler_system_dirs(for_machine)}
return [l for l in link_args if l not in exclude]
+
+
+def process_method_kw(possible: T.List[DependencyMethods], kwargs) -> T.List[DependencyMethods]:
+ method = kwargs.get('method', 'auto')
+ if isinstance(method, DependencyMethods):
+ return method
+ if method not in [e.value for e in DependencyMethods]:
+ raise DependencyException('method {!r} is invalid'.format(method))
+ method = DependencyMethods(method)
+
+ # 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]:
+ mlog.warning(textwrap.dedent("""\
+ Configuration method {} has been deprecated in favor of
+ 'config-tool'. This will be removed in a future version of
+ meson.""".format(method)))
+ method = DependencyMethods.CONFIG_TOOL
+
+ # 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:
+ methods = possible
+ elif method in possible:
+ methods = [method]
+ else:
+ raise DependencyException(
+ 'Unsupported detection method: {}, allowed methods are {}'.format(
+ method.value,
+ mlog.format_list([x.value for x in [DependencyMethods.AUTO] + possible])))
+
+ return methods
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 49f8fea..0488b2b 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -25,7 +25,7 @@ from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineC
from ..environment import get_llvm_tool_names
from .base import (
DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
- strip_system_libdirs, ConfigToolDependency, CMakeDependency
+ strip_system_libdirs, ConfigToolDependency, CMakeDependency, process_method_kw
)
from .misc import ThreadDependency
@@ -100,7 +100,7 @@ class GTestDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -179,7 +179,7 @@ class GMockDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -439,7 +439,7 @@ class LLVMDependency(ExternalDependency):
@classmethod
def _factory(cls, env, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.CONFIG_TOOL in methods:
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 9077222..fd480c1 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -27,7 +27,7 @@ from ..mesonlib import listify
from .base import (
DependencyException, DependencyMethods, ExternalDependency,
ExtraFrameworkDependency, PkgConfigDependency,
- CMakeDependency, ConfigToolDependency,
+ CMakeDependency, ConfigToolDependency, process_method_kw,
)
@@ -205,7 +205,7 @@ class Python3Dependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -329,7 +329,7 @@ class PcapDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -374,7 +374,7 @@ class CupsDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -416,7 +416,7 @@ class LibWmfDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -444,7 +444,7 @@ class LibGCryptDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -475,7 +475,7 @@ class GpgmeDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -530,7 +530,7 @@ class ShadercDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index da411ef..c953951 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -30,7 +30,7 @@ from ..environment import detect_cpu_family
from .base import DependencyException, DependencyMethods
from .base import ExternalDependency, ExternalProgram, NonExistingExternalProgram
from .base import ExtraFrameworkDependency, PkgConfigDependency
-from .base import ConfigToolDependency
+from .base import ConfigToolDependency, process_method_kw
class GLDependency(ExternalDependency):
@@ -52,7 +52,7 @@ class GLDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -532,7 +532,7 @@ class SDL2Dependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods:
@@ -648,7 +648,7 @@ class VulkanDependency(ExternalDependency):
@classmethod
def _factory(cls, environment, kwargs):
- methods = cls._process_method_kw(kwargs)
+ methods = process_method_kw(cls.get_methods(), kwargs)
candidates = []
if DependencyMethods.PKGCONFIG in methods: