From 8f68f5435dfbb2f476aaa7927399e16fdc80422e Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 10 Mar 2022 10:52:12 -0800 Subject: [PATCH] interpreter: add type restrictions to declare_dependency link_whole Including that we don't accept SharedLibraries or CustomTarget[Index]s that are a shared library --- mesonbuild/interpreter/interpreter.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index e787b7ae6..df00ed35f 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -687,10 +687,19 @@ class Interpreter(InterpreterBase, HoldableObject): for d in deps: if not isinstance(d, dependencies.Dependency): raise InterpreterException('Invalid dependency') + + dep_err = 'declare_dependency: Entries in "{}" may only be self-built targets, external dependencies (including libraries) must go to "dependencies".' + for l in libs: if isinstance(l, dependencies.Dependency): - raise InterpreterException('''Entries in "link_with" may only be self-built targets, -external dependencies (including libraries) must go to "dependencies".''') + raise InvalidArguments(dep_err.format('link_with')) + for l in libs_whole: + if isinstance(l, dependencies.Dependency): + raise InvalidArguments(dep_err.format('link_whole')) + if isinstance(l, build.SharedLibrary): + raise InvalidArguments('declare_dependency: SharedLibrary objects are not allowed in "link_whole"') + if isinstance(l, (build.CustomTarget, build.CustomTargetIndex)) and l.links_dynamically(): + raise InvalidArguments('declare_dependency: CustomTarget and CustomTargetIndex returning shared libaries are not allowed in "link_whole"') dep = dependencies.InternalDependency(version, incs, compile_args, link_args, libs, libs_whole, sources, deps, variables, d_module_versions, d_import_dirs)