Skip to content

MOB-89: cpp_archive NDK resolution honors ANDROID_HOME#40

Merged
GenericJam merged 1 commit into
masterfrom
MOB-89-cpparchive-ndk
Jul 12, 2026
Merged

MOB-89: cpp_archive NDK resolution honors ANDROID_HOME#40
GenericJam merged 1 commit into
masterfrom
MOB-89-cpparchive-ndk

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

Problem

MobDev.Plugin.CppArchive (and MobDev.NxEigenNif, which it was copied from) resolved the Android NDK with a hardcoded ~/Library/Android/sdk/ndk/<ver> + darwin-x86_64 host, ignoring ANDROID_HOME / ANDROID_SDK_ROOT — unlike the main MobDev.NativeBuild.ndk_sysroot/0, which honors them. So a lang: :cpp_archive plugin build (e.g. mob_nx_eigen) failed with NDK toolchain not found at ~/Library/Android/sdk/ndk/<ver> on any machine whose NDK lives elsewhere (CI, a shared SDK), even with ANDROID_HOME set. Surfaced during the MOB-42 nx_eigen build verification.

Fix

MobDev.NdkVersion.sdk_root/0 already reads ANDROID_HOMEANDROID_SDK_ROOT → OS default. Added root/0, host/0, toolchain_bin/0, sysroot/0 on top of it and routed all three call sites through them:

  • cpp_archive.exdefault_ndk_root / android_toolchain_bin
  • nx_eigen_nif.ex — the identical hardcoded copy
  • native_build.exndk_sysroot/0 now delegates (provably equivalent, and now also honors ANDROID_SDK_ROOT + Linux host)

One source of truth, so the NDK path can't diverge again.

Tests

ndk_version_test.exs pins root/0 honoring ANDROID_HOME (not a hardcoded ~/Library path), the ANDROID_SDK_ROOT fallback, the host tag, and sysroot/toolchain composition. cpp_archive + native_build suites stay green; mix credo --strict clean.

Part of making mob_nx_eigen build out-of-the-box (MOB-42); pairs with MOB-90 (Eigen provisioning).

🤖 Generated with Claude Code

MobDev.Plugin.CppArchive and MobDev.NxEigenNif hardcoded
~/Library/Android/sdk/ndk/<ver> (+ darwin-x86_64), ignoring ANDROID_HOME /
ANDROID_SDK_ROOT — so a lang: :cpp_archive plugin build failed with
'NDK toolchain not found' wherever the NDK lived elsewhere, unlike the main
NativeBuild path which honored ANDROID_HOME. Found building mob_nx_eigen.

Add shared MobDev.NdkVersion.{root,host,toolchain_bin,sysroot}/0 (built on the
existing sdk_root/0, which already reads ANDROID_HOME/ANDROID_SDK_ROOT) and route
all three call sites through them — cpp_archive, nx_eigen_nif, and native_build's
ndk_sysroot — so the NDK path is single-sourced and can't diverge again.

Tests pin root/0 honoring ANDROID_HOME (not a hardcoded ~/Library path),
ANDROID_SDK_ROOT fallback, host tag, and sysroot/toolchain composition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@GenericJam GenericJam merged commit e5faf75 into master Jul 12, 2026
3 checks passed
@GenericJam GenericJam deleted the MOB-89-cpparchive-ndk branch July 12, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant