aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-03-23 18:56:40 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-03-24 12:27:06 -0400
commitc8c8aeef0fcc6aba31b8d4775cfaec368f102604 (patch)
treef48062396553075a948fd6b93e08b5ba58b320c8
parentf2d21bf8a98fe4eb528a077f3faf5d68cd35c244 (diff)
downloadmeson-c8c8aeef0fcc6aba31b8d4775cfaec368f102604.zip
meson-c8c8aeef0fcc6aba31b8d4775cfaec368f102604.tar.gz
meson-c8c8aeef0fcc6aba31b8d4775cfaec368f102604.tar.bz2
build.py: Simplify validate_sources()
There is no need to go through all sources again, we already did that to populate self.compilers. When cs or java compilers are in the list, then there must be only one compiler. The code was also not considering generate sources any way.
-rw-r--r--mesonbuild/build.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 5c997e8..00a737a 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -971,21 +971,9 @@ class BuildTarget(Target):
return missing_languages
def validate_sources(self):
- if not self.sources:
- return
- for lang in ('cs', 'java'):
- if lang in self.compilers:
- check_sources = list(self.sources)
- compiler = self.compilers[lang]
- if not self.can_compile_remove_sources(compiler, check_sources):
- raise InvalidArguments(f'No {lang} sources found in target {self.name!r}')
- if check_sources:
- m = '{0} targets can only contain {0} files:\n'.format(lang.capitalize())
- m += '\n'.join([repr(c) for c in check_sources])
- raise InvalidArguments(m)
- # CSharp and Java targets can't contain any other file types
- assert len(self.compilers) == 1
- return
+ if len(self.compilers) > 1 and any(lang in self.compilers for lang in {'cs', 'java'}):
+ langs = ', '.join(self.compilers.keys())
+ raise InvalidArguments(f'Cannot mix those languages into a target: {langs}')
def process_link_depends(self, sources, environment):
"""Process the link_depends keyword argument.