Commit Graph

558 Commits

Author SHA1 Message Date
Dylan Baker b1eab89a0c coredata: delete a bunch of unused methods
Added by the optionrefactor changes, but not used
2025-03-04 13:37:57 -05:00
Dylan Baker 7130468402 compilers: Remove the BaseOption type
This class only served one purpose, to avoid typing the name of the
option twice. Unfortunately the way it was implemented made getting the
type checking right difficult, and required storing the same data twice.
This patch replaces this approach with a dictionary comprehension that
creates the OptionKey from the UserOption. This allows us to initialize
a single dictionary once, avoid typing the name twice, delete lines of
code, and get better type safety.

As an added bonus, it means that the exported data from the module can
be marked module constant, ie, ALL_CAPS.
2025-03-03 11:26:23 -08:00
Dylan Baker daf4774cea coredata: subproject should be None for checking in base_options
These options are stored as a "global" options, ie, subproject=None.
Therefore, the call to `as_root()` could never be correct, and only the
`k in base_options` check could ever be correct. Since these options are
not supposed to be set here in the root project or in subprojects, we
want to check for the global option and skip.
2025-03-03 11:26:23 -08:00
Charles Brunet 70c7bc45fe Replace OptionKey.evolve(...) with specialized functions
This removes a few comparisons, and one function call.
2025-03-01 13:24:48 +02:00
Dylan Baker f827010184 coredata: remove dead code from option refactor 2025-02-27 23:33:39 +02:00
Dylan Baker 3f430886dc coredata: delete the OptionsView
This also makes KeyedOptionDictType obsolete and it's removed
2025-02-27 23:33:39 +02:00
Jussi Pakkanen d37d649b08 Make all Meson level options overridable per subproject. 2025-02-13 23:57:48 +02:00
Dylan Baker 5e7b1a9d1d options: Add a TypeAlias for option values
This gives us a simpler way to annotate things returning an option
value, and gives us an easy single place to change that will affect
everywhere if the option value types are changed.
2025-02-12 10:35:35 -08:00
Dylan Baker 9fd5281bef options: Replace uses of `UserOption[T.Any]` with a Union of UserOption types
The fact that UserOption is generic is really an implementation detail,
not something to be used publicly. So by having an `AnyOptionType`
alias, we can get better type checking, as can be seen by the patch as a
whole. One of the big fixes it replace open-coded equivlalents of
`MutableKeydOptionDictType` with that type alias.
2025-02-05 17:45:38 +02:00
Dylan Baker 8eba69cbaa options: Add a function to compare different option choices
This allows us to hide type differences inside the options module, but
still get accurate change information.
2025-02-05 17:45:38 +02:00
Dylan Baker 164a18d84f options: fix typing of add_to_argparse
Which wants a string, but then passes that string to a function that
wants an OptionKey, which means that we'll always miss the lookup in
BULITIN_DIR_NOPREFIX_OPTIONS, and return the default. The only case this
gets used we cast an OptionKey to str, and then pass that. So instead,
do the cast inside the function when necessary and pass the OptionKey
2025-02-05 17:45:38 +02:00
Dylan Baker ba3460eb11 options: Add an EnumeratedUserOption class
This will allow us to take choices out of the UserOption class, which
doesn't actually use this attribute.
2025-02-05 17:45:38 +02:00
Dylan Baker 0e11b90d6f options: use dataclasses for UserOption
This reduces code, makes this clearer, and will be a nice step toward
the goal of getting everything typesafe.

