diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-01-19 10:12:38 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-01-19 10:12:38 -0800 |
commit | 3ae115b57ad7f8eca09c03f5bd6bf65604dcaf59 (patch) | |
tree | 7e2c18c073c0b6d2463114d4d6ee9ce5633fd57a /mesonbuild | |
parent | c64d4070763b2daf82a50a7b4f5b130b2bb91062 (diff) | |
download | meson-3ae115b57ad7f8eca09c03f5bd6bf65604dcaf59.zip meson-3ae115b57ad7f8eca09c03f5bd6bf65604dcaf59.tar.gz meson-3ae115b57ad7f8eca09c03f5bd6bf65604dcaf59.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 9 | ||||
-rw-r--r-- | mesonbuild/build.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/unstable_rust.py | 2 |
3 files changed, 5 insertions, 12 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d66708c..d3350bb 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.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: diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 017b0f0..fa7c140 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -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 diff --git a/mesonbuild/modules/unstable_rust.py b/mesonbuild/modules/unstable_rust.py index 02369b6..d215376 100644 --- a/mesonbuild/modules/unstable_rust.py +++ b/mesonbuild/modules/unstable_rust.py @@ -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', [])) |