As in https://github.com/bbqsrc/cargo-ndk/issues/89, we build multiple ffi libraries in the same cargo workspace. cargo-ndk ends up copying all libraries in the target directory instead of only the ones built for that invocation. Gradle then will complain with something like 2 files found with path 'lib/arm64-v8a/libffi.so' from inputs in the merge JNI libraries step.
This change parses the library name from Cargo.toml and copies only the library (per target) to the output directory. I'm not sure if this will end up missing some libraries in copy. As far as I can tell, every rust crate can have 0 or 1 libraries, and package.name is required in Cargo.toml so we always have a name.
As in https://github.com/bbqsrc/cargo-ndk/issues/89, we build multiple ffi libraries in the same cargo workspace.
cargo-ndk
ends up copying all libraries in the target directory instead of only the ones built for that invocation. Gradle then will complain with something like2 files found with path 'lib/arm64-v8a/libffi.so' from inputs
in the merge JNI libraries step.This change parses the library name from Cargo.toml and copies only the library (per target) to the output directory. I'm not sure if this will end up missing some libraries in copy. As far as I can tell, every rust crate can have 0 or 1 libraries, and
package.name
is required inCargo.toml
so we always have a name.The library name is derived from
lib.name
if set, or frompackage.name
if not, per https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-name-field