summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreter.py
AgeCommit message (Collapse)Author
2025-12-22cargo: allow overriding Meson's Cargo interpreterPaolo Bonzini
Some projects may want to override Meson's AST generation for Cargo projects. This was not really doable before without hard coding the results of feature resolution; however, now it will be possible by accessing the results of the global feature resolution from the Rust module's workspace object. At the same time, the subproject must keep using the Cargo method, which is forced by the workspace object's subproject() method, because otherwise the interpreter is not propagated. So just skip the interpretation phase if a Meson.build is present. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-17interpreter|build: Use typed_kwargs for build_target(dependencies)Dylan Baker
What is basically impossible is to handle `SubprojectHolder`, because it's not a true holder but an interpreter object. Well, impossible without changing SubprojectHolder into a true holder, because it's avoiding the circular import becomes extremely convoluted otherwise, and refactoring is difficult because the held object is itself an Interpreter. It's a rather complex problem to solve gracefully. I've punted to avoid the complexity, it does mean that the error message is somewhat less exact. I don't think this is actually a huge problem because we've really guided people away from using `subproject()` and to instead use dependency fallbacks, which don't have this problem to begin with. This removes validation from the build layer, and puts it in interpreter. For code sharing reasons this means that `internal_dependency` also gets more fine grained error messages. The test case for this has been modified to use the `testcase expect_error` construct, and thus has been moved to the common tests directory. It's also been extended to cover both the library case, which gives coverage for the `extra_types` in `KwargInfo`
2025-12-16build: cleanup include_directories codeDylan Baker
With the previous change the build layer no longer needs to be concerned about strings
2025-12-16interpreter: use typed_kwargs for build_target(include_directories)Dylan Baker
This allows some additional cleanup, as we had code specifically for doing version checking that was not only used here, and that can be removed.
2025-12-16interpreter: use typed_kwargs ifor dependency (include_directories) stringsDylan Baker
Instead of using the `extract_incdirs` function.
2025-12-08build|interpreter: use typed_kwargs for BuildTarget(install_tag)Dylan Baker
2025-11-19interpreter: Fix import of cargo for type checkingDylan Baker
2025-11-14interpreter: Robustly covert executable arguments to shared_library argumentsDylan Baker
This extends the code that strips executable keyword arguments to also default populate shared_library exclusive arguments. Fixes: #15238
2025-11-12build: Use a tuple for pch dataDylan Baker
This really isn't a list because it's not homogenous data, it's really `tuple[str, str | None] | None`, but we're using list length to decide what to do with it, and that makes for strict null issues, as an accurate annotation would be `list[str | None]`, which would require a lot of `is not None` checking. By using a tuple we don't need to keep checking length, which is more expensive than null checking. To ensure correctness I annotated some things in the VS backend
2025-11-12intepreter: Move remaining PCH validation to InterpreterDylan Baker
2025-11-05interpreter: Move validation of BuildTarget(extra_files) to InterpreterDylan Baker
This gets us to the point that the build layer can assume it's getting valid inputs. This does two checks, an initial cheap check for generated sources, and then an I/O check via `source_strings_to_files`.
2025-11-05interpreter: move rust_api/rust_crate_type interaction to the interpreterDylan Baker
These are two ways to implement the same thing, and at the DSL level the `rust_abi` provides needed flexability, but at the lower level where a target is a thing, the `rust_crate_type` is still proving to be more useful. So, keep the `rust_abi` in the Interpreter and don't let it leak into the build layer.
2025-11-05interpreter: copy keyword arguments in `build_target`Dylan Baker
Because it's not clear how ownership is supposed to work here, and in the case of `both_libraries()`, if there are any mutations made to them then those propagate, which isn't what we want. I'd like to do some further refactoring here that would make this not necessary.
2025-11-05interpreter: Move targetclass validation to top of build_targetDylan Baker
Why do work and then error out?
2025-11-04Add build target keyword parameter 'build_subdir' [v8]Keith Packard
Place the build products in a directory of the specified name somewhere within the build directory. This allows use of the target that includes a specific directory name: #include <subdir/configure.h> This also allows creating targets with the same basename by using different subdirectory names. v2: Move build_subdir to Target class. Error if path separator in build_dir v3: Rename to 'build_subdir' to make it clear that the name is appended to a meson-specific build directory, and does not provide the user with a way to define the overall meson build hierarchy. Allow build_subdir to include path separators. Support 'build_subdir' for configure_file. build_subdir must not exist in the source directory and must not contain '..' Add documentation and tests v4: Rebase and prepare for version 1.9.1 Add failing test case when build_subdir is present in the project. Add release note snippet v5: Clarify wording on restrictions on the value of build_subdir. Use the same wording in each place this restriction is described. v6: Move path validation to shared function, validate_build_subdir, instead of duplicating the tests in two places. v7: Update version numbers to 1.10.0 Add TypedDict updates. Remove spurious build_subdir instance variable v8: Oops, missed one version number update. Signed-off-by: Keith Packard <keithp@keithp.com>
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-29environment: move detection functions to envconfig.pyPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-24cmake: Do not pass install prefix explicitly to the CMake interpreterDaniele Nicolodi
There is no point in doing so as it can be readily obtained from the environment. This in preparation of extracting more installation location from the environment.
2025-10-20dependencyfallbacks: move required/disabled check to interpreterDylan Baker
The lookup code only has two callers. One of them is an internal caller that never sets the `required` key, and the other is the interpreter. Moving this code to the interpreter allows us to simplify the common code, especially the types.
2025-10-20interpreter: Rework extract_required_kwarg to have better typingDylan Baker
This allows us to avoid making `feature` a union, therefore if we write code like: ```python disabled, required, feature = extract_required_kwarg(...) if disabled: ... ``` and now mypy knows that feature is a `str` inside the `if disabled` block
2025-10-20interpreter: remove dependency_kwargsDylan Baker
Since it's basically unusued, but the DEPENDENCY_KWS can be used instead This requires changing the number of arguments from 19 to 20 because the `DEPENDENCY_KWS` includes `disabler`, but the `permitted_dependency_kwargs` does not.
2025-10-20interpreter: use typed_kwargs for checking disabler dependencyDylan Baker
2025-10-20interpreter: remove permittedKwargs from dependencyDylan Baker
This is also the ideal time to remove the `allow_unknown` from `typed_kwargs`, as permittedKwargs was providing extra key checking, so now `typed_kwargs` can do that instead.
2025-10-20interpreter: port dependency not_found_message to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency native to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency method to typed_kwargsDylan Baker
This allows us a bunch of nice things: 1. We can use the DependencyMethods enum everywhere 2. The deprecated methods can be checked in the Interpreter, so we can now emit deprecation warnings for stuff that was deperecated in 0.44! 3. We can share this more strongly typed method everywhere
2025-10-20interpreter: port dependency include_type to typed_kargsDylan Baker
The cleanup this allows lower down points out that we don't properly validate the value passed to `as_system()`. I have no idea what happens if you pass a non-valid value, but it's a bug and I've simply made it a hard error. We can re-assess if necessary.
2025-10-20interpreter: port dependency fallback to typed_kwargsDylan Baker
2025-10-20interpreter: port dependencies components to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency cmake_package_version to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency cmake_module_path to typed_kwargsDylan Baker
2025-10-20interpreter: port cmake_args to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency(allow_fallback) to typed_kwargsDylan Baker
2025-10-20cargo: do not propagate cargo interpreter when doing sysdep fallbackXavier Claessens
A cargo subproject can fallback to a regular Meson subproject in the case it has system-deps.
2025-10-20interpreter: Fix extract_object subproject validationXavier Claessens
Fixes: #12519
2025-10-17cargo: Small simplification in path joinXavier Claessens
2025-10-17cargo: Allow a cargo subproject to subdir() into another cargo projectXavier Claessens
Cargo workspaces will use this to have a single subproject defining multiple crates.
2025-10-16backend: remove InterpreterPaolo Bonzini
No one is accessing backend.interpreter anymore, get rid of it to avoid future temptations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build, backend: store build_def_files in BuildPaolo Bonzini
The interpreter's build_def_files are the only remaining piece of interpreter state used by the backend. Compute it once and store it in build, using a property to ensure that it's initialized and accessed correctly. This also removes one of the cases in which introspection uses the interpreter object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build: store Environment in GeneratorPaolo Bonzini
Objects like targets already store the environment in which they were created, do the same for Generator: pass it to the constructor and use it in process_files. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-15revert local_program()Eli Schwartz
This reverts https://github.com/mesonbuild/meson/pull/15107 Explicit objections regarding the design were raised and not answered, so it shouldn't have been merged. It needs to be discussed and revisited.
2025-10-15build: remove build layer validation of Executable(implib)Dylan Baker
This includes cleaning up some of the type handling to account for cleanups that are done at the DSL level.
2025-10-15interpreter: move the BuildTarget install feature validator to KwargInfoDylan Baker
2025-10-15Share implementation between local_program and override_find_programXavier Claessens
2025-10-15Add interpreter kwarg to local_program()Xavier Claessens
2025-10-15Add common ABC for ExternalProgram and LocalProgramXavier Claessens
2025-10-15Replace OverrideExecutable and OverrideProgram with LocalProgramXavier Claessens
2025-10-15Add support for LocalProgram to override_find_program()Xavier Claessens
2025-10-15Add support for LocalProgram to generator()Xavier Claessens