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/compilers/__init__.py | 2 ++ mesonbuild/compilers/compilers.py | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'mesonbuild/compilers') diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index b378a63..a4e3943 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -30,6 +30,7 @@ __all__ = [ 'is_llvm_ir', 'is_object', 'is_source', + 'is_known_suffix', 'lang_suffixes', 'sort_clink', @@ -115,6 +116,7 @@ from .compilers import ( is_llvm_ir, is_object, is_library, + is_known_suffix, lang_suffixes, sort_clink, CompilerArgs, diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index e8e72cf..0df6aea 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -14,6 +14,7 @@ import contextlib, os.path, re, tempfile import collections.abc +import itertools import typing as T from ..linkers import StaticLinker, GnuLikeDynamicLinkerMixin, SolarisDynamicLinker @@ -72,6 +73,7 @@ clink_suffixes = () for _l in clink_langs + ('vala',): clink_suffixes += lang_suffixes[_l] clink_suffixes += ('h', 'll', 's') +all_suffixes = set(itertools.chain(*lang_suffixes.values(), clink_suffixes)) # Languages that should use LDFLAGS arguments when linking. languages_using_ldflags = ('objcpp', 'cpp', 'objc', 'c', 'fortran', 'd', 'cuda') @@ -144,6 +146,13 @@ def is_library(fname): suffix = fname.split('.')[-1] return suffix in lib_suffixes +def is_known_suffix(fname): + if hasattr(fname, 'fname'): + fname = fname.fname + suffix = fname.split('.')[-1] + + return suffix in all_suffixes + cuda_buildtype_args = {'plain': [], 'debug': [], 'debugoptimized': [], -- cgit v1.1