aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-11 13:27:26 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-11 11:15:07 -0800
commitf3fcbba1f89f0b2a323dd596a3caf4fce5a1611e (patch)
tree349f993b9421e3ce904df7777f479402249d99b0 /mesonbuild/environment.py
parente7a5c75285ce63a7197cd82e893450eb9bb68b6c (diff)
downloadmeson-f3fcbba1f89f0b2a323dd596a3caf4fce5a1611e.zip
meson-f3fcbba1f89f0b2a323dd596a3caf4fce5a1611e.tar.gz
meson-f3fcbba1f89f0b2a323dd596a3caf4fce5a1611e.tar.bz2
boost: default machine file properties to env var values
This both moves the env reading to configuration time, which is useful, and also simplifies the implementation of the boost dependency. The simplification comes from being able to delete basically duplicated code since the values will be in the Properties if they exist at all.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 6275da0..ba24411 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -656,6 +656,7 @@ class Environment:
# Take default value from env if not set in cross/native files or command line.
self.set_default_options_from_env()
self._set_default_binaries_from_env()
+ self._set_default_properties_from_env()
# Warn if the user is using two different ways of setting build-type
# options that override each other
@@ -821,6 +822,26 @@ class Environment:
_, p_env = p_env_pair
self.binaries[for_machine].binaries.setdefault(name, mesonlib.split_args(p_env))
+ def _set_default_properties_from_env(self) -> None:
+ """Properties which can alkso be set from the environment."""
+ # name, evar, split
+ opts: T.List[T.Tuple[str, T.List[str], bool]] = [
+ ('boost_includedir', ['BOOST_INCLUDEDIR'], False),
+ ('boost_librarydir', ['BOOST_LIBRARYDIR'], False),
+ ('boost_root', ['BOOST_ROOT', 'BOOSTROOT'], True),
+ ]
+
+ 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
+ if split:
+ self.properties[for_machine].properties.setdefault(name, p_env.split(os.pathsep))
+ else:
+ self.properties[for_machine].properties.setdefault(name, p_env)
+ break
+
def create_new_coredata(self, options: 'argparse.Namespace') -> None:
# WARNING: Don't use any values from coredata in __init__. It gets
# re-initialized with project options by the interpreter during