aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-02-17 09:28:43 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-02-18 10:57:20 -0800
commit91e56c7d59650445ad2f868dfb552cfbeed53796 (patch)
tree1f895a07f8ab25a9b1592ca1e70eee48d1d9164c /mesonbuild/environment.py
parentb03039ec9d8fe01ff06c28972e4dd46421e4a238 (diff)
downloadmeson-91e56c7d59650445ad2f868dfb552cfbeed53796.zip
meson-91e56c7d59650445ad2f868dfb552cfbeed53796.tar.gz
meson-91e56c7d59650445ad2f868dfb552cfbeed53796.tar.bz2
environment: Allow setting build options in cross files
This did work previously, so we need to let it continue working. I'm proposing removing it in 0.60 because the correct solution has always worked. I've also been a bit more defensive here, and made setting `subproject:opt = foo` in the machine files an error, as we have `[subproject:built-in options]` or `[subproject:project options]` for that.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 7e9118e..756dd81 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -769,13 +769,20 @@ class Environment:
subproject = ''
if section == 'built-in options':
for k, v in values.items():
- key = OptionKey.from_string(k).evolve(subproject=subproject, machine=machine)
- self.options[key] = v
+ key = OptionKey.from_string(k)
+ # If we're in the cross file, and there is a `build.foo` warn about that. Later we'll remove it.
+ if machine is MachineChoice.HOST and key.machine is not machine:
+ mlog.deprecation('Setting build machine options in cross files, please use a native file instead, this will be removed in meson 0.60', once=True)
+ if key.subproject:
+ raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.')
+ self.options[key.evolve(subproject=subproject, machine=machine)] = v
elif section == 'project options':
for k, v in values.items():
# Project options are always for the machine machine
- key = OptionKey.from_string(k).evolve(subproject=subproject)
- self.options[key] = v
+ key = OptionKey.from_string(k)
+ if key.subproject:
+ raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.')
+ self.options[key.evolve(subproject=subproject)] = v
def _set_default_options_from_env(self) -> None:
opts: T.List[T.Tuple[str, str]] = (