For `UserIntegerOption` this makes a fairly nice, but substantial change
in that the old method used a tuple of `(min, value, max)` to pass to the
initializer, while all other types just passed `value`. The new
`UserIntegerOption` does the same, with keyword arguments for the min
and max values.
2025-02-05 17:45:38 +02:00
Jussi Pakkanen 0cbc4e1e1a Bump version number for new development. 2025-01-26 21:13:56 +02:00
Jussi Pakkanen 897b6fcdf9 Bump version number for release. 2025-01-26 20:04:15 +02:00
Jussi Pakkanen 91eb6c2289 Bump version number for rc2. 2025-01-19 21:00:05 +02:00
Jussi Pakkanen a86476c57c Bump version number for rc1. 2025-01-09 16:55:00 +02:00
Jussi Pakkanen 16cf71f051 Handle top level options set in subprojects. Closes #13847. 2024-12-16 21:12:39 +02:00
Jussi Pakkanen 5e920e3907 Bump version number for new development. 2024-10-20 22:01:56 +03:00
Jussi Pakkanen 4c6c89ca7a Update docs and version number for release. 2024-10-20 21:20:25 +03:00
Jussi Pakkanen 9fd9cc957f Bump version number for rc2. 2024-10-13 18:40:31 +03:00
Jussi Pakkanen 739683943a Update version number for rc1. 2024-10-07 00:21:03 +03:00
Eli Schwartz 4a352dd8bd
flake8: move unused typing-only imports to TYPE_CHECKING 2024-07-30 14:13:11 -04:00
Jussi Pakkanen a97de6b527 Ensure override var exists. Closes #13402. 2024-07-23 11:34:42 -04:00
Jussi Pakkanen 6e20022295 Remove module type from OptionKey. 2024-07-17 18:37:51 +03:00
Jussi Pakkanen 61c742fae9 Remove language (AKA compiler) type from OptionKey. 2024-07-17 18:37:51 +03:00
Jussi Pakkanen de8e3d65e0 Remove option type from OptionKey and get it from OptionStore instead. 2024-07-17 18:37:51 +03:00
Jussi Pakkanen 0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 5c6e9d2d8f Move builtin option check into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 8e3f609e73 Move project option detection into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 814e581537 Bump version number for new development. 2024-07-10 21:26:32 +03:00
Jussi Pakkanen 183084a9e8 Release 1.5.0 time. 2024-07-10 20:25:01 +03:00
Jussi Pakkanen 5d417edd64 Bump version number for rc3. 2024-07-08 20:46:42 +03:00
Jussi Pakkanen ff5865c45c Bump version number for rc2. 2024-07-01 18:35:29 +03:00
Jussi Pakkanen 7ec1fc507e Bump version numbers for rc1. 2024-06-24 19:32:34 +03:00
Jussi Pakkanen 181c3499fd Fix mypy. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen 9a6fcd4d9a Replace direct indexing with named methods. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen 2b1510d706 Convert option from a plain dictionary into a named class. 2024-06-08 22:58:06 +03:00
Jussi Pakkanen 41a445c228 Extract native file parser to machinefile source file. 2024-06-04 22:45:41 +03:00
Jussi Pakkanen 5365d9a842 Refactor option classes to their own file. 2024-05-23 21:26:45 +03:00
Jussi Pakkanen 128f0e828e
Pass wrapmode value around as a string. (#13229) 2024-05-19 20:58:46 +03:00
Eli Schwartz e5f32b7414 catch build files that cannot be opened in utf8 mode and emit useful error
Previously, if a junked meson.build or native.ini was used we got a
lengthy traceback ending in UnicodeDecodeError.

Fixes: #13154
Fixes: #13156
2024-04-28 22:51:08 +03:00
Ole André Vadla Ravnås 0cec1c03d8 coredata: Fix is_per_machine_option() for builtins
The keys in BUILTIN_OPTIONS_PER_MACHINE are OptionKey values, not
strings.

This fixes a regression introduced in 71db6b0.
2024-04-22 09:41:43 -07:00
Eli Schwartz 39f6d11792
micro-optimize iteration of evaluated set
It is generally accepted practice to convert dict.keys() to a list
before iterating over it and e.g. deleting values, as keys returns a
live-action view. In this case, we use the difference of *two* dict
keys, which returns a regular non-view set and doesn't need protecting.

Iteration order doesn't matter (the set already randomizes it anyway).
Avoid the cost of converting to a list.
2024-04-15 16:43:07 -04:00
Charles Brunet bd4fd90730 parser: revert to single StringNode type
this will allow transforming string types in the formater
2024-04-08 10:43:57 -07:00
Dylan Baker c6875305f3 coredata: add tracking of the options files
When we load the option file in the interpreter record which file it
was, and what the hash of that file was. This will let `meson configure`
know that the options have changed since the last re-configure.
2024-03-18 16:06:37 -07:00
Dylan Baker 8a10c8a539 coredata: remove extraneous keys when updating project_options
This can happen when a project's meson.options file is updated, and an
old option is removed.
2024-03-18 16:06:37 -07:00
Charles Brunet dacb25db10 Improve error messages for invalid option values
By adding the option name to UserOption object, it is now possible to
display the name of the affected option when the given option value is
not valid.

Fixes #12635
2024-03-15 09:23:46 -07:00
Charles Brunet d08ef2c08b move UserArrayOption.listify_value to mesonlib
This function is used at 3 different places and it does not justify it
as being a staticmethod instead of being a free function.
2024-03-15 09:23:46 -07:00