aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-03-29 13:43:59 +0200
committerEli Schwartz <eschwartz93@gmail.com>2022-05-03 02:00:29 -0400
commit06b76f7c9d7bbe74450ed49316eaeae28dccda7d (patch)
tree9d5f4f60bb0173bce1542a0f93137773a09d5c4e /mesonbuild/dependencies
parentd413dedf2a6a6f893e110f7a03d9e3468fdf1fc3 (diff)
downloadmeson-06b76f7c9d7bbe74450ed49316eaeae28dccda7d.zip
meson-06b76f7c9d7bbe74450ed49316eaeae28dccda7d.tar.gz
meson-06b76f7c9d7bbe74450ed49316eaeae28dccda7d.tar.bz2
dependencies: extract code to get all leaf dependencies
Extract to a separate function the code that resolves dependencies for compiler methods. We will reuse it for add_project_dependencies(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/__init__.py3
-rw-r--r--mesonbuild/dependencies/base.py18
2 files changed, 19 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index 1e1a9f7..cdadd56 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -18,7 +18,7 @@ from .hdf5 import hdf5_factory
from .base import Dependency, InternalDependency, ExternalDependency, NotFoundDependency
from .base import (
ExternalLibrary, DependencyException, DependencyMethods,
- BuiltinDependency, SystemDependency)
+ BuiltinDependency, SystemDependency, get_leaf_external_dependencies)
from .cmake import CMakeDependency
from .configtool import ConfigToolDependency
from .dub import DubDependency
@@ -65,6 +65,7 @@ __all__ = [
'find_external_dependency',
'get_dep_identifier',
+ 'get_leaf_external_dependencies',
]
"""Dependency representations and discovery logic.
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 1242af7..c2a274e 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -23,7 +23,7 @@ import itertools
import typing as T
from enum import Enum
-from .. import mlog
+from .. import mlog, mesonlib
from ..compilers import clib_langs
from ..mesonlib import LibType, MachineChoice, MesonException, HoldableObject
from ..mesonlib import version_compare_many
@@ -461,6 +461,22 @@ class ExternalLibrary(ExternalDependency):
return new
+def get_leaf_external_dependencies(deps: T.List[Dependency]) -> T.List[Dependency]:
+ if not deps:
+ # Ensure that we always return a new instance
+ return deps.copy()
+ final_deps = []
+ while deps:
+ next_deps = []
+ for d in mesonlib.listify(deps):
+ if not isinstance(d, Dependency) or d.is_built():
+ raise DependencyException('Dependencies must be external dependencies')
+ final_deps.append(d)
+ next_deps.extend(d.ext_deps)
+ deps = next_deps
+ return final_deps
+
+
def sort_libpaths(libpaths: T.List[str], refpaths: T.List[str]) -> T.List[str]:
"""Sort <libpaths> according to <refpaths>