Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ These environment variables are exported for use in build scripts and other down
| Variable | Description | Example |
|----------|-------------|---------|
| `CARGO_NDK_ANDROID_PLATFORM` | The Android platform API number as an integer | `21` |
| `CARGO_NDK_NDK_VERSION` | The detected Android NDK revision | `28.0.12433566` |
| `CARGO_NDK_OUTPUT_PATH` | The output path as specified with the `-o` flag | `./jniLibs` |
| `CARGO_NDK_SYSROOT_PATH` | Path to the sysroot inside the Android NDK | `/path/to/ndk/toolchains/llvm/prebuilt/...` |
| `CARGO_NDK_SYSROOT_TARGET` | The target name for files inside the sysroot (differs from LLVM triples) | `aarch64-linux-android` |
Expand Down
6 changes: 6 additions & 0 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn clang_lib_path(ndk_home: &Path) -> PathBuf {
const CARGO_NDK_SYSROOT_PATH_KEY: &str = "CARGO_NDK_SYSROOT_PATH";
const CARGO_NDK_SYSROOT_TARGET_KEY: &str = "CARGO_NDK_SYSROOT_TARGET";
const CARGO_NDK_SYSROOT_LIBS_PATH_KEY: &str = "CARGO_NDK_SYSROOT_LIBS_PATH";
const CARGO_NDK_NDK_VERSION_KEY: &str = "CARGO_NDK_NDK_VERSION";

fn is_64bit(triple: &str) -> bool {
triple.starts_with("aarch64") || triple.starts_with("x86_64")
Expand Down Expand Up @@ -153,6 +154,10 @@ pub(crate) fn build_env(
"CARGO_NDK_ANDROID_PLATFORM".to_string(),
platform.to_string().into(),
),
(
CARGO_NDK_NDK_VERSION_KEY.to_string(),
ndk_version.to_string().into(),
),
("ANDROID_PLATFORM".to_string(), platform.to_string().into()),
("ANDROID_ABI".to_string(), android_abi.into()),
// https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#environment-variables
Expand Down Expand Up @@ -379,6 +384,7 @@ mod tests {
);

assert_eq!(env["CARGO_NDK_ANDROID_PLATFORM"], "28");
assert_eq!(env["CARGO_NDK_NDK_VERSION"], "28.0.0");
assert_eq!(env["ANDROID_PLATFORM"], "28");
assert_eq!(env["ANDROID_ABI"], "arm64-v8a");
}
Expand Down
Loading