environment: Add some comments to the _load_machine_file_options method

0.57
Dylan Baker 4 years ago committed by Nirbheek Chauhan
parent 63e0861eb3
commit 4bf25c84cf
  1. 13
      mesonbuild/environment.py

@ -748,12 +748,20 @@ class Environment:
def _load_machine_file_options(self, config: 'ConfigParser', properties: Properties, machine: MachineChoice) -> None: def _load_machine_file_options(self, config: 'ConfigParser', properties: Properties, machine: MachineChoice) -> None:
"""Read the contents of a Machine file and put it in the options store.""" """Read the contents of a Machine file and put it in the options store."""
# Look for any options in the deprecated paths section, warn about
# those, then assign them. They will be overwritten by the ones in the
# "built-in options" section if they're in both sections.
paths = config.get('paths') paths = config.get('paths')
if paths: if paths:
mlog.deprecation('The [paths] section is deprecated, use the [built-in options] section instead.') mlog.deprecation('The [paths] section is deprecated, use the [built-in options] section instead.')
for k, v in paths.items(): for k, v in paths.items():
self.options[OptionKey.from_string(k).evolve(machine=machine)] = v self.options[OptionKey.from_string(k).evolve(machine=machine)] = v
deprecated_properties = set()
# Next look for compiler options in the "properties" section, this is
# also deprecated, and these will also be overwritten by the "built-in
# options" section. We need to remove these from this section, as well.
deprecated_properties: T.Set[str] = set()
for lang in compilers.all_languages: for lang in compilers.all_languages:
deprecated_properties.add(lang + '_args') deprecated_properties.add(lang + '_args')
deprecated_properties.add(lang + '_link_args') deprecated_properties.add(lang + '_link_args')
@ -762,6 +770,7 @@ class Environment:
mlog.deprecation('{} in the [properties] section of the machine file is deprecated, use the [built-in options] section.'.format(k)) mlog.deprecation('{} in the [properties] section of the machine file is deprecated, use the [built-in options] section.'.format(k))
self.options[OptionKey.from_string(k).evolve(machine=machine)] = v self.options[OptionKey.from_string(k).evolve(machine=machine)] = v
del properties.properties[k] del properties.properties[k]
for section, values in config.items(): for section, values in config.items():
if ':' in section: if ':' in section:
subproject, section = section.split(':') subproject, section = section.split(':')
@ -778,7 +787,7 @@ class Environment:
self.options[key.evolve(subproject=subproject, machine=machine)] = v 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 host machine
key = OptionKey.from_string(k) key = OptionKey.from_string(k)
if key.subproject: if key.subproject:
raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.') raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.')

Loading…
Cancel
Save