From ecc8032dcb7cd5fc8c3b8e468818ca235cfa9ff4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 26 Oct 2025 08:36:16 +0100 Subject: modules: rust: implement workspace.subproject() and package.dependency() Signed-off-by: Paolo Bonzini --- docs/markdown/Rust-module.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'docs') diff --git a/docs/markdown/Rust-module.md b/docs/markdown/Rust-module.md index 1e8305d07..1126723ca 100644 --- a/docs/markdown/Rust-module.md +++ b/docs/markdown/Rust-module.md @@ -230,3 +230,38 @@ cargo_ws = rustmod.workspace(features: []) The first form says "use whatever features are configured," while the latter forms say "require this specific configuration," which may conflict with the parent project. + +## Workspace object + +### workspace.subproject() + +```meson +package = ws.subproject(package_name, api) +``` + +Returns a `package` object for managing a specific package within the workspace. + +Positional arguments: +- `package_name`: (`str`) The name of the package to retrieve +- `api`: (`str`, optional) The version constraints for the package in Cargo format + +## Package object + +The package object returned by `workspace.subproject()` provides methods +for working with individual packages in a Cargo workspace. + +### subproject.dependency() + +```meson +dep = subproject.dependency(...) +``` + +Returns a dependency object for the subproject that can be used with other Meson targets. + +*Note*: right now, this method is implemented on top of the normal Meson function +[[dependency]]; this is subject to change in future releases. It is recommended +to always retrieve a Cargo subproject's dependency object via this method. + +Keyword arguments: +- `rust_abi`: (`str`, optional) The ABI to use for the dependency. Valid values are + `'rust'`, `'c'`, or `'proc-macro'`. The package must support the specified ABI. -- cgit v1.2.3