aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2024-03-09 18:44:40 -0500
committerXavier Claessens <xclaesse@gmail.com>2024-10-24 11:00:10 -0400
commitafd89440aaf114c00652d799b8043d3d43fb807a (patch)
tree7c700f9d4fa9444c75a76ee874edb9f8f77ac994 /docs
parentc02e0b7b1e2499f3ae18d26e443e18043fff3046 (diff)
downloadmeson-afd89440aaf114c00652d799b8043d3d43fb807a.zip
meson-afd89440aaf114c00652d799b8043d3d43fb807a.tar.gz
meson-afd89440aaf114c00652d799b8043d3d43fb807a.tar.bz2
cargo: Fix feature resolution
Introduce a global Cargo interpreter state that keeps track of enabled features on each crate. Before generating AST of a Cargo subproject, it downloads every sub-subproject and resolves the set of features enabled on each of them recursively. When it later generates AST for one its dependencies, its set of features and dependencies is already determined.
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/Wrap-dependency-system-manual.md21
-rw-r--r--docs/markdown/snippets/cargo_features.md14
2 files changed, 14 insertions, 21 deletions
diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md
index d84e4aa..c1652c1 100644
--- a/docs/markdown/Wrap-dependency-system-manual.md
+++ b/docs/markdown/Wrap-dependency-system-manual.md
@@ -354,27 +354,6 @@ method = cargo
dependency_names = foo-bar-0.1-rs
```
-Cargo features are exposed as Meson boolean options, with the `feature-` prefix.
-For example the `default` feature is named `feature-default` and can be set from
-the command line with `-Dfoo-1-rs:feature-default=false`. When a cargo subproject
-depends on another cargo subproject, it will automatically enable features it
-needs using the `dependency('foo-1-rs', default_options: ...)` mechanism. However,
-unlike Cargo, the set of enabled features is not managed globally. Let's assume
-the main project depends on `foo-1-rs` and `bar-1-rs`, and they both depend on
-`common-1-rs`. The main project will first look up `foo-1-rs` which itself will
-configure `common-rs` with a set of features. Later, when `bar-1-rs` does a lookup
-for `common-1-rs` it has already been configured and the set of features cannot be
-changed. If `bar-1-rs` wants extra features from `common-1-rs`, Meson will error out.
-It is currently the responsibility of the main project to resolve those
-issues by enabling extra features on each subproject:
-```meson
-project(...,
- default_options: {
- 'common-1-rs:feature-something': true,
- },
-)
-```
-
In addition, if the file `meson/meson.build` exists, Meson will call `subdir('meson')`
where the project can add manual logic that would usually be part of `build.rs`.
Some naming conventions need to be respected:
diff --git a/docs/markdown/snippets/cargo_features.md b/docs/markdown/snippets/cargo_features.md
new file mode 100644
index 0000000..26f1bff
--- /dev/null
+++ b/docs/markdown/snippets/cargo_features.md
@@ -0,0 +1,14 @@
+## Cargo features are resolved globally
+
+When configuring a Cargo dependency, Meson will now resolve its complete
+dependency tree and feature set before generating the subproject AST.
+This solves many cases of Cargo subprojects being configured with missing
+features that the main project had to enable by hand using e.g.
+`default_options: ['foo-rs:feature-default=true']`.
+
+Note that there could still be issues in the case there are multiple Cargo
+entry points. That happens if the main Meson project makes multiple `dependency()`
+calls for different Cargo crates that have common dependencies.
+
+Breaks: This change removes per feature Meson options that were previously
+possible to set as shown above or from command line `-Dfoo-rs:feature-foo=true`.