ref: ee01b78ddd88a9156d6b926fc932d3cdfc070df9
parent: 4282d29355df3b72372669fe3b745c753dfe1c7d
parent: a3400f4376ce3d94011cc5f4ac87324d909874f3
author: Johann Koenig <[email protected]>
date: Thu Sep 15 15:17:13 EDT 2016
Merge "Documentation for building unit tests for Android"
--- a/build/make/Android.mk
+++ b/build/make/Android.mk
@@ -41,6 +41,25 @@
# Running ndk-build will build libvpx and include it in your project.
#
+# Alternatively, building the examples and unit tests can be accomplished in the
+# following way:
+#
+# Create a standalone toolchain from the NDK:
+# https://developer.android.com/ndk/guides/standalone_toolchain.html
+#
+# For example - to test on arm64 devices with clang:
+# $NDK/build/tools/make_standalone_toolchain.py \
+# --arch arm64 --install-dir=/tmp/my-android-toolchain
+# export PATH=/tmp/my-android-toolchain/bin:$PATH
+# CROSS=aarch64-linux-android- CC=clang CXX=clang++ /path/to/libvpx/configure \
+# --target=arm64-android-gcc
+#
+# Push the resulting binaries to a device and run them:
+# adb push test_libvpx /data/tmp/test_libvpx
+# adb shell /data/tmp/test_libvpx --gtest_filter=\*Sixtap\*
+#
+# Make sure to push the test data as well and set LIBVPX_TEST_DATA
+
CONFIG_DIR := $(LOCAL_PATH)/
LIBVPX_PATH := $(LOCAL_PATH)/libvpx
ASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -978,48 +978,51 @@
;;
android*)
- if [ -z "${sdk_path}" ]; then
- die "Must specify --sdk-path for Android builds."
- fi
+ if [ -n "${sdk_path}" ]; then
+ SDK_PATH=${sdk_path}
+ COMPILER_LOCATION=`find "${SDK_PATH}" \
+ -name "arm-linux-androideabi-gcc*" -print -quit`
+ TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
+ CC=${TOOLCHAIN_PATH}gcc
+ CXX=${TOOLCHAIN_PATH}g++
+ AR=${TOOLCHAIN_PATH}ar
+ LD=${TOOLCHAIN_PATH}gcc
+ AS=${TOOLCHAIN_PATH}as
+ STRIP=${TOOLCHAIN_PATH}strip
+ NM=${TOOLCHAIN_PATH}nm
- SDK_PATH=${sdk_path}
- COMPILER_LOCATION=`find "${SDK_PATH}" \
- -name "arm-linux-androideabi-gcc*" -print -quit`
- TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
- CC=${TOOLCHAIN_PATH}gcc
- CXX=${TOOLCHAIN_PATH}g++
- AR=${TOOLCHAIN_PATH}ar
- LD=${TOOLCHAIN_PATH}gcc
- AS=${TOOLCHAIN_PATH}as
- STRIP=${TOOLCHAIN_PATH}strip
- NM=${TOOLCHAIN_PATH}nm
-
- if [ -z "${alt_libc}" ]; then
- alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
- awk '{n = split($0,a,"/"); \
+ if [ -z "${alt_libc}" ]; then
+ alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
+ awk '{n = split($0,a,"/"); \
split(a[n-1],b,"-"); \
print $0 " " b[2]}' | \
sort -g -k 2 | \
awk '{ print $1 }' | tail -1`
- fi
+ fi
- if [ -d "${alt_libc}" ]; then
- add_cflags "--sysroot=${alt_libc}"
- add_ldflags "--sysroot=${alt_libc}"
- fi
+ if [ -d "${alt_libc}" ]; then
+ add_cflags "--sysroot=${alt_libc}"
+ add_ldflags "--sysroot=${alt_libc}"
+ fi
- # linker flag that routes around a CPU bug in some
- # Cortex-A8 implementations (NDK Dev Guide)
- add_ldflags "-Wl,--fix-cortex-a8"
+ # linker flag that routes around a CPU bug in some
+ # Cortex-A8 implementations (NDK Dev Guide)
+ add_ldflags "-Wl,--fix-cortex-a8"
- enable_feature pic
- soft_enable realtime_only
- if [ ${tgt_isa} = "armv7" ]; then
- soft_enable runtime_cpu_detect
+ enable_feature pic
+ soft_enable realtime_only
+ if [ ${tgt_isa} = "armv7" ]; then
+ soft_enable runtime_cpu_detect
+ fi
+ if enabled runtime_cpu_detect; then
+ add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
+ fi
+ else
+ echo "Assuming standalone build with NDK toolchain."
+ echo "See build/make/Android.mk for details."
+ check_add_ldflags -static
+ soft_enable unit_tests
fi
- if enabled runtime_cpu_detect; then
- add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
- fi
;;
darwin*)
@@ -1392,6 +1395,7 @@
*-win*-vs*)
;;
*-android-gcc)
+ # bionic includes basic pthread functionality, obviating -lpthread.
;;
*)
check_header pthread.h && add_extralibs -lpthread
--- a/configure
+++ b/configure
@@ -97,6 +97,7 @@
# all_platforms is a list of all supported target platforms. Maintain
# alphabetically by architecture, generic-gnu last.
+all_platforms="${all_platforms} arm64-android-gcc"
all_platforms="${all_platforms} arm64-darwin-gcc"
all_platforms="${all_platforms} arm64-linux-gcc"
all_platforms="${all_platforms} armv7-android-gcc" #neon Cortex-A8