summaryrefslogtreecommitdiff
path: root/mesonbuild/backend
AgeCommit message (Collapse)Author
2025-12-11add clippy-json targetclippy-jsonJohn Turner
Add a clippy-json target to the ninja script. This is useful for rust-analyzer, which requires an "external check command" to function when not using cargo. This also changes the --emit option in the clippy script to "emit", without this, clippy will fail with errors about missing libraries. These would normally be created with the normal compilation target, but we can't rely on that, because if it fails, clippy-json never runs, and you won't get error messages to the LSP.
2025-12-01fix crate name in rust-project.jsonPaolo Bonzini
Include the real crate name, with "_" instead of "-" and without the Meson-specific "+foo" suffix. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-30Bump sln_version_comment to 18 for vs2026 backend.Luke Elliott
Allows version selector to open the correct IDE.
2025-11-23compilers: forward gen_vs_module_defs_args to linkerPaolo Bonzini
This adds support for DEF files to rust and removes some hasattr duck typing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-23Add import std support to MSVC.Jussi Pakkanen
2025-11-23Add basic import std support for GCC.Jussi Pakkanen
2025-11-19compilers: Remove Environment parameter from RustCompiler.lib_file_to_l_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from RustCompiler.get_rustdocDylan Baker
2025-11-19compilers: Remove Environment parameter from CLikeCompiler.gen_dynamic_link_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_compile_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_std_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_link_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.sanitizer_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_library_namingDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_program_dirsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.build_rpath_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_soname_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_library_dirsDylan Baker
2025-11-17rust: allow either crate names or target names in the dependency mapPaolo Bonzini
Since commit 44ce04537 ("cargo: Add library API version into its name", 2025-10-28), the target names provided by cargo subprojects have a suffix corresponding to the library API; for example, the target that used to be "gtk4" is now "gtk4+0_10". This however is an implementation detail, and the change broke rust_dependency_maps that expected to use the crate name. While the target name is preferrable, and will work great when Meson is able to create dependency maps by itself (as is the case for the Cargo interpreter), preserve the old behavior by checking also the entry corresponding to the result of _get_rust_crate_name. Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-17Support Visual Studio 2026.Jussi Pakkanen
2025-11-14Generate a shared library and an import library correctly on OS/2KO Myung-Hun
On OS/2, 1. a shared libary has '.dll' suffix 2. a length of DLL name should not be longer than 8 chars 3. an import library is used to link against a DLL 4. an import library has '_dll.a' suffix.
2025-11-14Extension of the executable is `exe' on OS/2KO Myung-Hun
2025-11-13vala: utilize depfilesValeri Ochinski
2025-11-12compilers: pass target and env to sanitizer_*_argsPaolo Bonzini
The Rust compiler will need these to check the rust_nightly option. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-12rust: call compilers.get_base_link_argsPaolo Bonzini
The rustc invocation performs both compilation and linking, so it should include link-phase arguments for LTO or sanitizers. RustCompiler has been taught how to include these arguments, so now add them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-12ninjabackend: rust: add linker args for cdylibsPaolo Bonzini
These produce a linked build product like binaries and Rust-ABI dylibs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-12interpreter: move backend type checking to interpreterDylan Baker
Of course, this checking isn't actually doing what it claims, as it doesn't actually stop you from writing at target like: ```meson build_target( 'foo', 'srcs/main.c', c_pch : 'src/pch.h', ) ```
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-11vala: Remove space from --target-glib versionChris Mayo
If the dependency version contains a space: dependency('glib-2.0', version: '>= 2.40.0') Then the --target-glib version has a space: --target-glib ' 2.40.0' The quotes and space have no effect on valac. Tidy the output.
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-11-03backends: add CustomTargetIndexes to meson-{test,benchmark}-prereqPaolo Bonzini
If a CustomTargetIndex is passed as an argument to a test, running meson test (with no test glob) does not automatically build the custom_target before running the test, because CustomTargetIndex outputs are not added as prerequisites to the meson-test-prereq and meson-benchmark-prereq targets. Fixes: #14743 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-01Compilers: Add get_depfile_format() methodLuca Bacci
2025-10-29environment: move tool detection functions to a new modulePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29environment, backends: remove is_* methodsPaolo Bonzini
They are duplicates of what is already in compilers and have no state. Just use compilers. Fixes: #15082 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-27rust: drop +SUFFIX from crate namePaolo Bonzini
Allow multiple targets for the same crate name, which is useful when the same crate is used for both the host and the build machine. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-27rust: unify conversion from target name to crate namePaolo Bonzini
_get_rust_dependency_name was less lenient in accepting targets containing invalid characters for a crate name. This made it impossible to link to those targets without using a dependency map. Use the same algorithm to do the conversion. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-20build: Ensure that `vala_*` properties always exist, and are correctDylan Baker
This allows us to do a lot less proxy checking for vala, and lot more "If this thing says it's going to output vala, it's going to output vala. By only setting them when they use vala, we can also be sure that the fields aren't meaningless.
2025-10-16rust: work around unintuitive behavior of -l:-bundlePaolo Bonzini
When a Rust target depends on an intermediate Rust library (.rlib) which itself has a dependency on a native static library, Meson's generated rustc command line failed to collect and propagate the search paths for these indirect native dependencies, leading to a linker error: error: linking with `cc` failed: exit status: 1 = note: rust-lld: error: unable to find library -l:libf.a collect2: error: ld returned 1 exit status The root cause is that the intermediate .rlib's metadata correctly stores the requirement to link the native library (via the -l flag), but it does not store the library's search path (the -L flag); the responsibility for providing the search path is therefore deferred to the final link command. Ensures that search paths for all transitive dependencies are collected, allowing the final linker invocation to find and correctly link the required native libraries. Reported-by: Martin Kletzander <nert.pinx@gmail.com> Fixes: 018d22482 ("ninjabackend: unify conversion from path to -L/-l", 2025-10-08) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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: do not pass Interpreter to Generator.process_filesPaolo Bonzini
All that is needed is the subdir, pass it explicitly (and make it an optional argument so that the backend does not have to pass it). 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-15backend/ninja: Ensure that a rust file is found when using StructuredSourcesDylan Baker
When a structured source contains non rust files, the backend may select such a file to treat as the main file. That doesn't work obviously, so instead filter the main file such that it must be a rust file.
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-15Add support for LocalProgram to override_find_program()Xavier Claessens
2025-10-14Make use of build TypeAliasesDylan Baker
There are a lot of spelled out unions for these types, lets reduce that number
2025-10-11fix rustc -l argument on WindowsPaolo Bonzini
On Windows, rustc searches both FOO.lib and libFOO.a when passed -lfoo. This means that the check for nonstandard names in the Unix sense is too struct, and indeed it breaks passing for example -lkernel32 (which adds kernel32.lib to the link). Fix this by special casing Windows. Extract the logic to the Rust compiler class for clarity. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-11ninjabackend: fix cut and paste issuePaolo Bonzini
The variable for the .a here is called "a", not "lib". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-08ninja: don't exclude rustc native-static-link argsMarc-André Lureau
`rustc --crate-type staticlib --print native-static-libs` doesn't print the default libraries being linked with rustc by default, at least not with rustc 1.89.0 (29483883e 2025-08-04). Stripping those by default, such as ws2_32 on win32, prevents from linking programs using sockets (ex qemu). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2025-10-08rust: query linker in addition to compiler for verbatim supportPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>