aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-11 13:39:14 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-11 11:15:07 -0800
commit1cc7e4c84cc2b411b7adbc58d7a302fa7117c6e0 (patch)
treeac554a1a7f647e4c1d1d10ec9e5b458166c06189 /mesonbuild/environment.py
parent0076db6ff9309a34e2b86a6ae3fd85ff34b8f9f3 (diff)
downloadmeson-1cc7e4c84cc2b411b7adbc58d7a302fa7117c6e0.zip
meson-1cc7e4c84cc2b411b7adbc58d7a302fa7117c6e0.tar.gz
meson-1cc7e4c84cc2b411b7adbc58d7a302fa7117c6e0.tar.bz2
clean up get_env_var_pair
This function returns both the name and the value, but we never actually use the name, just the value. Also make this module private. We really want to keep all environment variable reading in the Environment class so it's done once up front. This should help with that goal.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 8ff9574..7889911 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -142,9 +142,7 @@ if T.TYPE_CHECKING:
import argparse
-def get_env_var_pair(for_machine: MachineChoice,
- is_cross: bool,
- var_name: str) -> T.Optional[T.Tuple[str, str]]:
+def _get_env_var(for_machine: MachineChoice, is_cross: bool, var_name: str) -> T.Optional[str]:
"""
Returns the exact env var and the value.
"""
@@ -166,7 +164,7 @@ def get_env_var_pair(for_machine: MachineChoice,
mlog.debug('None of {} are defined in the environment, not changing global flags.'.format(formatted))
return None
mlog.debug('Using {!r} from environment with value: {!r}'.format(var, value))
- return var, value
+ return value
def detect_gcovr(min_version='3.3', new_rootdir_version='4.2', log=False):
@@ -791,10 +789,8 @@ class Environment:
)
for (evar, keyname), for_machine in itertools.product(opts, MachineChoice):
- p_env_pair = get_env_var_pair(for_machine, self.is_cross_build(), evar)
- if p_env_pair is not None:
- _, p_env = p_env_pair
-
+ p_env = _get_env_var(for_machine, self.is_cross_build(), evar)
+ if p_env is not None:
# these may contain duplicates, which must be removed, else
# a duplicates-in-array-option warning arises.
if keyname == 'cmake_prefix_path':
@@ -843,9 +839,8 @@ class Environment:
envconfig.ENV_VAR_PROG_MAP.items())
for (name, evar), for_machine in itertools.product(opts, MachineChoice):
- p_env_pair = get_env_var_pair(for_machine, self.is_cross_build(), evar)
- if p_env_pair is not None:
- _, p_env = p_env_pair
+ p_env = _get_env_var(for_machine, self.is_cross_build(), evar)
+ if p_env is not None:
self.binaries[for_machine].binaries.setdefault(name, mesonlib.split_args(p_env))
def _set_default_properties_from_env(self) -> None:
@@ -859,9 +854,8 @@ class Environment:
for (name, evars, split), for_machine in itertools.product(opts, MachineChoice):
for evar in evars:
- p_env_pair = get_env_var_pair(for_machine, self.is_cross_build(), evar)
- if p_env_pair is not None:
- _, p_env = p_env_pair
+ p_env = _get_env_var(for_machine, self.is_cross_build(), evar)
+ if p_env is not None:
if split:
self.properties[for_machine].properties.setdefault(name, p_env.split(os.pathsep))
else: