diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-05-02 16:36:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 16:36:39 -0700 |
commit | 529d3788ab70785e12735d4aa9a3cf9e64023bc9 (patch) | |
tree | 2ddf739bb546d8fcca784eb40514318c88eabb86 /mesonbuild/dependencies/base.py | |
parent | c0aa89e57ff5a92c1a1e2cf542692f54622d8cd2 (diff) | |
parent | b59bec08a2a8edf9442dcf4bbf2ce6bc736d7dc0 (diff) | |
download | meson-529d3788ab70785e12735d4aa9a3cf9e64023bc9.zip meson-529d3788ab70785e12735d4aa9a3cf9e64023bc9.tar.gz meson-529d3788ab70785e12735d4aa9a3cf9e64023bc9.tar.bz2 |
Merge pull request #5254 from dcbaker/fix-sub-dependencies
Fix sub dependencies
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-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 9664215..7a10d69 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): |