aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-11-23 23:03:35 +0100
committerGitHub <noreply@github.com>2020-11-24 00:03:35 +0200
commit0deab2ee9efc2ffe9e43f2787611e34656e6a304 (patch)
treefd60e29d4d91a6d566af3a0bfec1f8f6db0c2714 /mesonbuild/interpreter.py
parentb53505a9dc2e82a5040d3427246935c50b63184b (diff)
downloadmeson-0deab2ee9efc2ffe9e43f2787611e34656e6a304.zip
meson-0deab2ee9efc2ffe9e43f2787611e34656e6a304.tar.gz
meson-0deab2ee9efc2ffe9e43f2787611e34656e6a304.tar.bz2
compiler: allow non-built internal dependencies as arguments
Allow methods on the compiler object to receive internal dependencies, as long as they only specify compiler/linker arguments or other dependencies that satisfy the same requirements. This is useful if you're using internal dependencies to add special "-D" flags such as -DNCURSES_WIDECHAR, -D_XOPEN_SOURCE_EXTENDED or -DGLIB_STATIC_COMPILATION.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 5337984..83acc01 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1120,14 +1120,18 @@ class CompilerHolder(InterpreterObject):
return endl
if endl is None:
endl = ''
- tpl = msg_many if len(deps) > 1 else msg_single
names = []
for d in deps:
+ if isinstance(d, dependencies.InternalDependency):
+ continue
if isinstance(d, dependencies.ExternalLibrary):
name = '-l' + d.name
else:
name = d.name
names.append(name)
+ if not names:
+ return None
+ tpl = msg_many if len(names) > 1 else msg_single
return tpl.format(', '.join(names)) + endl
@noPosargs
@@ -1165,16 +1169,15 @@ class CompilerHolder(InterpreterObject):
def determine_dependencies(self, kwargs, endl=':'):
deps = kwargs.get('dependencies', None)
if deps is not None:
- deps = listify(deps)
final_deps = []
- for d in deps:
- try:
- d = d.held_object
- except Exception:
- pass
- if isinstance(d, InternalDependency) or not isinstance(d, Dependency):
- raise InterpreterException('Dependencies must be external dependencies')
- final_deps.append(d)
+ while deps:
+ next_deps = []
+ for d in unholder(listify(deps)):
+ if not isinstance(d, Dependency) or d.is_built():
+ raise InterpreterException('Dependencies must be external dependencies')
+ final_deps.append(d)
+ next_deps.extend(d.ext_deps)
+ deps = next_deps
deps = final_deps
return deps, self._dep_msg(deps, endl)