From f021c37191d19bd0d2c12acee4d78bcb91fa1218 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 20 Nov 2024 13:27:43 +0100 Subject: ninjabackend: remove cratetype variable Since we're going to split generate_rust_target() in multiple functions, eliminate the only variable that spans large parts of it. The cratetype ninja variable has been unused since Meson started invoking rustc directly nine years ago (commit d952812b1, "Fix Rust to work with 1.3 release. Closes #277.", 2015-10-11). Reviewed-by: Dylan Baker Signed-off-by: Paolo Bonzini --- mesonbuild/backend/ninjabackend.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 73a809cd4..24758866c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1994,14 +1994,13 @@ class NinjaBackend(backends.Backend): if main_rust_file is None: raise RuntimeError('A Rust target has no Rust sources. This is weird. Also a bug. Please report') target_name = self.get_target_filename(target) - cratetype = target.rust_crate_type - args.extend(['--crate-type', cratetype]) + args.extend(['--crate-type', target.rust_crate_type]) # If we're dynamically linking, add those arguments # # Rust is super annoying, calling -C link-arg foo does not work, it has # to be -C link-arg=foo - if cratetype in {'bin', 'dylib'}: + if target.rust_crate_type in {'bin', 'dylib'}: args.extend(rustc.get_linker_always_args()) args += self.generate_basic_compiler_args(target, rustc) @@ -2116,7 +2115,7 @@ class NinjaBackend(backends.Backend): and dep.rust_crate_type == 'dylib' for dep in target_deps) - if cratetype in {'dylib', 'proc-macro'} or has_rust_shared_deps: + if target.rust_crate_type in {'dylib', 'proc-macro'} or has_rust_shared_deps: # add prefer-dynamic if any of the Rust libraries we link # against are dynamic or this is a dynamic library itself, # otherwise we'll end up with multiple implementations of libstd. @@ -2126,12 +2125,12 @@ class NinjaBackend(backends.Backend): args += self.get_build_rpath_args(target, rustc) proc_macro_dylib_path = None - if cratetype == 'proc-macro': + if target.rust_crate_type == 'proc-macro': proc_macro_dylib_path = self.get_target_filename_abs(target) self._add_rust_project_entry(target.name, os.path.abspath(os.path.join(self.environment.build_dir, main_rust_file)), - args, cratetype, target_name, + args, target.rust_crate_type, target_name, bool(target.subproject), proc_macro_dylib_path, project_deps) @@ -2144,7 +2143,6 @@ class NinjaBackend(backends.Backend): element.add_dep(deps) element.add_item('ARGS', args) element.add_item('targetdep', depfile) - element.add_item('cratetype', cratetype) self.add_build(element) if isinstance(target, build.SharedLibrary): self.generate_shsym(target) -- cgit v1.2.3