From 14d0f381580222f4b4eac376f514fcfcfdb6ee4c Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 24 Mar 2017 18:31:22 +0530 Subject: 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 --- mesonbuild/build.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'mesonbuild/build.py') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 2806331..c28a8a4 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -391,13 +391,6 @@ class BuildTarget(Target): raise InvalidArguments(msg) @staticmethod - def can_compile_sources(compiler, sources): - for s in sources: - if compiler.can_compile(s): - return True - return False - - @staticmethod def can_compile_remove_sources(compiler, sources): removed = False for s in sources[:]: @@ -442,13 +435,15 @@ class BuildTarget(Target): if not s.endswith(lang_suffixes['vala']): sources.append(s) if sources: - # Add compilers based on the above sources - for lang, compiler in compilers.items(): - # We try to be conservative because sometimes people add files - # in the list of sources that we can't determine the type based - # just on the suffix. - if self.can_compile_sources(compiler, sources): - self.compilers[lang] = compiler + # 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. + 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: # No source files, target consists of only object files of unknown # origin. Just add the first clike compiler that we have and hope -- cgit v1.1