summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/rust.py
AgeCommit message (Collapse)Author
2025-12-22modules: rust: add package.override_dependency methodPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: add package.shared_module methodPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: add package.executablePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: add package.library/package.proc_macro methodsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: invoke subprojects automatically from dependencies()Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: add dependencies() method to package objectPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22rust: add to_system_dependencyPaolo Bonzini
Move the logic for system dependencies outside Cargo.interpreter and into the rust module, so that it can be reused by the workspace object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: add workspace methods returning arguments for build targetsPaolo Bonzini
Add rustc_args(), env(), and rust_dependency_map() methods to the RustPackage class. They simply delegate to PackageState and PackageConfiguration. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: implement workspace.package()Paolo Bonzini
Note that, as shown in the testcase, package() works in the subproject as well. This means that in the future the Cargo code generator can be changed to reduce the amount of generated code and instead rely on the package object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: implement more package accessorsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: implement workspace.packages()Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22modules: rust: implement workspace.subproject() and package.dependency()Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22cargo: add configurable features to InterpreterPaolo Bonzini
Add features property to cargo.Interpreter to make default features configurable; customization of which features are enabled by default is triggered by rust.workspace(). Fixes: #14290 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22rust: add rust.workspace() skeleton implementationPaolo Bonzini
rust.workspace() is the entry point for global feature resolution. It loads a Cargo.toml file and ensures that all dependencies will be built with the correct set of features. Fixes: #13404 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-19compilers: Remove Environment parameter from RustCompiler.get_rustdocDylan Baker
2025-11-18rust.proc_macro: fix type of kwargs["native"]Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-14Add `shortname' kwarg for a short DLL name on OS/2KO Myung-Hun
Give an user opportunities to mangle a custom short name for a DLL on OS/2.
2025-11-05interpreter: Add rust_crate_type to kwargs TypeDictDylan Baker
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: use a TypedDict for Executable kwargsDylan Baker
2025-10-15build: Add a TypedDict for BuildTarget keyword argumentsDylan Baker
This has the "processed" keyword arguments that the interpreter is supposed to create for us, or that we expect internal users to build by build. This requires some hacking around in the rust module for the moment because we suddenly have a type.
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-15module/rust: set _FILE_OFFSET_BITS=64 for bindgenDavid Rheinsberg
Meson sets 64-bit offsets as the default for all platforms but MSVC. Lets do the same for bindgen, to ensure we get compatible definitions. Do this by calling `get_always_args()` on the first C'ish host compiler we can find. Note that the `libc` crate does not expose 64-bit types as the default and there is no intention to do so. Instead, it exposes 32-bit default types, plus the 64-bit extended types with the `*64` suffix. This is quite unfortunate, but it seems unlikely to change [1]. However, use of `bindgen` is usually not tied to the `libc` crate. Instead, it is tied to whatever other C code in the same project does. And Meson sets `_FILE_OFFSET_BITS=64` unconditionally for all this C code. It thus seems much more plausible for Meson to also imply it for bindgen. Given that Rust code that uses the `libc` crate very likely already uses the `*64` suffixed variants, they are unaffected by whether `_FILE_OFFSET_BITS=64` is set. If they use `libc::off_t`, they already explicitly state that they use the 32-bit variant on 32-bit platforms. Hence, it is inherently incompatible to C code that uses `_FILE_OFFSET_BITS=64`. And lastly, if a Meson project is Rust-only, but generates its internal code from its public C headers, then it is better suited to actually call `add_language('c')` and ensure that Meson knows what the compiler configuration for the target platform actually is. Otherwise, bindgen cannot know what platform options to enable. Hence, warn loudly if `rust.bindgen()` is used without a configured C compiler (even if the compiler used by bindgen does not necessarily match the configured one). [1] https://github.com/rust-lang/libc/issues/3223#issuecomment-2033298952
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-07-21rust: only allow rust.doctests if the target is a cratePaolo Bonzini
Rust doctests implicitly use the base target as a crate. This is not possible unless the target uses the Rust ABI. If someone uses a C-ABI target with rust.doctest(), you get an unresolved module error and it is not clear what's really going on, so add a more specific error. Cargo does the same, though it only reports a warning. Fixes: #14813 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-13rust: skip doctests when build machine cannot run host binariesPaolo Bonzini
"rustdoc --test" relies on running host binaries, and has no way of wrapping them with Meson's exe_wrapper. Just skip the doctests in that case. Fixes: #14583 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02rust: add link_whole to rust.test and rust.doctestPaolo Bonzini
QEMU needs it in its integration tests (in order to run global constructors), and therefore in rust.doctest too. With this change I could do: # Rust executables do not support objects, so add an intermediate step. rust_qemu_api_objs = static_library( 'rust_qemu_api_objs', objects: [libqom.extract_all_objects(recursive: false), libhwcore.extract_all_objects(recursive: false)]) rust.doctest('rust-qemu-api-doc', _qemu_api_rs, dependencies: [qemu_api, qemu_api_macros], link_with: libqemuutil, link_whole: [rust_qemu_api_objs], suite: ['doc', 'rust']) followed by "meson test --suite doc". For completeness, add it to rust.test as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02rust: add rust.doctestPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02rust: extract common parts of rust.test and rust.doctestPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02interpreter, rust: move "args" out of BaseTestPaolo Bonzini
rust.doctest() will have to typecheck that to a list of strings, no other argument types are allowed. Extract the field out of BaseTest, placing it in FuncBenchmark and the rust modules's FuncTest. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02build, interpreter: associate a doctest target to a BuildTargetPaolo Bonzini
A doctest target is a separate build target (with its own linker arguments, including dependencies) that is built and added as a unit test whenever the parent target is built. The doctest's target is not accessible via ninja. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-02-27modules/rust: use 'nightly' as the bindgen version if the compiler is nightlyDylan Baker
This adds tracking for both nightly and beta to the rust compiler.
2025-02-27modules/rust: set --rust-edition for bindgen >= 0.71Dylan Baker
But only if the user hasn't manually set it.
2025-02-27modules/rust: Update bindgen target error checking for bindgen >= 0.71Dylan Baker
Which has both changed the error message and relaxed the check. In theory we wouldn't hit this unless you have a very old bindgen and a very new rustc.
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen
2024-12-20modules/rust: Specify the compiler version to bindgen when possibleDylan Baker
bindgen by default may output code that an older rustc cannot successfully consume. To avoid this, we check if bindgen supports the rustc version we're using, if so, and if the user didn't set the `--rust-target` option, we will supply it to ensure that bindgen writes out code our rustc can use. If it does not support that version explicitly, we leave it at the default, assuming that our compiler version is newer than bindgen.
2024-11-19rust: avoid warnings from rust.testPaolo Bonzini
Any argument from the base target is copied to the test target, but some keyword arguments for libraries are not available in executable. Remove them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-09-14Fix various incorrect uses of `its` vs `it's`.Andrew McNulty
These errors can make reading comments and documentation unnecessarily confusing for users and contributors who do not speak English as their first language.
2024-07-17Remove language (AKA compiler) type from OptionKey.Jussi Pakkanen
2024-06-14Rename option variable to optstore to make it unique.Jussi Pakkanen
2024-02-26modules/rust: Fix New Version check that was not updatedDylan Baker
Should be 1.4.0 but was 1.3.0
2024-02-24meson/rust: wrap `bindgen`s `wrap-static-fns` functionalityKarol Herbst
This way the `rust.bindgen` can generate a second output being a C file, which contains wrapper functions for static inline ones. This output file can then be compiled via C targets.
2024-02-23modules/rust: allow setting a version constraint on bindgenDylan Baker
This allows us to ensure that the bindgen we're using is suitable for our purpose.
2024-02-23modules/rust: inject a C/C++ standard for bindgenDylan Baker
Especially for C++ this is very important.
2024-02-23modules/rust: Allow explicitly setting the language to bindDylan Baker
This may be of particular use when a header is .h but should be treated as a C++ header instead of a C header.
2024-02-23rust/bindgen: Use Meson rules for C++ headersDylan Baker
Bindgen natively only considers .hpp to be C++ headers, but Meson considers some additional extensions including .hh and .hxx to be C++.
2024-01-30rust: Add `--extern proc_macro` in `rust.proc_macro() not in cargo translationDylan Baker
Cargo does this by default, so it's reasonable that we do the same. Fixes: #12758
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field