summaryrefslogtreecommitdiff
path: root/unittests/optiontests.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-11-19options: the parent of a yielding option can be falsyPaolo Bonzini
Fixes: #15258
2025-10-29options: rename get_value_object_and_value_forPaolo Bonzini
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: replace get_value with get_value_forPaolo Bonzini
The two methods are identical. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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-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-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-09unittests: improve test for yielding optionsPaolo Bonzini
Go through the whole initialization and set_option process, and check that the option value is unaffected by the creation of a subproject. 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-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-18options: fix option orderingPaolo Bonzini
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-18optiontests: use a real system optionPaolo Bonzini
Once unknown options will go through accept_as_pending_option, only system options that really exist in Meson will be accepted. Adjust the unit tests. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-05unittests: use UnitTest helper methods instead of raw assertDylan Baker
Which doesn't give helpful error messages unless used with pytest
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 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>
2025-05-07options: fix "deprecated" with dictionary argument and non-string typesPaolo Bonzini
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 <pbonzini@redhat.com>
2025-04-24options: subproject system options require the global onesPaolo Bonzini
Because system options apply to all subprojects, they need to be present globally whenever a subproject needs them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-08options: fix typing issues stemming from initialize_from_top_level_project_callDylan Baker
Machine files provide a `Mapping[OptionKey, ElementaryOptionValues]`, but the expectation listed was that they provided options in the raw DSL format.
2025-04-02unittests: use more subtestsDylan Baker
2025-03-06options: delete unused set_subproject_optionsDylan Baker
2025-03-06unittests: Use more subtestsDylan Baker
2025-03-04OptionStore: remove unused build_options attributeDylan Baker
2025-03-03options: use an OptionKey for `get_default_for_b_option`Dylan Baker
We have the OptionKey in the one caller that exists already, and this allows us to do a hash lookup instead of a linear walk.
2025-02-27Actually fix base option default values.Jussi Pakkanen
2025-02-27optstore: remove num_optionsDylan Baker
It's only used for unittests, so define it as a helper in the unit test module instead
2025-02-27Maintain bw compatibility for requesting bad options.Jussi Pakkanen
Closes: #14255.
2025-02-22Fix yielding when top project does not define the option.Jussi Pakkanen
Closes #14281.
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen