Android upstream NDK

This page describes how one can modify the NDK and generate new experimental release packages for it.

Getting the sources

The sources live under the "ndk" and "development/ndk" directories in the Android source tree:

  • "ndk" contains the main build scripts and documentation
  • "development/ndk" contains platform-specific headers and samples

If you have downloaded the full Android source tree through the "repo" tool, you can start directly there. Otherwise, you can just get these two repositories with the following:

git clone git://android.git.kernel.org/platform/ndk.git ndk
git clone git://android.git.kernel.org/platform/development.git development
export NDK=`pwd`/ndk

Building the platforms tree

You need to do that once if you want to use the content of $NDK to build samples, tests or anything else:

$NDK/build/tools/build-platforms.sh

What the script does is populate the $NDK/platforms and $NDK/samples directories from the content of development/ndk.

What is under development/ndk is segregated by API level. This makes it easier to add a new platform to the tree, but is not well-suited to building stuff. The build-platforms.sh script will gather all files appropriately and place the result inside $NDK/platforms and $NDK/samples.

Note: These directories are listed by $NDK/.gitignore, so they won't appear on your git status. You can remove them if you want by running:

$NDK/build/tools/dev-cleanup.sh

which also removes all intermediate files and directories from $NDK.

Prebuilt binaries

The NDK requires several prebuilt binary executables to work properly, these include the following:

  • toolchain binaries for the cross-compiler and associated tools
  • gdbserver binaries required for native debugging

Build NDK from source

Build command:

./build/tools/rebuild-all-prebuilt.sh --sysroot=../out/target/product/passion --binutils-version=2.20.1 --gdb-version=7.1.x

reference output:

Forcing generation of Linux binaries with legacy toolchain
Checking whether the compiler generates 32-bit binaries...yes
To follow build in another terminal, please use: tail -F /tmp/ndk-toolchain/build-PM2vgB/log.txt
Download sources from android.git.kernel.org
Using git clone prefix: git://android.git.kernel.org/toolchain
downloading sources for toolchain/binutils
Using sources for date '2011-02-22': toolchain/binutils revision a4316ba2b7698435a68e9826cabd87ae43dad182
downloading sources for toolchain/build
Using sources for date '2011-02-22': toolchain/build revision d8249bbe6bfac8c7d819d08601da20eaf9cf6403
downloading sources for toolchain/gcc
Using sources for date '2011-02-22': toolchain/gcc revision 80934e7f7db429984fb56756a4cc893ba412b7b5
downloading sources for toolchain/gdb
Using sources for date '2011-02-22': toolchain/gdb revision 3954a66c7a6939e2c7bed362ec4df06b9f921bcf
downloading sources for toolchain/gmp
Using sources for date '2011-02-22': toolchain/gmp revision 9fb242a79dd122d7fbf867daf5620dba6927bd2e
downloading sources for toolchain/gold
Using sources for date '2011-02-22': toolchain/gold revision 8d401cf711539af5a2f78d12447341d774892618
downloading sources for toolchain/mpfr
Using sources for date '2011-02-22': toolchain/mpfr revision da6dfde986af1b56f0f41e9f5de61d093fa8af90
Patching toolchain sources
Toolchain sources downloaded and copied to /tmp/ndk-toolchain/build-PM2vgB/src
Cleaning up...
Done.

Platform/Android/UpstreamNDK (last modified 2011-03-11 19:16:13)