Replace NinjaBackend is_rust_target with build.uses_rust

we have two functions to do the exact same thing, and they're basically
implemented the same way. Instead, let's just use the BuildTarget one,
as it's more generally available.
pull/8158/head
Dylan Baker 4 years ago
parent c64d407076
commit 3ae115b57a
  1. 9
      mesonbuild/backend/ninjabackend.py
  2. 6
      mesonbuild/build.py
  3. 2
      mesonbuild/modules/unstable_rust.py

@ -691,13 +691,6 @@ int dummy;
src_block['sources'] += sources
src_block['generated_sources'] += generated_sources
def is_rust_target(self, target):
if len(target.sources) > 0:
first_file = target.sources[0]
if first_file.fname.endswith('.rs'):
return True
return False
def generate_target(self, target):
try:
if isinstance(target, build.BuildTarget):
@ -723,7 +716,7 @@ int dummy;
if isinstance(target, build.Jar):
self.generate_jar_target(target)
return
if self.is_rust_target(target):
if target.uses_rust():
self.generate_rust_target(target)
return
if 'cs' in target.compilers:

@ -1412,7 +1412,7 @@ You probably should put it in link_with instead.''')
m = 'Could not get a dynamic linker for build target {!r}'
raise AssertionError(m.format(self.name))
def get_using_rustc(self) -> bool:
def uses_rust(self) -> bool:
"""Is this target a rust target."""
return self.sources and self.sources[0].fname.endswith('.rs')
@ -1687,7 +1687,7 @@ class Executable(BuildTarget):
self.import_filename = self.gcc_import_filename
if m.is_windows() and ('cs' in self.compilers or
self.get_using_rustc() or
self.uses_rust() or
self.get_using_msvc()):
self.debug_filename = self.name + '.pdb'
@ -1877,7 +1877,7 @@ class SharedLibrary(BuildTarget):
suffix = 'dll'
self.vs_import_filename = '{0}{1}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
if self.get_using_rustc():
if self.uses_rust():
# Shared library is of the form foo.dll
prefix = ''
# Import library is called foo.dll.lib

@ -85,7 +85,7 @@ class RustModule(ExtensionModule):
base_target: BuildTarget = unholder(args[1])
if not isinstance(base_target, BuildTarget):
raise InterpreterException('Second positional argument to rustmod.test() must be a library or executable')
if not base_target.get_using_rustc():
if not base_target.uses_rust():
raise InterpreterException('Second positional argument to rustmod.test() must be a rust based target')
extra_args = stringlistify(kwargs.get('args', []))

Loading…
Cancel
Save