diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-06-20 12:32:13 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-07-07 20:32:11 +0300 |
| commit | b132fca6067f84f1cb39043af9df661f9c941b1c (patch) | |
| tree | 97e4d8878bcb33c5f1b6d08a7d66ad9ee37f18de | |
| parent | 49ea8499e265f3a9a5301d77c774d168cb8637a9 (diff) | |
| download | meson-b132fca6067f84f1cb39043af9df661f9c941b1c.tar.gz | |
options: warn if subproject sets another subproject option too late
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/options.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 16aed1898..c31ad9bb6 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -805,6 +805,7 @@ class OptionStore: def __init__(self, is_cross: bool) -> None: self.options: T.Dict['OptionKey', 'AnyOptionType'] = {} + self.subprojects: T.Set[str] = set() self.project_options: T.Set[OptionKey] = set() self.module_options: T.Set[OptionKey] = set() from .compilers import all_languages @@ -889,6 +890,10 @@ class OptionStore: computed_value = vobject.validate_value(self.augments[key]) return (vobject, computed_value) + def option_has_value(self, key: OptionKey, value: ElementaryOptionValues) -> bool: + vobject, current_value = self.get_value_object_and_value_for(key) + return vobject.validate_value(value) == current_value + def get_value_for(self, name: 'T.Union[OptionKey, str]', subproject: T.Optional[str] = None) -> ElementaryOptionValues: if isinstance(name, str): key = OptionKey(name, subproject) @@ -1387,6 +1392,10 @@ class OptionStore: # merge everything that has been computed above, while giving self.augments priority for key, valstr in options.items(): if key.subproject != subproject: + if key.subproject in self.subprojects and not self.option_has_value(key, valstr): + mlog.warning('option {key} is set in subproject {subproject} but has already been processed') + continue + # Subproject options from project() will be processed when the subproject is found self.pending_subproject_options[key] = valstr continue @@ -1398,6 +1407,8 @@ class OptionStore: else: self.augments[key] = valstr + self.subprojects.add(subproject) + def update_project_options(self, project_options: MutableKeyedOptionDictType, subproject: SubProject) -> None: for key, value in project_options.items(): if key not in self.options: |
