The Android 4.2 source code ships a ndk
directory with NDK build scripts.
These tools download various upstream imports from https://android.googlesource.com/toolchain/XXX/ with optional commit date (no branches or tags), apply patches, and build them.
Note: as of 2015-07, the upcoming Android version moved to a different build system, and will populate $topdir/toolchain through repo
instead of invoking git in a temporary directory (i.e. ditched download-toolchain-sources.sh
).