diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-06-20 11:46:26 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-07-07 20:32:11 +0300 |
| commit | 49ea8499e265f3a9a5301d77c774d168cb8637a9 (patch) | |
| tree | d23686cff468257508e52942fc6ba8cf495c8ae3 | |
| parent | 576869233a6846c9953be017206832acc7a0e0db (diff) | |
| download | meson-49ea8499e265f3a9a5301d77c774d168cb8637a9.tar.gz | |
options: split pending subproject options into their own dictionary
Reserve pending_options for those that could appear later in
the configuration process. Options are added there only if
accept_as_pending_option() is true.
This is a preparation for changing the code so that it checks
pending_options for subprojects as well.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/options.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 7c9d1ab86..16aed1898 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -812,10 +812,11 @@ class OptionStore: self.augments: OptionDict = {} self.is_cross = is_cross - # Pending options are options that need to be initialized later, either - # configuration dependent options like compiler options, or options for - # a different subproject + # Pending options are configuration dependent options that could be + # initialized later, such as compiler options self.pending_options: OptionDict = {} + # Subproject options from toplevel project() + self.pending_subproject_options: OptionDict = {} def clear_pending(self) -> None: self.pending_options = {} @@ -1305,9 +1306,9 @@ class OptionStore: if not self.is_cross and key.is_for_build(): continue if key.subproject: - # do apply project() default_options for subprojects here, because - # they have low priority - self.pending_options[key] = valstr + # Subproject options from toplevel project() have low priority + # and will be processed when the subproject is found + self.pending_subproject_options[key] = valstr else: # Setting a project option with default_options # should arguably be a hard error; the default @@ -1359,7 +1360,7 @@ class OptionStore: cmd_line_options: OptionDict, machine_file_options: OptionDict) -> None: # pick up pending per-project settings from the toplevel project() invocation - options = {k: v for k, v in self.pending_options.items() if k.subproject == subproject} + options = {k: v for k, v in self.pending_subproject_options.items() if k.subproject == subproject} # apply project() and subproject() default_options for key, valstr in itertools.chain(project_default_options.items(), spcall_default_options.items()): @@ -1375,7 +1376,7 @@ class OptionStore: for key, valstr in itertools.chain(machine_file_options.items(), cmd_line_options.items()): if key.subproject is None and not self.is_project_option(key.as_root()): subp_key = key.evolve(subproject=subproject) - self.pending_options.pop(subp_key, None) + self.pending_subproject_options.pop(subp_key, None) options.pop(subp_key, None) # then finally per project augments from machine file and command line @@ -1385,7 +1386,12 @@ class OptionStore: # merge everything that has been computed above, while giving self.augments priority for key, valstr in options.items(): - self.pending_options.pop(key, None) + if key.subproject != subproject: + # Subproject options from project() will be processed when the subproject is found + self.pending_subproject_options[key] = valstr + continue + + self.pending_subproject_options.pop(key, None) valstr = self.augments.pop(key, valstr) if key in self.project_options: self.set_option(key, valstr, True) |
