aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-07-01 02:10:02 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-07-01 02:10:02 +0300
commitad3dc937f11af894576032dcad4fb88042bdf253 (patch)
tree14a055d9b4cf26c9d5fe193e6b676ccfc00ca772
parentecde592b86e9c25fc82a612085761c4825017841 (diff)
downloadmeson-ad3dc937f11af894576032dcad4fb88042bdf253.zip
meson-ad3dc937f11af894576032dcad4fb88042bdf253.tar.gz
meson-ad3dc937f11af894576032dcad4fb88042bdf253.tar.bz2
Fix remaining Interpreter object leaks.
-rw-r--r--mesonbuild/build.py24
-rw-r--r--mesonbuild/interpreter.py9
-rw-r--r--mesonbuild/mesonlib.py8
3 files changed, 32 insertions, 9 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 9dd0fa0..a797e9f 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.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 = []
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index d776b05..58a145a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -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):
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index bf6ba98..4760e04 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -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.