aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-04-19 14:52:55 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2025-04-24 17:49:05 +0300
commit66420a4a7fc43e5e6076afbdaa709cf4581e398c (patch)
tree33fda9f15f53ce1fffd2164125d7a2fbb65e8453
parent2e8a804a009d5ee0c4bfba8bf629ace3a28c6e14 (diff)
downloadmeson-66420a4a7fc43e5e6076afbdaa709cf4581e398c.zip
meson-66420a4a7fc43e5e6076afbdaa709cf4581e398c.tar.gz
meson-66420a4a7fc43e5e6076afbdaa709cf4581e398c.tar.bz2
options: use early return
Prepare for adding more complex logic to add_system_option_internal, in order to handle inheritance of global options to subprojects. Do the same in add_project_option to make the similarities and differences evident. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/options.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index 5fc16f5..75eb197 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -895,11 +895,13 @@ class OptionStore:
assert isinstance(valobj, UserOption)
if not isinstance(valobj.name, str):
assert isinstance(valobj.name, str)
- if key not in self.options:
- self.options[key] = valobj
- pval = self.pending_options.pop(key, None)
- if pval is not None:
- self.set_option(key, pval)
+ if key in self.options:
+ return
+
+ self.options[key] = valobj
+ pval = self.pending_options.pop(key, None)
+ if pval is not None:
+ self.set_option(key, pval)
def add_compiler_option(self, language: str, key: T.Union[OptionKey, str], valobj: AnyOptionType) -> None:
key = self.ensure_and_validate_key(key)
@@ -910,14 +912,14 @@ class OptionStore:
def add_project_option(self, key: T.Union[OptionKey, str], valobj: AnyOptionType) -> None:
key = self.ensure_and_validate_key(key)
assert key.subproject is not None
- pval = self.pending_options.pop(key, None)
if key in self.options:
raise MesonException(f'Internal error: tried to add a project option {key} that already exists.')
- else:
- self.options[key] = valobj
- self.project_options.add(key)
- if pval is not None:
- self.set_option(key, pval)
+
+ self.options[key] = valobj
+ self.project_options.add(key)
+ pval = self.pending_options.pop(key, None)
+ if pval is not None:
+ self.set_option(key, pval)
def add_module_option(self, modulename: str, key: T.Union[OptionKey, str], valobj: AnyOptionType) -> None:
key = self.ensure_and_validate_key(key)