Skip to content

Conversation

@bonzini
Copy link
Collaborator

@bonzini bonzini commented Oct 22, 2025

This introduces a skeletal implementation of #14639, which however is already relatable to what is implemented by the cmake module. In particular, workspace().subproject() works, and allows retrieving the overridden dependency as well as the Cargo features of the crate.

Current WIP full version: https://github.com/bonzini/meson/commits/cargo-object-full

Fixes: #13404
Fixes: #14290

@bonzini bonzini requested a review from jpakkane as a code owner October 22, 2025 17:07
@bonzini bonzini added module:rust Specific to the Rust module dependencies:cargo Issues related to using cargo subprojects labels Oct 22, 2025
@bonzini bonzini force-pushed the cargo-object branch 9 times, most recently from f3af508 to 834dd17 Compare October 23, 2025 15:37
@bonzini bonzini requested a review from dcbaker as a code owner October 23, 2025 15:37
@bonzini bonzini force-pushed the cargo-object branch 6 times, most recently from b724c84 to cd0097f Compare October 25, 2025 15:49
@bonzini bonzini requested a review from mensinda as a code owner October 25, 2025 15:49
@bonzini bonzini force-pushed the cargo-object branch 7 times, most recently from e2a1d59 to 33c8c6c Compare October 28, 2025 17:17
@bonzini bonzini force-pushed the cargo-object branch 3 times, most recently from 41f55fe to 2a8dfca Compare October 29, 2025 20:25
@bonzini bonzini added this to the 1.11 milestone Nov 7, 2025
@bonzini bonzini force-pushed the cargo-object branch 3 times, most recently from ee40006 to 8ac0906 Compare November 18, 2025 08:57
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: mesonbuild#13404
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: mesonbuild#14290
This is up to 2x faster because it avoids checks for pkg-config and cmake.

Signed-off-by: Paolo Bonzini <[email protected]>
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies:cargo Issues related to using cargo subprojects module:rust Specific to the Rust module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to disable default-features on rust dependencies? When compiling Rust project with meson, dependencies' features are not fully resolved

1 participant