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.
pull/11742/head
Xavier Claessens 2 years ago
parent 2dadc3ae5b
commit 01949df4f6
  1. 15
      mesonbuild/build.py
  2. 2
      mesonbuild/modules/rust.py

@ -17,7 +17,6 @@ from collections import defaultdict, OrderedDict
from dataclasses import dataclass, field, InitVar from dataclasses import dataclass, field, InitVar
from functools import lru_cache from functools import lru_cache
import abc import abc
import copy
import hashlib import hashlib
import itertools, pathlib import itertools, pathlib
import os import os
@ -988,18 +987,6 @@ class BuildTarget(Target):
'Link_depends arguments must be strings, Files, ' 'Link_depends arguments must be strings, Files, '
'or a Custom Target, or lists thereof.') '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: def extract_objects(self, srclist: T.List[T.Union['FileOrString', 'GeneratedTypes']]) -> ExtractedObjects:
sources_set = set(self.sources) sources_set = set(self.sources)
generated_set = set(self.generated) generated_set = set(self.generated)
@ -1073,7 +1060,7 @@ class BuildTarget(Target):
def process_kwargs(self, kwargs): def process_kwargs(self, kwargs):
self.process_kwargs_base(kwargs) self.process_kwargs_base(kwargs)
self.copy_kwargs(kwargs) self.original_kwargs = kwargs
kwargs.get('modules', []) kwargs.get('modules', [])
self.need_install = kwargs.get('install', self.need_install) self.need_install = kwargs.get('install', self.need_install)
llist = extract_as_list(kwargs, 'link_with') llist = extract_as_list(kwargs, 'link_with')

@ -139,7 +139,7 @@ class RustModule(ExtensionModule):
tkwargs['args'] = extra_args + ['--test', '--format', 'pretty'] tkwargs['args'] = extra_args + ['--test', '--format', 'pretty']
tkwargs['protocol'] = 'rust' 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 # Don't mutate the shallow copied list, instead replace it with a new
# one # one
new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test'] new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test']

Loading…
Cancel
Save