From 1464ac6ed54cad795444d240d3bdb83568f5601f Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 9 Feb 2020 18:49:03 +0000 Subject: Improve error reported when language has no compiler This gives consistent reporting of this error for all platforms. Also, reporting this error when constructing the BuildTarget, rather than discovering the problem during backend generation means that the error is reported against with a location. --- mesonbuild/build.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'mesonbuild/build.py') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 0a8ca45..7637885 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -28,7 +28,7 @@ from .mesonlib import ( extract_as_list, typeslistify, stringlistify, classify_unity_sources, get_filenames_templates_dict, substitute_values, has_path_sep, ) -from .compilers import Compiler, is_object, clink_langs, sort_clink, lang_suffixes +from .compilers import Compiler, is_object, clink_langs, sort_clink, lang_suffixes, is_known_suffix from .linkers import StaticLinker from .interpreterbase import FeatureNew @@ -652,14 +652,24 @@ class BuildTarget(Target): sources.append(s) if sources: # For each source, try to add one compiler that can compile it. - # It's ok if no compilers can do so, because users are expected to - # be able to add arbitrary non-source files to the sources list. + # + # If it has a suffix that belongs to a known language, we must have + # a compiler for that language. + # + # Otherwise, it's ok if no compilers can compile it, because users + # are expected to be able to add arbitrary non-source files to the + # sources list for s in sources: for lang, compiler in compilers.items(): if compiler.can_compile(s): if lang not in self.compilers: self.compilers[lang] = compiler break + else: + if is_known_suffix(s): + raise MesonException('No {} machine compiler for "{}"'. + format(self.for_machine.get_lower_case_name(), s)) + # Re-sort according to clink_langs self.compilers = OrderedDict(sorted(self.compilers.items(), key=lambda t: sort_clink(t[0]))) -- cgit v1.1