build.py: Simplify uses_rust()

There is no need to check all source files again, if there are .rs
sources then rust compiler is in self.compilers already.
pull/10164/head
Xavier Claessens 3 years ago committed by Xavier Claessens
parent c8c8aeef0f
commit b66a477bbc
  1. 20
      mesonbuild/build.py

@ -1582,25 +1582,7 @@ You probably should put it in link_with instead.''')
raise AssertionError(f'Could not get a dynamic linker for build target {self.name!r}')
def uses_rust(self) -> bool:
"""Is this target a rust target."""
if self.sources:
first_file = self.sources[0]
if first_file.fname.endswith('.rs'):
return True
elif self.generated:
if self.generated[0].get_outputs()[0].endswith('.rs'):
return True
elif self.structured_sources:
for v in self.structured_sources.sources.values():
for s in v:
if isinstance(s, (str, File)):
if s.endswith('.rs'):
return True
else:
for ss in s.get_outputs():
if ss.endswith('.rs'):
return True
return False
return 'rust' in self.compilers
def get_using_msvc(self) -> bool:
'''

Loading…
Cancel
Save