Skip to main content

Module android_ndk

Module android_ndk 

Source
Expand description

Android NDK toolchain resolution for the hot-patch link step.

Mirrors whisker-build/src/android.rs’s NDK lookup (deliberately duplicated, not shared) so the dev-server doesn’t pull the whole whisker-build crate into its dep tree just for two helpers. The two implementations need to stay in sync — if NDK layouts shift, both have to learn about the new shape.

What this module gives us:

  • resolve the NDK root (env first, then $ANDROID_HOME/ndk/<v>)
  • pick a host-tag for the toolchain bin dir
  • locate <prefix><api>-clang for an ABI

Tier 1’s link step (build_link_plan + run_link_plan) uses the returned clang as both linker_path (what we spawn) and WHISKER_REAL_LINKER (what the linker shim forwards to during the fat build). Same binary on both sides keeps SDK / sysroot resolution consistent.

Functions§

abi_from_jni_libs_path
Pure helper: convert an existing-on-disk dylib path under a jniLibs tree to its ABI. Used by the patcher to figure out which NDK clang to use without the caller having to plumb the ABI separately. Returns None if the path doesn’t fit the …/jniLibs/<abi>/lib<crate>.so shape.
android_clang_for
Locate the NDK clang for (abi, api). The returned path is the API-pinned wrapper (e.g. aarch64-linux-android21-clang) — both Builder::with_capture (as WHISKER_REAL_LINKER) and the thin-rebuild link step (as linker_path) need this same binary.
android_home
Find the Android SDK root. Honours ANDROID_HOME; otherwise falls back to the macOS default install location.
clang_target_prefix
clang’s --target=<prefix><api> prefix per ABI. Differs from the Rust triple for armeabi-v7a (clang wants armv7a-linux-androideabi).
host_tag
NDK toolchain host tag (darwin-x86_64 / linux-x86_64 / …). NDK ships darwin-x86_64 even on Apple Silicon.
ndk_bin_dir
<NDK>/toolchains/llvm/prebuilt/<host>/bin. Pulled out so future helpers (llvm-ar, ranlib, lld-link) don’t have to recompose it.
ndk_home
Find the NDK root. ANDROID_NDK_HOME wins; otherwise picks the first installed entry from [PREFERRED_NDKS] under <ANDROID_HOME>/ndk/.