diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-02-04 13:54:44 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-06 09:37:24 -0800 |
| commit | 906f376b52730ab3721d17d749a44dee9efcd633 (patch) | |
| tree | ed5859a0d02ae302e54b16b008a7353a424793f2 | |
| parent | 97a1c567c9813176e4bec40f6055f228b2121609 (diff) | |
| download | meson-906f376b52730ab3721d17d749a44dee9efcd633.tar.gz | |
environment: handle machine file options sections with more than one subproject
Instead of having a raw python exception, provide a helpful error
message that `[sub:sub1:project options]` should just be `[sub1:project
options]`
No test is provided as this is basic error handling, and I felt it was
not worth adding to our test runtime to test that we don't raise a raw
exception.
Fixes: #14222
| -rw-r--r-- | mesonbuild/environment.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 90b10697a..f1d55cc0f 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -273,7 +273,7 @@ class Environment: for section, values in config.items(): if ':' in section: - section_subproject, section = section.split(':') + section_subproject, section = section.split(':', 1) else: section_subproject = '' if section == 'built-in options': @@ -290,6 +290,13 @@ class Environment: # Project options are always for the host machine key = self.mfilestr2key(strk, section, section_subproject, machine) self.options[key] = v + elif ':' in section: + correct_subproject, correct_section = section.split(':')[-2:] + raise MesonException( + 'Subproject options should always be set as ' + '`[subproject:section]`, even if the options are from a ' + 'nested subproject. ' + f'Replace `[{section_subproject}:{section}]` with `[{correct_subproject}:{correct_section}]`') def _set_default_options_from_env(self) -> None: opts: T.List[T.Tuple[str, str]] = ( |
