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.
pull/10164/head
Xavier Claessens 3 years ago committed by Xavier Claessens
parent f2d21bf8a9
commit c8c8aeef0f
  1. 18
      mesonbuild/build.py

@ -971,21 +971,9 @@ class BuildTarget(Target):
return missing_languages return missing_languages
def validate_sources(self): def validate_sources(self):
if not self.sources: if len(self.compilers) > 1 and any(lang in self.compilers for lang in {'cs', 'java'}):
return langs = ', '.join(self.compilers.keys())
for lang in ('cs', 'java'): raise InvalidArguments(f'Cannot mix those languages into a target: {langs}')
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
def process_link_depends(self, sources, environment): def process_link_depends(self, sources, environment):
"""Process the link_depends keyword argument. """Process the link_depends keyword argument.

Loading…
Cancel
Save