diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-04-13 11:25:58 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-04-13 11:25:58 +0530 |
commit | 26cb9bb8df0d1a759d4d62abf0877e5fe3fd6bf6 (patch) | |
tree | 0bc1389fc92ce3e5f3e11f1da8951b236d0e768a /mesonbuild/interpreter.py | |
parent | eaed4aecbe218018feed73192e6fc25e54034d53 (diff) | |
download | meson-warn-env-ops-dont-stack.tar.gz |
interpreter: Warn when environment() ops are overridenwarn-env-ops-dont-stack
Warn when someone tries to use append() or prepend() on an env var
which already has an operation set on it. People seem to think that
multiple append/prepend operations stack, but they don't.
Closes https://github.com/mesonbuild/meson/issues/5087
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 1cf56a253..993ebbd1c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -235,7 +235,13 @@ class EnvironmentVariablesHolder(MutableInterpreterObject, ObjectHolder): raise InterpreterException("EnvironmentVariablesHolder methods require at least" "2 arguments, first is the name of the variable and" " following one are values") - self.held_object.envvars.append((method, args[0], args[1:], kwargs)) + # Warn when someone tries to use append() or prepend() on an env var + # which already has an operation set on it. People seem to think that + # multiple append/prepend operations stack, but they don't. + if method != self.held_object.set and self.held_object.has_name(args[0]): + mlog.warning('Overriding previous value of environment variable {!r} with a new one' + .format(args[0]), location=self.current_node) + self.held_object.add_var(method, args[0], args[1:], kwargs) @stringArgs @permittedKwargs({'separator'}) |