summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-11-17 11:03:53 +0100
committerXavier Claessens <xclaesse@gmail.com>2025-11-17 08:13:05 -0500
commit4fdc1172b7aada1f3335d28c60bfdc4b01ef7ab8 (patch)
tree37b8db3a06577f6668a4f5294a05ee3bd8d7ddef
parenta23aa1132fd75248f1b9617dc518ca3fc69804ba (diff)
downloadmeson-4fdc1172b7aada1f3335d28c60bfdc4b01ef7ab8.tar.gz
rust: allow either crate names or target names in the dependency map
Since commit 44ce04537 ("cargo: Add library API version into its name", 2025-10-28), the target names provided by cargo subprojects have a suffix corresponding to the library API; for example, the target that used to be "gtk4" is now "gtk4+0_10". This however is an implementation detail, and the change broke rust_dependency_maps that expected to use the crate name. While the target name is preferrable, and will work great when Meson is able to create dependency maps by itself (as is the case for the Cargo interpreter), preserve the old behavior by checking also the entry corresponding to the result of _get_rust_crate_name. Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--docs/yaml/functions/_build_target_base.yaml2
-rw-r--r--mesonbuild/backend/ninjabackend.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/docs/yaml/functions/_build_target_base.yaml b/docs/yaml/functions/_build_target_base.yaml
index dec3d8db0..112953387 100644
--- a/docs/yaml/functions/_build_target_base.yaml
+++ b/docs/yaml/functions/_build_target_base.yaml
@@ -333,6 +333,8 @@ kwargs:
in the `dependencies` section of a Cargo.toml file, or
`extern crate gtk4 as gtk` inside Rust code.
+ *Since 1.10.0*, the keys can be either crate names or target names.
+
vala_header:
type: str
description: |
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index fbf6c42fc..71bda303e 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1959,7 +1959,10 @@ class NinjaBackend(backends.Backend):
@staticmethod
def _get_rust_dependency_name(target: build.BuildTarget, dependency: LibTypes) -> str:
- crate_name_raw = target.rust_dependency_map.get(dependency.name, dependency.name)
+ crate_name_raw = target.rust_dependency_map.get(dependency.name, None)
+ if crate_name_raw is None:
+ dependency_crate_name = NinjaBackend._get_rust_crate_name(dependency.name)
+ crate_name_raw = target.rust_dependency_map.get(dependency_crate_name, dependency.name)
return NinjaBackend._get_rust_crate_name(crate_name_raw)
def generate_rust_sources(self, target: build.BuildTarget) -> T.Tuple[T.List[str], str]: