From 01949df4f62258941c128150ecdb424aa9286f45 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 27 Apr 2023 13:27:46 -0400 Subject: [PATCH] build: Don't do a deep copy of kwargs It seems to only be used by the Rust module now, and it already does a copy. --- mesonbuild/build.py | 15 +-------------- mesonbuild/modules/rust.py | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 1dcc99843..8d42dbd40 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -17,7 +17,6 @@ from collections import defaultdict, OrderedDict from dataclasses import dataclass, field, InitVar from functools import lru_cache import abc -import copy import hashlib import itertools, pathlib import os @@ -988,18 +987,6 @@ class BuildTarget(Target): 'Link_depends arguments must be strings, Files, ' 'or a Custom Target, or lists thereof.') - def get_original_kwargs(self): - return self.kwargs - - def copy_kwargs(self, kwargs): - self.kwargs = copy.copy(kwargs) - for k, v in self.kwargs.items(): - if isinstance(v, list): - self.kwargs[k] = listify(v, flatten=True) - for t in ['dependencies', 'link_with', 'include_directories', 'sources']: - if t in self.kwargs: - self.kwargs[t] = listify(self.kwargs[t], flatten=True) - def extract_objects(self, srclist: T.List[T.Union['FileOrString', 'GeneratedTypes']]) -> ExtractedObjects: sources_set = set(self.sources) generated_set = set(self.generated) @@ -1073,7 +1060,7 @@ class BuildTarget(Target): def process_kwargs(self, kwargs): self.process_kwargs_base(kwargs) - self.copy_kwargs(kwargs) + self.original_kwargs = kwargs kwargs.get('modules', []) self.need_install = kwargs.get('install', self.need_install) llist = extract_as_list(kwargs, 'link_with') diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index bf1fd1dda..6052ac4d6 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -139,7 +139,7 @@ class RustModule(ExtensionModule): tkwargs['args'] = extra_args + ['--test', '--format', 'pretty'] tkwargs['protocol'] = 'rust' - new_target_kwargs = base_target.kwargs.copy() + new_target_kwargs = base_target.original_kwargs.copy() # Don't mutate the shallow copied list, instead replace it with a new # one new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test']