aboutsummaryrefslogtreecommitdiff
path: root/scripts/android-armv7-build.sh
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@gmail.com>2018-03-18 13:11:26 -0700
committerMarat Dukhan <maratek@gmail.com>2018-03-18 13:11:26 -0700
commit32e42ef120f10f169953bca565ab441071a8e15a (patch)
tree93e21f0e8645617a01e9909b16d5cabf8fdae919 /scripts/android-armv7-build.sh
parentbfc32f50caa979719c7e0388bd039f3582bd6e03 (diff)
downloadcpuinfo-32e42ef120f10f169953bca565ab441071a8e15a.tar.gz
Switch build and test scripts to CMake
Diffstat (limited to 'scripts/android-armv7-build.sh')
-rwxr-xr-xscripts/android-armv7-build.sh58
1 files changed, 52 insertions, 6 deletions
diff --git a/scripts/android-armv7-build.sh b/scripts/android-armv7-build.sh
index 094e9eb..0d7ed06 100755
--- a/scripts/android-armv7-build.sh
+++ b/scripts/android-armv7-build.sh
@@ -2,12 +2,58 @@
set -e
-SYSTEMNAME=`uname`
-if [[ "$SYSTEMNAME" == 'Darwin' ]]
+if [ -z "$ANDROID_NDK" ]
then
- PROCESSORS=`sysctl -n hw.ncpu`
-else
- PROCESSORS=`nproc`
+ echo "ANDROID_NDK not set; please set it to the Android NDK directory"
+ exit 1
fi
-ndk-build APP_ABI=armeabi-v7a -j$PROCESSORS
+if [ ! -d "$ANDROID_NDK" ]
+then
+ echo "ANDROID_NDK not a directory; did you install it under ${ANDROID_NDK}?"
+ exit 1
+fi
+
+mkdir -p build/android/armeabi-v7a
+
+CMAKE_ARGS=()
+
+# CMake-level configuration
+CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake")
+CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release")
+CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+
+# If Ninja is installed, prefer it to Make
+if [ -x "$(command -v ninja)" ]
+then
+ CMAKE_ARGS+=("-GNinja")
+fi
+
+CMAKE_ARGS+=("-DCPUINFO_LIBRARY_TYPE=static")
+# CMakeLists for Google Benchmark is broken on Android
+CMAKE_ARGS+=("-DCPUINFO_BUILD_BENCHMARKS=OFF")
+CMAKE_ARGS+=("-DCPUINFO_BUILD_TOOLS=ON")
+CMAKE_ARGS+=("-DCPUINFO_BUILD_UNIT_TESTS=ON")
+CMAKE_ARGS+=("-DCPUINFO_BUILD_MOCK_TESTS=ON")
+
+# Android-specific options
+CMAKE_ARGS+=("-DANDROID_NDK=$ANDROID_NDK")
+CMAKE_ARGS+=("-DANDROID_ABI=armeabi-v7a")
+CMAKE_ARGS+=("-DANDROID_PLATFORM=android-14")
+CMAKE_ARGS+=("-DANDROID_PIE=ON")
+CMAKE_ARGS+=("-DANDROID_STL=c++_static")
+CMAKE_ARGS+=("-DANDROID_CPP_FEATURES=exceptions")
+
+# Use-specified CMake arguments go last to allow overridding defaults
+CMAKE_ARGS+=($@)
+
+cd build/android/armeabi-v7a && cmake ../../.. \
+ "${CMAKE_ARGS[@]}"
+
+# Cross-platform parallel build
+if [ "$(uname)" == "Darwin" ]
+then
+ cmake --build . -- "-j$(sysctl -n hw.ncpu)"
+else
+ cmake --build . -- "-j$(nproc)"
+fi