bbqsrc / cargo-ndk

Compile Rust projects against the Android NDK without hassle
Apache License 2.0
712 stars 64 forks source link

copy only the libraries that were built #135

Closed mightyguava closed 6 months ago

mightyguava commented 6 months ago

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.

The library name is derived from lib.name if set, or from package.name if not, per https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-name-field

mightyguava commented 6 months ago

@bbqsrc how do I get this new change? Do I wait for you to get a new tag? Not sure how cargo plugins versioning works

bbqsrc commented 6 months ago

Published in 3.5.5. 😄

bbqsrc commented 6 months ago

done