From 6a5c6fb439c9351d513c63ff7eb028dde4c3f1c0 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 12 Feb 2020 18:47:51 +0000 Subject: Be more careful about the use of repr() in error messages Generally, we'd want to use str() rather than repr() in error messages anyhow, as that explicitly gives something designed to be read by humans. Sometimes {!r} is being used as a shortcut to avoid writing the quotes in '{!s}'. Unfortunately, these things aren't quite the same, as the repr of a string containing '\' (the path separator on Windows) will have those escaped. We don't have a good string representation to use for the arbitrary internal object used as an argument for install_data() when it's neither a string nor file (which doesn't lead to a good error message), so drop that for the moment. --- mesonbuild/interpreter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/interpreter.py') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index dd1e57b..11eceae 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3897,7 +3897,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self absname = os.path.join(self.environment.get_source_dir(), buildfilename) if not os.path.isfile(absname): self.subdir = prev_subdir - raise InterpreterException('Non-existent build file {!r}'.format(buildfilename)) + raise InterpreterException("Non-existent build file '{!s}'".format(buildfilename)) with open(absname, encoding='utf8') as f: code = f.read() assert(isinstance(code, str)) @@ -3945,7 +3945,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self elif isinstance(s, str): source_strings.append(s) else: - raise InvalidArguments('Argument {!r} must be string or file.'.format(s)) + raise InvalidArguments('Argument must be string or file.') sources += self.source_strings_to_files(source_strings) install_dir = kwargs.get('install_dir', None) if not isinstance(install_dir, (str, type(None))): -- cgit v1.1 From 10817381131ba58b243e13d76f97be59d65a5a8a Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 12 Feb 2020 19:13:43 +0000 Subject: Check before compiler detection if 'c' language is present when adding 'vala' For the sake of a consistent error message (irrespective of if 'valac' is present or not), check if the 'c' language is present if we are adding 'vala' before (rather than after) we do compiler detection. --- mesonbuild/interpreter.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'mesonbuild/interpreter.py') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 11eceae..9811b0a 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3117,6 +3117,12 @@ external dependencies (including libraries) must go to "dependencies".''') return should def add_languages_for(self, args, required, for_machine: MachineChoice): + langs = set(self.coredata.compilers[for_machine].keys()) + langs.update(args) + if 'vala' in langs: + if 'c' not in langs: + raise InterpreterException('Compiling Vala requires C. Add C to your project languages and rerun Meson.') + success = True for lang in sorted(args, key=compilers.sort_clink): lang = lang.lower() @@ -3154,11 +3160,6 @@ external dependencies (including libraries) must go to "dependencies".''') mlog.bold(' '.join(comp.linker.get_exelist())), comp.linker.id, comp.linker.version) self.build.ensure_static_linker(comp) - langs = self.coredata.compilers[for_machine].keys() - if 'vala' in langs: - if 'c' not in langs: - raise InterpreterException('Compiling Vala requires C. Add C to your project languages and rerun Meson.') - return success def program_from_file_for(self, for_machine, prognames, silent): -- cgit v1.1 From b647ce1b63961a76a6de63a3586015a4c5d56b44 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 12 Feb 2020 14:17:50 +0000 Subject: Cosmetic tweak to error message for incdir() with an absolute path Cosmetic tweak to the error message for incdir() with an absolute path. Don't split the message in the middle of a sentence at a point which may or may not correspond to the terminal width. --- mesonbuild/interpreter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mesonbuild/interpreter.py') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 9811b0a..0dfb616 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -4220,8 +4220,9 @@ This will become a hard error in the future.''' % kwargs['input'], location=self for a in incdir_strings: if a.startswith(src_root): - raise InvalidArguments('''Tried to form an absolute path to a source dir. You should not do that but use -relative paths instead. + raise InvalidArguments('Tried to form an absolute path to a source dir. ' + 'You should not do that but use relative paths instead.' + ''' To get include path to any directory relative to the current dir do -- cgit v1.1