diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-03-26 20:39:16 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-04-02 08:59:56 -0700 |
| commit | babd42300e9e05d8e7e1ae0bec05907d143f4f40 (patch) | |
| tree | b25cea03bc6a41abbfb1286a51e817d93ba80714 /mesonbuild/environment.py | |
| parent | 8e92f1ee872081417d470e75a32edbadda8972b6 (diff) | |
| download | meson-babd42300e9e05d8e7e1ae0bec05907d143f4f40.tar.gz | |
use correct section when suggesting the placement of subproject options
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/environment.py')
| -rw-r--r-- | mesonbuild/environment.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 4999be1ec..9d0677446 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -702,11 +702,12 @@ class Environment: # Store a global state of Cargo dependencies self.cargo: T.Optional[cargo.Interpreter] = None - def mfilestr2key(self, machine_file_string: str, section_subproject: T.Optional[str], machine: MachineChoice) -> OptionKey: + def mfilestr2key(self, machine_file_string: str, section: T.Optional[str], section_subproject: T.Optional[str], machine: MachineChoice) -> OptionKey: key = OptionKey.from_string(machine_file_string) assert key.machine == MachineChoice.HOST if key.subproject: - raise MesonException('Do not set subproject options in [built-in options] section, use [subproject:built-in options] instead.') + suggestion = section if section == 'project options' else 'built-in options' + raise MesonException(f'Do not set subproject options in [{section}] section, use [subproject:{suggestion}] instead.') if section_subproject: key = key.evolve(subproject=section_subproject) if machine == MachineChoice.BUILD: @@ -724,7 +725,7 @@ class Environment: if paths: mlog.deprecation('The [paths] section is deprecated, use the [built-in options] section instead.') for strk, v in paths.items(): - k = self.mfilestr2key(strk, None, machine) + k = self.mfilestr2key(strk, 'paths', None, machine) self.options[k] = v # Next look for compiler options in the "properties" section, this is @@ -737,7 +738,7 @@ class Environment: for strk, v in properties.properties.copy().items(): if strk in deprecated_properties: mlog.deprecation(f'{strk} in the [properties] section of the machine file is deprecated, use the [built-in options] section.') - k = self.mfilestr2key(strk, None, machine) + k = self.mfilestr2key(strk, 'properties', None, machine) self.options[k] = v del properties.properties[strk] @@ -748,7 +749,7 @@ class Environment: section_subproject = '' if section == 'built-in options': for strk, v in values.items(): - key = self.mfilestr2key(strk, section_subproject, machine) + key = self.mfilestr2key(strk, section, section_subproject, machine) # 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 2.0', once=True) @@ -758,7 +759,7 @@ class Environment: # to read these from the native file for strk, v in values.items(): # Project options are always for the host machine - key = self.mfilestr2key(strk, section_subproject, machine) + key = self.mfilestr2key(strk, section, section_subproject, machine) self.options[key] = v def _set_default_options_from_env(self) -> None: |
