aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-03-24 18:31:22 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-03-27 11:25:22 +0530
commit14d0f381580222f4b4eac376f514fcfcfdb6ee4c (patch)
tree5105ec03bd92fc4fc5dc528aaa6c886c572baec0 /mesonbuild/interpreter.py
parentff4b32741acb36e8b2cf3d83fe0d513ad5753e59 (diff)
downloadmeson-14d0f381580222f4b4eac376f514fcfcfdb6ee4c.zip
meson-14d0f381580222f4b4eac376f514fcfcfdb6ee4c.tar.gz
meson-14d0f381580222f4b4eac376f514fcfcfdb6ee4c.tar.bz2
Try harder to use the C compiler for compiling asm
Use an ordered dict for the compiler dictionary and sort it according to a priority order: fortran, c, c++, etc. This also ensures that builds are reproducible because it would be a toss-up whether a C or a C++ compiler would be used based on the order in which compilers.items() would return items. Closes https://github.com/mesonbuild/meson/issues/1370
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 5d3c095..56e5b8f 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1752,10 +1752,22 @@ class Interpreter(InterpreterBase):
self.coredata.compiler_options = new_options
return comp, cross_comp
+ @staticmethod
+ 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 compilers.clike_langs:
+ return 1
+ return -compilers.clike_langs.index(lang)
+
def add_languages(self, args, required):
success = True
need_cross_compiler = self.environment.is_cross_build() and self.environment.cross_info.need_cross_compiler()
- for lang in args:
+ for lang in sorted(args, key=self.sort_clike):
lang = lang.lower()
if lang in self.coredata.compilers:
comp = self.coredata.compilers[lang]