cargo-ndk icon indicating copy to clipboard operation
cargo-ndk copied to clipboard

Feature request: Use cargo-ndk as a library inside build.rs to get the correct environment based on current arch

Open bes opened this issue 4 months ago • 1 comments

I don't know if this is feasible, but I thought I'd ask.

I would like all cargo-ndk environment variables (same as are available through cargo ndk-env, including AR_ and CC_) to be added to the build through build.rs through a function call like ndk_env() or ndk_env!().

Is that even possible, would all the sub crates pick up stuff like CC_ from cargo:rustc-env?

Motivating example

I am using RustRover, and RustRover has a selector for putting the editor into an "architecture mode" like aarch64-linux-android, armv7-linux-androideabi, or aarch64-apple-ios.

When switching architecture mode, RustRover does a "cargo refresh"; basically tries to configure all the crates to use the current platform.

Currently I am using cargo ndk-env -P29 -t arm64-v8a in .zshrc, which is fine, but I can't easily switch to armv7-linux-androideabi in RustRover, and I have to tell everyone else that they need to use aarch64-linux-android.

Alternative solution

I could write a bunch of code and use the json output inside build.rs to get the same result.

bes avatar Aug 09 '25 20:08 bes