Skip to content

Commit b724c84

Browse files
committed
docs: add release notes for rust.workspace()
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent c8fe8d9 commit b724c84

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

docs/markdown/Rust.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,40 @@ target is a proc macro or dylib, or it depends on a dylib, in which case [`-C
9898
prefer-dynamic`](https://doc.rust-lang.org/rustc/codegen-options/index.html#prefer-dynamic)
9999
will be passed to the Rust compiler, and the standard libraries will be
100100
dynamically 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.

docs/markdown/Wrap-dependency-system-manual.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,7 @@ Since *1.5.0* Cargo wraps can also be provided with `Cargo.lock` file at the roo
368368
of (sub)project source tree. Meson will automatically load that file and convert
369369
it into a series of wraps definitions.
370370

371-
Since *1.10.0* Workspace Cargo.toml are supported. For the time being it is
372-
recommended to regroup all Cargo dependencies inside a single workspace invoked
373-
from the main Meson project. When invoking multiple different Cargo subprojects
374-
from Meson, feature resolution of common dependencies might be wrong.
371+
Since *1.10.0* Workspace Cargo.toml are supported.
375372

376373
## Using wrapped projects
377374

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Cargo workspace object
2+
3+
Meson now is able to parse the toplevel `Cargo.toml` file of the
4+
project when the `workspace()` method of the Rust module is called.
5+
This guarantees that features are resolved according to what is
6+
in the `Cargo.toml` file, and in fact enables configuration of
7+
features for the build.
8+
9+
The returned object also allows retrieving features and dependencies
10+
for Cargo subprojects.
11+
12+
While Cargo subprojects remain experimental, the Meson project will
13+
try to keep the workspace object reasonably backwards-compatible.

0 commit comments

Comments
 (0)