-
Notifications
You must be signed in to change notification settings - Fork 114
Expose C and C++ build tools to crates #230
Comments
I think that this would be nice to have. However, many use cases for |
Agreed. I was thinking mostly about dependencies of a lot of gfx related libraries like shaderc. |
Libraries that used to link statically no longer work with the latest cargo-apk. This is another side affect of building a static library instead of a dynamic library. Since static libraries aren't linked, the native dependencies are not linked during the build process. Generating a rlib will embed that dependency info into the static library but there would need to be someway to get it from the rlib or other means and pass it to ndk-build. |
As much as I liked the idea of using ndk-build to avoid getting entangled in the android toolchain, I am leaning towards not using it as being the cleanest solution. If we avoided ndk-make, we'd need to build the android_native_glue ourselves which should be straightforward anyways. I suggest:
@mb64 thoughts? |
This seemed weird to me, so I made a simple test case to see what the normal behavior was. I had a crate with a static native dependency that I compiled as a static lib, and it worked just fine; i.e. the static native dependency was included in the static library. This gives me hope that this is not an irresolvable issue.
The proposed plan looks OK to me. One thing that would simplify it, assuming the changes in #228 are agreed upon, is to have |
Perhaps rustc will combine static libraries with I saw an issue on the I have experimenting with the proposed integration and things are working for the most part. It builds off #231 so things will need to be adjusted if that isn't merged. It currently includes tests which builds C and C++ libraries with Caveats
Once the next revision of the build system is ready, I think it would be reasonable to go ahead and merge it along with a note about the C++ issues. Once R21 is released, we can switch to linking
Building TLDR: I've got a working version but it'll be a week or so before it's ready and it's currently dependent on #231. |
I would like to ask whether this is something that people felt should be part of
cargo-apk
before implementing this.cc-rs
andcmake-rs
are commonly used for building C and C++ libraries via build scripts.It is currently the user's responsibility to expose the appropriate build tools. I propose that
cargo-apk
do what is necessary to expose the NDK provided build tools to the build process. This will mostly involve setting environment variables based on the NDK location, ABI, and min_version_sdk.While there may be aspects of this that can be used to improve
cmake-rs
, the build tools used should reflect the min_sdk_version in the Cargo.toml. As such, it is not practical forcc-rs
andcmake-rs
to determine the appropriate compiler.Benefits:
I have experimented with doing this manually but it is non-trivial to manually set the environment variables in a way that would support multiple ABIs.
References:
The text was updated successfully, but these errors were encountered: