From 6f4406928bd7c6beeb85502153c13841af4e3239 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 21 Oct 2016 07:02:25 +0530 Subject: [PATCH] BuildTarget: Add compilers needed by generated sources --- mesonbuild/build.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index e16f1183c..20b4425f3 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -312,6 +312,13 @@ class BuildTarget(): msg = 'Bad source of type {!r} in target {!r}.'.format(type(s).__name__, self.name) 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 @@ -322,16 +329,23 @@ class BuildTarget(): return removed def process_compilers(self): - if len(self.sources) == 0: + if len(self.sources) + len(self.generated) == 0: return sources = list(self.sources) + for gensrc in self.generated: + sources += gensrc.get_outputs() + # Populate list of compilers if self.is_cross: compilers = self.environment.coredata.cross_compilers else: compilers = self.environment.coredata.compilers for lang, compiler in compilers.items(): - if self.can_compile_remove_sources(compiler, sources): + if self.can_compile_sources(compiler, sources): self.compilers[lang] = compiler + # If all our sources are Vala, our target also needs the C compiler but + # it won't get added above. + if 'vala' in self.compilers and 'c' not in self.compilers: + self.compilers['c'] = compilers['c'] def validate_sources(self): if len(self.sources) == 0: