aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 22fb522..76a9067 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -57,6 +57,17 @@ clike_suffixes += ('h', 'll', 's')
# All these are only for C-like languages; see `clike_langs` above.
+def sort_clike(lang):
+ '''
+ Sorting function to sort the list of languages according to
+ reversed(compilers.clike_langs) and append the unknown langs in the end.
+ The purpose is to prefer C over C++ for files that can be compiled by
+ both such as assembly, C, etc. Also applies to ObjC, ObjC++, etc.
+ '''
+ if lang not in clike_langs:
+ return 1
+ return -clike_langs.index(lang)
+
def is_header(fname):
if hasattr(fname, 'fname'):
fname = fname.fname