Fix remaining Interpreter object leaks.

pull/2017/head
Jussi Pakkanen 8 years ago
parent ecde592b86
commit ad3dc937f1
  1. 24
      mesonbuild/build.py
  2. 9
      mesonbuild/interpreter.py
  3. 8
      mesonbuild/mesonlib.py

@ -546,10 +546,14 @@ class BuildTarget(Target):
d = [d] d = [d]
newd = [] newd = []
for i in d: for i in d:
if hasattr(i, 'held_object'): if isinstance(i, list):
newd.append(i.held_object) i = self.unpack_holder(i)
else: elif hasattr(i, 'held_object'):
newd.append(i) i = i.held_object
for t in ['dependencies', 'link_with', 'include_directories', 'sources']:
if hasattr(i, t):
setattr(i, t, self.unpack_holder(getattr(i, t)))
newd.append(i)
return newd return newd
def copy_kwargs(self, kwargs): def copy_kwargs(self, kwargs):
@ -557,10 +561,14 @@ class BuildTarget(Target):
# This sucks quite badly. Arguments # This sucks quite badly. Arguments
# are holders but they can't be pickled # are holders but they can't be pickled
# so unpack those known. # so unpack those known.
if 'dependencies' in self.kwargs: for k, v in self.kwargs.items():
self.kwargs['dependencies'] = self.unpack_holder(self.kwargs['dependencies']) if isinstance(v, list):
if 'link_with' in self.kwargs: self.kwargs[k] = self.unpack_holder(v)
self.kwargs['link_with'] = self.unpack_holder(self.kwargs['link_with']) if hasattr(v, 'held_object'):
self.kwargs[k] = v.held_object
for t in ['dependencies', 'link_with', 'include_directories', 'sources']:
if t in self.kwargs:
self.kwargs[t] = self.unpack_holder(self.kwargs[t])
def extract_objects(self, srclist): def extract_objects(self, srclist):
obj_src = [] obj_src = []

@ -1522,7 +1522,13 @@ class Interpreter(InterpreterBase):
if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)): if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)):
raise InterpreterException('Dependencies must be external deps') raise InterpreterException('Dependencies must be external deps')
final_deps.append(d) final_deps.append(d)
dep = dependencies.InternalDependency(version, incs, compile_args, link_args, libs, sources, final_deps) dep = dependencies.InternalDependency(version,
mesonlib.unholder_array(incs),
compile_args,
link_args,
mesonlib.unholder_array(libs),
mesonlib.unholder_array(sources),
final_deps)
return DependencyHolder(dep) return DependencyHolder(dep)
@noKwargs @noKwargs
@ -2289,6 +2295,7 @@ class Interpreter(InterpreterBase):
for i in cmd_args: for i in cmd_args:
if not isinstance(i, (str, mesonlib.File, TargetHolder)): if not isinstance(i, (str, mesonlib.File, TargetHolder)):
raise InterpreterException('Command line arguments must be strings, files or targets.') raise InterpreterException('Command line arguments must be strings, files or targets.')
cmd_args = mesonlib.unholder_array(cmd_args)
env = self.unpack_env_kwarg(kwargs) env = self.unpack_env_kwarg(kwargs)
should_fail = kwargs.get('should_fail', False) should_fail = kwargs.get('should_fail', False)
if not isinstance(should_fail, bool): if not isinstance(should_fail, bool):

@ -709,6 +709,14 @@ def windows_proof_rmtree(f):
# Try one last time and throw if it fails. # Try one last time and throw if it fails.
shutil.rmtree(f) shutil.rmtree(f)
def unholder_array(entries):
result = []
for e in entries:
if hasattr(e, 'held_object'):
e = e.held_object
result.append(e)
return result
class OrderedSet(collections.MutableSet): class OrderedSet(collections.MutableSet):
"""A set that preserves the order in which items are added, by first """A set that preserves the order in which items are added, by first
insertion. insertion.

Loading…
Cancel
Save