diff --git a/mesonbuild/cargo/interpreter.py b/mesonbuild/cargo/interpreter.py index 4e10110a5aea..3a4cccfa638b 100644 --- a/mesonbuild/cargo/interpreter.py +++ b/mesonbuild/cargo/interpreter.py @@ -645,7 +645,9 @@ def _create_lib(self, pkg: PackageState, build: builder.Builder, crate_type: man dep = pkg.manifest.dependencies[name] dependencies.append(build.identifier(_dependency_varname(dep.package))) if name != dep.package: - dependency_map[build.string(fixup_meson_varname(dep.package))] = build.string(name) + dep_pkg = self._dep_package(dep) + dep_lib_name = dep_pkg.manifest.lib.name + dependency_map[build.string(fixup_meson_varname(dep_lib_name))] = build.string(name) rust_args: T.List[mparser.BaseNode] = [ build.identifier('features_args'), @@ -655,7 +657,7 @@ def _create_lib(self, pkg: PackageState, build: builder.Builder, crate_type: man dependencies.append(build.identifier(_extra_deps_varname())) posargs: T.List[mparser.BaseNode] = [ - build.string(fixup_meson_varname(pkg.manifest.package.name)), + build.string(fixup_meson_varname(pkg.manifest.lib.name)), build.string(pkg.manifest.lib.path), ] diff --git a/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/Cargo.toml b/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/Cargo.toml index 858efa4dd9cc..8c5351a77b2e 100644 --- a/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/Cargo.toml +++ b/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/Cargo.toml @@ -24,6 +24,9 @@ mybar = { version = "0.1", package = "bar", default-features = false } version = "0.0.1" features = ["f1"] +[dependencies.libname] +version = "1" + [features] default = ["f1"] f1 = ["f2", "f3"] diff --git a/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/lib.rs b/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/lib.rs index a1a976a80339..4497dc4a4f3e 100644 --- a/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/lib.rs +++ b/test cases/rust/22 cargo subproject/subprojects/foo-0-rs/lib.rs @@ -1,4 +1,5 @@ extern crate common; +extern crate libothername; extern "C" { fn extra_func() -> i32; @@ -8,6 +9,7 @@ extern "C" { #[no_mangle] pub extern "C" fn rust_func() -> i32 { assert!(common::common_func() == 0); + assert!(libothername::stuff() == 42); let v: i32; unsafe { v = extra_func(); diff --git a/test cases/rust/22 cargo subproject/subprojects/libname-1-rs.wrap b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs.wrap new file mode 100644 index 000000000000..99686e90e78e --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs.wrap @@ -0,0 +1,2 @@ +[wrap-file] +method = cargo diff --git a/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/Cargo.toml b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/Cargo.toml new file mode 100644 index 000000000000..1fbc87c166ff --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "libname" +version = "1" + +[lib] +name="libothername" +path = "lib.rs" diff --git a/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/lib.rs b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/lib.rs new file mode 100644 index 000000000000..ff82dd1004be --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/libname-1-rs/lib.rs @@ -0,0 +1,3 @@ +pub fn stuff() -> i32 { + 42 +}