aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-14 17:47:52 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-10-23 18:02:19 +0530
commit70265c3782f8c4f74b6f7984d1bec708af008f56 (patch)
treebf4b0671469d326b27993a137ec287d6ab012daf /mesonbuild/interpreter.py
parentf79c4396f894aedd14f41d5dbd1474096ef65d4a (diff)
downloadmeson-70265c3782f8c4f74b6f7984d1bec708af008f56.zip
meson-70265c3782f8c4f74b6f7984d1bec708af008f56.tar.gz
meson-70265c3782f8c4f74b6f7984d1bec708af008f56.tar.bz2
Improve error when using the dependencies kwarg
The error message is misleading (talks about external dependencies), and doesn't tell you what you need to do (use the output of declare_dependency, dependency, or find_library). At the same time rename add_external_deps to add_deps since it adds internal deps too. Plus many more error message improvements all over the place.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py43
1 files changed, 30 insertions, 13 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index cc46665..dd2a227 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1559,7 +1559,7 @@ class Interpreter():
r = wrap.Resolver(os.path.join(self.build.environment.get_source_dir(), self.subproject_dir))
resolved = r.resolve(dirname)
if resolved is None:
- msg = 'Subproject directory {!r} does not exist and can not be downloaded.'
+ msg = 'Subproject directory {!r} does not exist and cannot be downloaded.'
raise InterpreterException(msg.format(os.path.join(self.subproject_dir, dirname)))
subdir = os.path.join(self.subproject_dir, resolved)
os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True)
@@ -2266,9 +2266,18 @@ requirements use the version keyword argument instead.''')
@stringArgs
def func_add_global_arguments(self, node, args, kwargs):
if self.subproject != '':
- raise InvalidCode('Global arguments can not be set in subprojects because there is no way to make that reliable.')
+ msg = 'Global arguments can not be set in subprojects because ' \
+ 'there is no way to make that reliable.\nPlease only call ' \
+ 'this if is_subproject() returns false. Alternatively, ' \
+ 'define a variable that\ncontains your language-specific ' \
+ 'arguments and add it to the appropriate *_args kwarg ' \
+ 'in each target.'
+ raise InvalidCode(msg)
if self.global_args_frozen:
- raise InvalidCode('Tried to set global arguments after a build target has been declared.\nThis is not permitted. Please declare all global arguments before your targets.')
+ msg = 'Tried to set global arguments after a build target has ' \
+ 'been declared.\nThis is not permitted. Please declare all ' \
+ 'global arguments before your targets.'
+ raise InvalidCode(msg)
if not 'language' in kwargs:
raise InvalidCode('Missing language definition in add_global_arguments')
lang = kwargs['language'].lower()
@@ -2280,11 +2289,20 @@ requirements use the version keyword argument instead.''')
@stringArgs
def func_add_global_link_arguments(self, node, args, kwargs):
if self.subproject != '':
- raise InvalidCode('Global arguments can not be set in subprojects because there is no way to make that reliable.')
+ msg = 'Global link arguments can not be set in subprojects because ' \
+ 'there is no way to make that reliable.\nPlease only call ' \
+ 'this if is_subproject() returns false. Alternatively, ' \
+ 'define a variable that\ncontains your language-specific ' \
+ 'arguments and add it to the appropriate *_args kwarg ' \
+ 'in each target.'
+ raise InvalidCode(msg)
if self.global_args_frozen:
- raise InvalidCode('Tried to set global arguments after a build target has been declared.\nThis is not permitted. Please declare all global arguments before your targets.')
+ msg = 'Tried to set global link arguments after a build target has ' \
+ 'been declared.\nThis is not permitted. Please declare all ' \
+ 'global arguments before your targets.'
+ raise InvalidCode(msg)
if not 'language' in kwargs:
- raise InvalidCode('Missing language definition in add_global_arguments')
+ raise InvalidCode('Missing language definition in add_global_link_arguments')
lang = kwargs['language'].lower()
if lang in self.build.global_link_args:
self.build.global_link_args[lang] += args
@@ -2405,7 +2423,7 @@ requirements use the version keyword argument instead.''')
for l in self.get_used_languages(target):
if self.environment.cross_info.has_stdlib(l) and \
self.subproject != self.environment.cross_info.get_stdlib(l)[0]:
- target.add_external_deps(self.build.cross_stdlibs[l])
+ target.add_deps(self.build.cross_stdlibs[l])
def check_sources_exist(self, subdir, sources):
for s in sources:
@@ -2413,7 +2431,7 @@ requirements use the version keyword argument instead.''')
continue # This means a generated source and they always exist.
fname = os.path.join(subdir, s)
if not os.path.isfile(fname):
- raise InterpreterException('Tried to add non-existing source %s.' % s)
+ raise InterpreterException('Tried to add non-existing source file %s.' % s)
def function_call(self, node):
func_name = node.func_name
@@ -2469,7 +2487,7 @@ requirements use the version keyword argument instead.''')
else:
return posargs[1]
else:
- raise InterpreterException('bool.to_string() must have either no arguments or exactly two string arguments.')
+ raise InterpreterException('bool.to_string() must have either no arguments or exactly two string arguments that signify what values to return for true and false.')
elif method_name == 'to_int':
if obj == True:
return 1
@@ -2509,7 +2527,7 @@ requirements use the version keyword argument instead.''')
return re.sub(r'[^a-zA-Z0-9]', '_', obj)
elif method_name == 'split':
if len(posargs) > 1:
- raise InterpreterException('Split() must have at most one argument.')
+ raise InterpreterException('Split() must have at most one argument.')
elif len(posargs) == 1:
s = posargs[0]
if not isinstance(s, str):
@@ -2530,7 +2548,7 @@ requirements use the version keyword argument instead.''')
try:
return int(obj)
except Exception:
- raise InterpreterException('String can not be converted to int: ' + obj)
+ raise InterpreterException('String {!r} cannot be converted to int'.format(obj))
elif method_name == 'join':
if len(posargs) != 1:
raise InterpreterException('Join() takes exactly one argument.')
@@ -2635,8 +2653,7 @@ requirements use the version keyword argument instead.''')
for i in node.ifs:
result = self.evaluate_statement(i.condition)
if not(isinstance(result, bool)):
- print(result)
- raise InvalidCode('If clause does not evaluate to true or false.')
+ raise InvalidCode('If clause {!r} does not evaluate to true or false.'.format(result))
if result:
self.evaluate_codeblock(i.block)
return