diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-27 14:40:34 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-27 14:40:34 +0530 |
commit | 001cf52c3a10aa4d2b0db5ec008fb5d2160ce23e (patch) | |
tree | fdffc3df42e987632a9da67a643d643fcbc158e8 /mesonbuild/compilers.py | |
parent | 58131c05153f947c37362dba4248bdaca7ebcbfa (diff) | |
download | meson-001cf52c3a10aa4d2b0db5ec008fb5d2160ce23e.zip meson-001cf52c3a10aa4d2b0db5ec008fb5d2160ce23e.tar.gz meson-001cf52c3a10aa4d2b0db5ec008fb5d2160ce23e.tar.bz2 |
Try even harder to use the C compiler for assembly
Now as long as you have a C compiler available in the project, it will
be used to compile assembly even if the target contains a C++ compiler
and even if the target contains only assembly and C++ sources.
Earlier, the order in which sources appeared in a target would decide
which compiler would be used.
However, if the project only provides a C++ compiler, that will be
used for compiling assembly sources.
If this breaks your use-case, please tell us.
Includes a test that ensures that all of the above is adhered to.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 11 |
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 |