From b132fca6067f84f1cb39043af9df661f9c941b1c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 20 Jun 2025 12:32:13 +0200 Subject: options: warn if subproject sets another subproject option too late Signed-off-by: Paolo Bonzini --- mesonbuild/options.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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: -- cgit v1.2.3