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.
0.57
Dylan Baker 4 years ago committed by Nirbheek Chauhan
parent 8742cae2d1
commit b4f5550843
  1. 15
      mesonbuild/environment.py

@ -769,13 +769,20 @@ class Environment:
subproject = '' subproject = ''
if section == 'built-in options': if section == 'built-in options':
for k, v in values.items(): for k, v in values.items():
key = OptionKey.from_string(k).evolve(subproject=subproject, machine=machine) key = OptionKey.from_string(k)
self.options[key] = v # 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': elif section == 'project options':
for k, v in values.items(): for k, v in values.items():
# Project options are always for the machine machine # Project options are always for the machine machine
key = OptionKey.from_string(k).evolve(subproject=subproject) key = OptionKey.from_string(k)
self.options[key] = v 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: def _set_default_options_from_env(self) -> None:
opts: T.List[T.Tuple[str, str]] = ( opts: T.List[T.Tuple[str, str]] = (

Loading…
Cancel
Save