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

@ -1522,7 +1522,13 @@ class Interpreter(InterpreterBase):
if not isinstance(d, (dependencies.Dependency, dependencies.ExternalLibrary, dependencies.InternalDependency)):
raise InterpreterException('Dependencies must be external deps')
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)
@noKwargs
@ -2289,6 +2295,7 @@ class Interpreter(InterpreterBase):
for i in cmd_args:
if not isinstance(i, (str, mesonlib.File, TargetHolder)):
raise InterpreterException('Command line arguments must be strings, files or targets.')
cmd_args = mesonlib.unholder_array(cmd_args)
env = self.unpack_env_kwarg(kwargs)
should_fail = kwargs.get('should_fail', False)
if not isinstance(should_fail, bool):

@ -709,6 +709,14 @@ def windows_proof_rmtree(f):
# Try one last time and throw if it fails.
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):
"""A set that preserves the order in which items are added, by first
insertion.

Loading…
Cancel
Save