aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
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/dependencies/base.py
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/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py67
1 files changed, 34 insertions, 33 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