commit | 83a84bfbfbeab7ba9fb12ee2b89eb97cf06b53ef | [log] [tgz] |
---|---|---|
author | Dan Albert <danalbert@google.com> | Tue Mar 13 14:21:19 2018 -0700 |
committer | Dan Albert <danalbert@google.com> | Tue Apr 03 22:09:50 2018 -0700 |
tree | d6e04f8ef920a00383e9b6df761006b44f58ba08 | |
parent | 34f9624f94559fb90385c52cdffc9a69e71b7ff5 [diff] |
Add support for dependencies to checkbuild.py. A need for this has come up a few times and thus far we've worked around the issue with prebuilts or other solutions. * We build libc++ and friends against prebuilts/ndk. * We build some vulkan components as a separate build that uses toolchain/prebuilts/ndk and then consume the artifacts in checkbuild.py. * New versions of gdbserver require an STL, which we haven't yet upgraded to because we'd need more prebuilts. * Modules that need to copy components from other modules have to redo the build themselves rather than just copy from the other module. We don't have any examples of this yet, but it is needed for the upcoming merged Clang toolchain (i.e. prebuilt standalone toolchain), where the Toolchain module needs to copy in binutils, clang, sysroot, etc. This commit will be followed with one that refactors the libc++ build to make use of this. Test: ./checkbuild.py Test: ./checkbuild.py gdbserver Test: nose2 ndk.test_deps Bug: None Change-Id: Ie813dfbf5ea130dbe48f239fecb7462e22121b25
The latest version of this document is available at https://android.googlesource.com/platform/ndk/+/master/README.md.
Note: This document is for developers of the NDK, not developers that use the NDK.
The NDK allows Android application developers to include native code in their Android application packages, compiled as JNI shared libraries.
Both Linux and Windows NDKs are built on Linux machines. Windows host binaries are cross-compiled with MinGW.
Building the NDK for Mac OS X requires at least 10.8.
The NDK components can be loosely grouped into host toolchains, target prebuilts, build systems, and support libraries.
toolchains/
contains GCC and Clang toolchains.$TOOLCHAIN/config.mk
contains ARCH and ABIS this toolchain can handle.$TOOLCHAIN/setup.mk
contains toolchain-specific default CFLAGS/LDFLAGS when this toolchain is used.prebuilt/$HOST_TAG
contains build dependencies and additional tools.ndk-depends
, ndk-stack
and ndk-gdb
can also be found here.sysroot/usr/include
contains the headers for the NDK. See Unified Headers for more information.platforms/android-$VERSION/arch-$ARCH_NAME/
contains stub shared libraries and a few static libraries for each API level. See Platform APIs for more information.sources/cxx-stl/$STL
contains the headers and libraries for the various C++ STLs.prebuilt/android-$ARCH/gdbserver
contains gdbserver.build/
contains ndk-build, the NDK's home grown build system. Most of the implementation lives in build/core
.build/cmake
contains components for using the NDK with CMake (at present only a CMake toolchain file, but in the future it will contain CMake modules that CMake will load, obviating the need for a toolchain file).build/tools
contains make_standalone_toolchain.py
, but also contains legacy sripts that were used to build the NDK. Eventually, this should contain nothing but the standalone toolchain scripts.sources/android
and sources/third_party
contain modules that can be used in apps (gtest, cpufeatures, native_app_glue, etc) via $(call import-module,$MODULE)
.Check out the branch master-ndk
repo init -u https://android.googlesource.com/platform/manifest \ -b master-ndk # Googlers, use repo init -u \ persistent-https://android.git.corp.google.com/platform/manifest \ -b master-ndk
Linux dependencies are listed in the Dockerfile. You can use docker to build the NDK:
docker build -t ndk-dev infra/docker docker run -it -u $UID -v `realpath ..`:/src -w /src/ndk ndk-dev ./checkbuild.py
Building on Mac OS X has similar dependencies as Linux, but also requires Xcode.
Running tests requires that adb
is in your PATH
. This is provided as part of the Android SDK.
$ python checkbuild.py
$ python checkbuild.py --system windows # Or windows64.
checkbuild.py
will also build all of the NDK tests. This takes about four times as long as building the NDK itself, so pass --no-build-tests
to skip building the tests. They can be built later with python run_tests.py --rebuild
.
checkbuild.py
also accepts a variety of other options to speed up local builds, namely --arch
and --module
.
By default, checkbuild.py
will also package the NDK. To skip the packaging step, use the --no-package
flag. To avoid packaging an incomplete NDK, packaging will not be run if --module
was passed unless --force-package
was also provided.