diff options
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 8c6e2cd..3dc0c99 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -27,6 +27,7 @@ import os, sys, subprocess, shutil, uuid, re from functools import wraps import importlib +import copy run_depr_printed = False @@ -91,6 +92,10 @@ class InterpreterObject(): return self.methods[method_name](args, kwargs) raise InvalidCode('Unknown method "%s" in object.' % method_name) +class MutableInterpreterObject(InterpreterObject): + def __init__(self): + super().__init__() + class TryRunResultHolder(InterpreterObject): def __init__(self, res): super().__init__() @@ -181,7 +186,7 @@ class ConfigureFileHolder(InterpreterObject): self.held_object = build.ConfigureFile(subdir, sourcename, targetname, configuration_data) -class EnvironmentVariablesHolder(InterpreterObject): +class EnvironmentVariablesHolder(MutableInterpreterObject): def __init__(self): super().__init__() self.held_object = build.EnvironmentVariables() @@ -211,7 +216,7 @@ class EnvironmentVariablesHolder(InterpreterObject): self.add_var(self.held_object.prepend, args, kwargs) -class ConfigurationDataHolder(InterpreterObject): +class ConfigurationDataHolder(MutableInterpreterObject): def __init__(self): super().__init__() self.used = False # These objects become immutable after use in configure_file. @@ -2455,6 +2460,9 @@ requirements use the version keyword argument instead.''') value = self.to_native(value) if not self.is_assignable(value): raise InvalidCode('Tried to assign an invalid value to variable.') + # For mutable objects we need to make a copy on assignment + if isinstance(value, MutableInterpreterObject): + value = copy.deepcopy(value) self.set_variable(var_name, value) return value |