summaryrefslogtreecommitdiff
path: root/mesonbuild/utils
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2024-06-23 16:41:21 -0400
committerEli Schwartz <eschwartz93@gmail.com>2024-06-23 23:02:43 -0400
commitaab2533ab4f7f4c16991620b400d71782f89be1c (patch)
tree5584674cd787dc85cf32955d68699967653581ea /mesonbuild/utils
parent1570289acf28272aa6f1e029a32229ad6f276d94 (diff)
downloadmeson-aab2533ab4f7f4c16991620b400d71782f89be1c.tar.gz
limit wrapped-due-to-env special case for `env` to only apply for env.set
In commit 2cb7350d1679fb61826bf4aebfb0f75a9b9103e3 we added a special case for environment() objects to allow skipping `meson --internal exe` overhead when /usr/bin/env exists and can be used to set environment variables instead of using a pickled wrapper. This special case assumed that environment is used for setting variables, but it is also possible, albeit less common, to append/prepend to them, in which case `meson --internal exe` will compute the final value as an offset from whatever the current environment variables inherited from ninja are. It is not possible to precompute this when generating command lines for ninja, so using arguments to /usr/bin/env is not possible. All it can do is set (override) an environment variable. In this case, we have to use the python wrapper and cannot optimize it away. Add a tracking bit to the env object and propagate it to the backend.
Diffstat (limited to 'mesonbuild/utils')
-rw-r--r--mesonbuild/utils/core.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/utils/core.py b/mesonbuild/utils/core.py
index 92f9d2c70..a87f77acc 100644
--- a/mesonbuild/utils/core.py
+++ b/mesonbuild/utils/core.py
@@ -64,6 +64,7 @@ class EnvironmentVariables(HoldableObject):
# The set of all env vars we have operations for. Only used for self.has_name()
self.varnames: T.Set[str] = set()
self.unset_vars: T.Set[str] = set()
+ self.can_use_env = True
if values:
init_func = getattr(self, init_method)
@@ -95,7 +96,9 @@ class EnvironmentVariables(HoldableObject):
self.envvars.append((method, name, values, separator))
if name in self.unset_vars:
self.unset_vars.remove(name)
- self.unset_vars.update(other.unset_vars)
+ if other.unset_vars:
+ self.can_use_env = False
+ self.unset_vars.update(other.unset_vars)
def set(self, name: str, values: T.List[str], separator: str = os.pathsep) -> None:
if name in self.unset_vars:
@@ -104,17 +107,20 @@ class EnvironmentVariables(HoldableObject):
self.envvars.append((self._set, name, values, separator))
def unset(self, name: str) -> None:
+ self.can_use_env = False
if name in self.varnames:
raise MesonException(f'You cannot unset the {name!r} variable because it is already set')
self.unset_vars.add(name)
def append(self, name: str, values: T.List[str], separator: str = os.pathsep) -> None:
+ self.can_use_env = False
if name in self.unset_vars:
raise MesonException(f'You cannot append to unset variable {name!r}')
self.varnames.add(name)
self.envvars.append((self._append, name, values, separator))
def prepend(self, name: str, values: T.List[str], separator: str = os.pathsep) -> None:
+ self.can_use_env = False
if name in self.unset_vars:
raise MesonException(f'You cannot prepend to unset variable {name!r}')
self.varnames.add(name)