diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-04-30 09:27:15 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-05-02 13:28:33 -0700 |
commit | 0654b1a2b160bd66f28991b67c16a43167a4b464 (patch) | |
tree | 19394c70bda8aaec8546acd6426c6611655cd4f5 | |
parent | 98b7b0f5c22ed7060069ae023c74a00617349210 (diff) | |
download | meson-0654b1a2b160bd66f28991b67c16a43167a4b464.zip meson-0654b1a2b160bd66f28991b67c16a43167a4b464.tar.gz meson-0654b1a2b160bd66f28991b67c16a43167a4b464.tar.bz2 |
dependencies/base: Add a new method for setting internal dependencies
When we create a dependency as part of another dependency (say Threads),
we want to pass down most of the methods (like required). Currently
however, there is the possibility that we can pass down invalid keyword
arguments, such as 'method'. This new method is meant to work around
that my simplifying and centralizing how we pass these dependencies
down.
-rw-r--r-- | mesonbuild/dependencies/base.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 1a60a16..8432ab6 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -25,6 +25,7 @@ import textwrap import platform import itertools import ctypes +import typing from typing import Any, Dict, List, Tuple from enum import Enum from pathlib import Path, PurePath @@ -73,6 +74,8 @@ 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) @@ -176,6 +179,20 @@ class Dependency: """ raise RuntimeError('Unreachable code in partial_dependency called') + def _add_sub_dependency(self, dep_type: typing.Type['Dependency'], env: Environment, + kwargs: typing.Dict[str, typing.Any], *, + method: DependencyMethods = DependencyMethods.AUTO) -> None: + """Add an internal dependency of of the given type. + + This method is intended to simplify cases of adding a dependency on + another dependency type (such as threads). This will by default set + the method back to auto, but the 'method' keyword argument can be + used to overwrite this behavior. + """ + kwargs = kwargs.copy() + kwargs['method'] = method + self.ext_deps.append(dep_type(env, kwargs)) + class InternalDependency(Dependency): def __init__(self, version, incdirs, compile_args, link_args, libraries, whole_libraries, sources, ext_deps): |