@@ -98,3 +98,40 @@ target is a proc macro or dylib, or it depends on a dylib, in which case [`-C
9898prefer-dynamic`](https://doc.rust-lang.org/rustc/codegen-options/index.html#prefer-dynamic)
9999will be passed to the Rust compiler, and the standard libraries will be
100100dynamically linked.
101+
102+ # # Cargo interaction
103+
104+ *Since 1.10.0*
105+
106+ In most cases, a Rust program will use Cargo to download crates. Meson is able
107+ to build Rust library crates based on a `Cargo.toml` file; each external crate
108+ corresponds to a subproject. Rust module's ` that do not need a `build.rs` file
109+ need no intervention, whereas if a `build.rs` file is present it needs to be
110+ converted manually to Meson code.
111+
112+ To enable automatic configuration of Cargo dependencies, your project must
113+ have `Cargo.toml` and `Cargo.lock` files in the root source directory;
114+ this enables proper feature resolution across crates. You can then
115+ create a workspace object using the Rust module, and retrieve specific
116+ packages from the workspace :
117+
118+ ` ` ` meson
119+ rust = import('rust')
120+ cargo = rust.workspace()
121+ anyhow_dep = ws.subproject('anyhow').dependency()
122+ ` ` `
123+
124+ The workspace object also enables configuration of Cargo features, for example
125+ from Meson options :
126+
127+ ` ` ` meson
128+ ws = rust.workspace(
129+ features: ['feature1', 'feature2'])
130+ ` ` `
131+
132+ # ## Limitations
133+
134+ All your own crates must be built using the usual Meson functions such as
135+ [[static_library]] or [[executable]]. In the future, workspace object
136+ functionality will be extended to help building rustc command lines
137+ based on features, dependency names, and so on.
0 commit comments