summaryrefslogtreecommitdiff
path: root/mesonbuild/options.py
AgeCommit message (Collapse)Author
2025-12-18options: canonicalize to host options anything that is not per-machinePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-18options: optimize shortcuts for evolve()Paolo Bonzini
Since OptionKey is immutable, it is possible to return self if we know that the returned value is the same as the one being transformed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-19options: the parent of a yielding option can be falsyPaolo Bonzini
Fixes: #15258
2025-11-17Support Visual Studio 2026.Jussi Pakkanen
2025-11-14Add `os2_emxomf' option to generate OMF files on OS/2KO Myung-Hun
1. Generate OMF objs with `-Zomf' compiler flags 2. Generate OMF libs with `.lib' suffix using `emxomfar' as a librarian
2025-10-29options: clean up handling of pending_optionsPaolo Bonzini
Options are now added to pending_options only if they *can* be accepted as pending, so there is never a need check if something is in pending_options but not acceptable. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29options: rename get_value_object_and_value_forPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29options: rename get_value_object_forPaolo Bonzini
No need to focus on the "value" part of the name. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: simplify builtins logicPaolo Bonzini
The keys are always global and there are no yielding options in fact; historically it was the way to make an option not per-subproject, but that's no longer needed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06coredata: remove pointless @staticmethodPaolo Bonzini
Just move everything to optstore, together with the methods it calls. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06interpreter, options: inline get_default_for_b_optionPaolo Bonzini
This is a simple access, and there are already uses of COMPILER_BASE_OPTIONS outside options.py. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: make is_base_option stricterPaolo Bonzini
Only return True if the option actually exists. While at it, ensure that the right machine is looked up in get_default_for_b_option; this allows removing the try/except block. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: remove set_value_objectPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: remove dead codePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: merge duplicate loops into onePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: replace get_value with get_value_forPaolo Bonzini
The two methods are identical. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-01Add option to specify target naming scheme.Jussi Pakkanen
2025-10-01options: ensure pending subproject options are validatedPaolo Bonzini
Boolean options need to be translated from string "true" to True and so on, otherwise we will get an assertion later when trying to set the value: ``` Traceback (most recent call last): File "meson.git/mesonbuild/mesonmain.py", line 193, in run return options.run_func(options) ~~~~~~~~~~~~~~~~^^^^^^^^^ File "meson.git/mesonbuild/msetup.py", line 395, in run app.generate() ~~~~~~~~~~~~^^ File "meson.git/mesonbuild/msetup.py", line 194, in generate return self._generate(env, capture, vslite_ctx) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "meson.git/mesonbuild/msetup.py", line 282, in _generate captured_compile_args = intr.backend.generate(capture, vslite_ctx) File "meson.git/mesonbuild/backend/ninjabackend.py", line 647, in generate self.generate_target(t) ~~~~~~~~~~~~~~~~~~~~^^^ File "meson.git/mesonbuild/backend/ninjabackend.py", line 1099, in generate_target elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args) File "meson.git/mesonbuild/backend/ninjabackend.py", line 3632, in generate_link base_link_args = compilers.get_base_link_args(target, linker, self.environment) File "meson.git/mesonbuild/compilers/compilers.py", line 405, in get_base_link_args option_enabled(linker.base_options, target, env, 'b_lundef')): ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "meson.git/mesonbuild/compilers/compilers.py", line 234, in option_enabled assert isinstance(ret, bool), 'must return bool' # could also be str ~~~~~~~~~~^^^^^^^^^^^ AssertionError: must return bool ``` This assertion is being hit because the vo-aacenc wrap sets `b_lundef=true` in `default_options:` in `project()`, which ends up in `self.augments` when the project is being invoked as a subproject. The fix is to use set_option even for pending subproject options. This will follow this path: new_value = opt.validate_value(new_value) old_value = self.augments.get(key, opt.value) self.augments[key] = new_value This regressed in 2bafe7dc403b92c7b1f7bbad62dd8533e90f8523. First noticed at: https://github.com/mesonbuild/wrapdb/actions/runs/18123699172/job/51573947286?pr=2425 [Commit message by Nirbheek Chauhan <nirbheek@centricular.com>]
2025-09-25mypy: ignore unused castEli Schwartz
It doesn't appear to have been needed at all? But only newer mypy versions go so far as to report it as an unused ignore (which is an error code itself).
2025-09-25remove unused function with mypy errorsEli Schwartz
Newer mypy astutely notices this always sets `self.options[str_key]`, which violates the type requirement for OptionKey. Per the comment, nobody should be using it, and fortunately nobody is. Deleting the code (or making it raise MesonBugException) has no impact on the testsuite.
2025-09-15options: put back in place 1.7 ordering of opt=value vs subp:opt=valuePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-28python: add a python.build_config option (PEP 739)Filipe Laíns
Signed-off-by: Filipe Laíns <lains@riseup.net> Signed-off-by: Michał Górny <mgorny@quansight.com>
2025-08-27options: do not raise exception for unknown options in -U commandPaolo Bonzini
Fixes: #14956 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-10options: ensure all build keys are changed to hostPaolo Bonzini
OptionStore.get_value did not change build keys to host when not cross-compiling. get_value_object_and_value_for also didn't when accessing self.augments. Make all accessors go through ensure_and_validate_key so that the conversion is done early. Otherwise, when "native: true" targets look up compiler options they do so with the "build.*" name, which does not exist when not cross compiling. This removes the distinction between get_value(), meant to be for global options, and get_value_for() which would be for project-specific options. While the distinction was added in commit d37d649b0 ("Make all Meson level options overridable per subproject.", 2025-02-13), it is not particularly useful and can be a source of bugs like the one in test_build_to_host_subproject testcase (corresponding to issue #14869). Fixes: #14869 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-19options: fix misindentationPaolo Bonzini
Ensure that valobj.yielding is cleared for options in the toplevel project. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-18Revert "options: do not overwrite parent options when a yielding option is set"Paolo Bonzini
This reverts commit 9ad10ee78f632a60d35327eaa9b88c7efde35fe6. The "if" in set_option() was removed, because get_key_and_value_object_for now always returns the subproject key and option object; remove the function as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-18options: resolve yielding options at the time they are addedPaolo Bonzini
This makes it possible to adjust the value of the option with a subproject-specific augment. This was an undocumented change in 1.8 which was (voluntarily) undone in commit eae4efa72 ("options: resolve yielding options at the time they are added", 2025-07-13), but is useful. This reimplementation of yielding options makes it possible to presreve the bugfix while restoring this new feature. Reported-by: Nirbheek Chauhan <nirbheek@centricular.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-17options: parse -D and -U arguments directly into a Dict[OptionKey, ↵Paolo Bonzini
Optional[str]] As a side effect, this deduplicates -D and -U arguments passed to meson configure, taking into account the relative ordering of -D and -U options. Fixes: #14754 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-09options: do not overwrite parent options when a yielding option is setPaolo Bonzini
Fixes: #14774 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07msetup: keep pending optionsPaolo Bonzini
New languages and subprojects can appear in subsequent configurations. Subproject options are kept for later now that they are not stored in pending_options, but compiler options for example are not. Drop OptionStore.clear_pending so that they are preserved as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: give priority to parent augments over child default_optionsPaolo Bonzini
Restore behavior of 1.7. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: handle augments in OptionStore.set_optionPaolo Bonzini
Remove all the special casing and late validation now that early augments are stored in pending_subproject_options until the subproject is found. As a result, this makes the buildtype special case operate on subprojects as well. It also simplifies set_from_configure_command(), which does not have to treat various kinds of options in different ways. Fixes: #14729 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: fix direction of resultPaolo Bonzini
Fixes: 8dcc9d342 ("options: accept compiler and built-in options in --reconfigure and "meson configure"", 2025-05-21 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: warn if subproject sets another subproject option too latePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: split pending subproject options into their own dictionaryPaolo Bonzini
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>
2025-07-07msetup, options: reverse direction of unknown options checkPaolo Bonzini
Remove knowledge of the internal pending_options from msetup; operate on the command line and check against the option store. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-07options: project options never act globallyPaolo Bonzini
As shown in the test, "-Dtests=true" should not override the subproject() call because tests is a project options and those do not share a namespace. Fixes: #14728 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-20options: do not store duplicate UserOptionsPaolo Bonzini
These options are never looked up except by "meson configure" and introspection, because option values are taken from self.augments[] instead. Fixes: #14558 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: fix option orderingPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: all inputs to OptionStore are OptionKeysPaolo Bonzini
Thanks to several fixes applied between commit d37d649b0 ("Make all Meson level options overridable per subproject.", 2025-02-13) and now, OptionStore never gets a string key. Tighten the type of OptionDict, and use it whenever possible. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: remove double assignmentPaolo Bonzini
self.project_options is set already a couple lines above. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: do not use always-true variablePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: reuse set_option_maybe_rootPaolo Bonzini
There is common logic hiding between project() and "meson configure": the complication that the comment mentions for the "default_options" case actually applies to "meson configure", to machine files, to command line options and to project options. Reuse the same function in all four cases. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: use nicer type annotation T.ContainerPaolo Bonzini
Suggested-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: accept backend options as pending on first invocationPaolo Bonzini
They must be there when running re-configuring, because the backend cannot be changed, but they can be pending on the first invocation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-18options: print option name before "as_root()" in errorsPaolo Bonzini
Starting with Meson 1.8.0, "meson configure" prints some options as ":foo" instead of "foo". Print the option as it was passed by the user. While at it, make errors more consistent and/or correct (e.g. "Unknown option" instead of "Unknown options"). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-23options: process project options before machine optionsPaolo Bonzini
Restore the behavior from before commit d37d649b0 ("Make all Meson level options overridable per subproject.", 2025-02-13). The old code was: options: T.MutableMapping[OptionKey, T.Any] = OrderedDict() # process project default options for k, v in default_options.items(): if not subproject or k.subproject == subproject: options[k] = v # override them with machine default and command line options options.update(env.options) env.options = options Fixes: #14608 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21options: accept build options in --reconfigure or "meson configure"Paolo Bonzini
Make more of the first-invocation logic apply to subsequent configuration of the build tree. This also opens the door for using set_option_maybe_root for the first invocation. This is a huge cleanup but also a larger change, and therefore not something for stable branches. Leave it for later. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21options: accept compiler and built-in options in --reconfigure and "meson ↵Paolo Bonzini
configure" Follow the same logic that is used at the end of the first invocation. This fixes meson setup --reconfigure -Db_ndebug=true on a project that has no language that defines b_ndebug. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-21options: commonize code to accept unknown optionsPaolo Bonzini
The check for unknown options is duplicated in OptionStore and MesonApp. Place the better version of the two as a new method of OptionStore, and use it in OptionStore.validate_cmd_line_options. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>