cargo: Use the library name instead of package name

The library name defaults to its package name, but it can be different.
For example:
- package name: cairo-sys-rs
- library name: cairo-sys
- dependency name: ffi
pull/12657/merge
Xavier Claessens 8 months ago committed by Xavier Claessens
parent afd89440aa
commit ed62a975b2
  1. 6
      mesonbuild/cargo/interpreter.py
  2. 3
      test cases/rust/22 cargo subproject/subprojects/foo-0-rs/Cargo.toml
  3. 2
      test cases/rust/22 cargo subproject/subprojects/foo-0-rs/lib.rs
  4. 2
      test cases/rust/22 cargo subproject/subprojects/libname-1-rs.wrap
  5. 7
      test cases/rust/22 cargo subproject/subprojects/libname-1-rs/Cargo.toml
  6. 3
      test cases/rust/22 cargo subproject/subprojects/libname-1-rs/lib.rs

@ -648,7 +648,9 @@ class Interpreter:
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'),
@ -658,7 +660,7 @@ class Interpreter:
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),
]

@ -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"]

@ -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();

@ -0,0 +1,7 @@
[package]
name = "libname"
version = "1"
[lib]
name="libothername"
path = "lib.rs"
Loading…
Cancel
Save