Skip to content

Cleanup OptionStore types#14559

Merged
dcbaker merged 12 commits intomesonbuild:masterfrom
bonzini:option-types-cleanup
May 7, 2025
Merged

Cleanup OptionStore types#14559
dcbaker merged 12 commits intomesonbuild:masterfrom
bonzini:option-types-cleanup

Conversation

@bonzini
Copy link
Copy Markdown
Contributor

@bonzini bonzini commented May 5, 2025

Fix cases in which str was used for values that could actually be any type valid for an option.

Stop going back and forth between lists and dictionaries. Also stop going back and forth between str and OptionKey.

@bonzini bonzini force-pushed the option-types-cleanup branch from 9603403 to e1c4e1f Compare May 5, 2025 12:47
@dcbaker
Copy link
Copy Markdown
Member

dcbaker commented May 5, 2025

I've got some work in this direction as well, but I've had no time to look at it recently.

I'd really like to put the -> dict conversion back in the typed_kwargs call where it belongs. I might have a patch or two that fixes the type issue completely, I can push that branch somewhere for you to look at it you're interested, but I don't realistically have time to work on it ATM, so it's only if you think it's useful.

@bonzini bonzini force-pushed the option-types-cleanup branch 2 times, most recently from c0cd5cb to 5959a44 Compare May 5, 2025 14:35
@bonzini bonzini force-pushed the option-types-cleanup branch 4 times, most recently from 589eedb to e48802e Compare May 5, 2025 15:57
@bonzini
Copy link
Copy Markdown
Contributor Author

bonzini commented May 5, 2025

I'd really like to put the -> dict conversion back in the typed_kwargs call where it belongs

Done. :) There's still a bit of work to do towards cleaning up usage of OptionStringLikeDict and clarifying the interface between interpreter and options (OptionKey vs str); but restoring the convertor seems like a good place to break this series.

@bonzini bonzini marked this pull request as ready for review May 5, 2025 16:37
@bonzini bonzini requested review from jpakkane and mensinda as code owners May 5, 2025 16:37
@bonzini bonzini added refactoring No behavior changes options Meson configuration options labels May 5, 2025
@dcbaker
Copy link
Copy Markdown
Member

dcbaker commented May 5, 2025

PS: I really dislike the augments/pending_options thing. OptionKeys should make having augments useless, and the only thing we really want pending_options for is options that may be valid, but not yet used. Like for a subproject option being set and the subprojects doesn't get trigged, but after a reconfigure is.

Copy link
Copy Markdown
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks really good to me, just a couple of small nits.

@bonzini bonzini force-pushed the option-types-cleanup branch 2 times, most recently from 4504065 to 920710c Compare May 6, 2025 15:24
@bonzini bonzini requested a review from dcbaker May 6, 2025 15:24
@bonzini bonzini force-pushed the option-types-cleanup branch from 920710c to f8413df Compare May 6, 2025 16:55
@bonzini bonzini force-pushed the option-types-cleanup branch from f8413df to e42bb21 Compare May 7, 2025 08:13
bonzini added 3 commits May 7, 2025 15:01
Since opt.deprecated is a dictionary with string keys, the lookup must use
str() around the user-provided value; with some care because booleans
will be the meson-ic 'true' and 'false' instead of Python's 'True' and
'False'.

Signed-off-by: Paolo Bonzini <[email protected]>
It is assigned to invoker_method_default_options for clarity, use that name
everywhere.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini force-pushed the option-types-cleanup branch from e42bb21 to 4bc8c3e Compare May 7, 2025 13:04
bonzini added 3 commits May 7, 2025 17:18
Make the validators accept any object since that is where the type
checking is done.  The same is true for listify_array_value, which
also performs type checking.

Signed-off-by: Paolo Bonzini <[email protected]>
This makes it possible to remove all list cases from first_handle_prefix
and callees.

Signed-off-by: Paolo Bonzini <[email protected]>
bonzini added 6 commits May 7, 2025 17:18
Do not go through string first and OptionKey second.  Just pass the OptionKeys
down.

Signed-off-by: Paolo Bonzini <[email protected]>
Allow OptionStringLikeDict to use non-string data types, and use it
as much as possible instead of string-valued dictionaries.

Signed-off-by: Paolo Bonzini <[email protected]>
A convertor will *accept* something that is definitely a TYPE_var; but the
output can be any Python object that the evaluation function desires.

Signed-off-by: Paolo Bonzini <[email protected]>
…_options

Replace optlist2optdict with a convertor.  However, while default_options
should use OptionKeys like it did before the option refactoring,
override_options keeps using strings.

Signed-off-by: Paolo Bonzini <[email protected]>
@bonzini bonzini force-pushed the option-types-cleanup branch from 4bc8c3e to 5c9be51 Compare May 7, 2025 15:19
@dcbaker dcbaker merged commit 5558453 into mesonbuild:master May 7, 2025
31 checks passed
@bonzini bonzini deleted the option-types-cleanup branch May 23, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

options Meson configuration options refactoring No behavior changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants