Better error message when trying to use subprojects as dependencies.

pull/767/head
Jussi Pakkanen 9 years ago
parent 69433025ca
commit 165f8a913d
  1. 9
      mesonbuild/build.py
  2. 4
      mesonbuild/interpreter.py

@ -533,7 +533,14 @@ class BuildTarget():
self.external_deps.append(dep)
self.process_sourcelist(dep.get_sources())
else:
raise InvalidArguments('Argument is not an external dependency')
# This is a bit of a hack. We do not want Build to know anything
# about the interpreter so we can't import it and use isinstance.
# This should be reliable enough.
if hasattr(dep, 'subproject'):
raise InvalidArguments('''Tried to use subproject object as a dependency.
You probably wanted to use a dependency declared in it instead. Access it
by calling get_variable() on the subproject object.''')
raise InvalidArguments('Argument is not an external dependency.')
def get_external_deps(self):
return self.external_deps

@ -567,7 +567,7 @@ class SubprojectHolder(InterpreterObject):
def __init__(self, subinterpreter):
super().__init__()
self.subinterpreter = subinterpreter
self.held_object = subinterpreter
self.methods.update({'get_variable' : self.get_variable_method,
})
@ -577,7 +577,7 @@ class SubprojectHolder(InterpreterObject):
varname = args[0]
if not isinstance(varname, str):
raise InterpreterException('Get_variable takes a string argument.')
return self.subinterpreter.variables[varname]
return self.held_object.variables[varname]
class CompilerHolder(InterpreterObject):
def __init__(self, compiler, env):

Loading…
Cancel
Save