From 89f57beacf57c8c874a9d63fd7705b96af303725 Mon Sep 17 00:00:00 2001 From: xiebaiyuan Date: Sun, 26 Apr 2020 14:57:09 +0700 Subject: [PATCH] add direct build script (#3497) * add test for imfix ,test=develop * fix group like 3x3,test=develop * add direct release build script, test=develop --- mobile/tools/build_android_armv7.sh | 78 +++++++++++++++++++++++++++++ mobile/tools/build_android_armv8.sh | 78 +++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100755 mobile/tools/build_android_armv7.sh create mode 100755 mobile/tools/build_android_armv8.sh diff --git a/mobile/tools/build_android_armv7.sh b/mobile/tools/build_android_armv7.sh new file mode 100755 index 0000000000..9466aa300e --- /dev/null +++ b/mobile/tools/build_android_armv7.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# merge cl to so +merge_cl_to_so=1 +opencl_kernels="opencl_kernels.cpp" +cd ../src/operators/kernel/cl +if [[ -f "${opencl_kernels}" ]]; then + rm "${opencl_kernels}" +fi +python gen_code.py "${merge_cl_to_so}" >"${opencl_kernels}" +cd - + +# get cl headers +opencl_header_dir="../third_party/opencl/OpenCL-Headers" +commit_id="320d7189b3e0e7b6a8fc5c10334c79ef364b5ef6" +if [[ -d "$opencl_header_dir" && -d "$opencl_header_dir/.git" ]]; then + echo "pulling opencl headers" + cd $opencl_header_dir + git stash + git pull + git checkout $commit_id + cd - +else + echo "cloning opencl headers" + rm -rf $opencl_header_dir + git clone https://github.com/KhronosGroup/OpenCL-Headers $opencl_header_dir + git checkout $commit_id +fi + +build_for_android() { + # rm -rf "../build" + if [ -z "${NDK_ROOT}" ]; then + echo "NDK_ROOT not found!" + exit -1 + fi + + if [ -z "$PLATFORM" ]; then + PLATFORM="arm-v7a" # Users could choose "arm-v8a" platform. + # PLATFORM="arm-v8a" + fi + + if [ "${PLATFORM}" = "arm-v7a" ]; then + ABI="armeabi-v7a with NEON" + ARM_PLATFORM="V7" + CXX_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -pie -fPIE -w -Wno-error=format-security" + elif [ "${PLATFORM}" = "arm-v8a" ]; then + ABI="arm64-v8a" + ARM_PLATFORM="V8" + CXX_FLAGS="-march=armv8-a -pie -fPIE -w -Wno-error=format-security -llog -fuse-ld=gold" + else + echo "unknown platform!" + exit -1 + fi + + MODE="Release" + ANDROID_PLATFORM_VERSION="android-19" + TOOLCHAIN_FILE="./tools/android-cmake/android.toolchain.cmake" + ANDROID_ARM_MODE="arm" + + cmake .. \ + -B"../buildreleasev7/${PLATFORM}" \ + -DANDROID_ABI="${ABI}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -DANDROID_STL=c++_static \ + -DANDROID=true \ + -DWITH_LOGGING=OFF \ + -DWITH_PROFILE=OFF \ + -DWITH_TEST=OFF \ + -D"${ARM_PLATFORM}"=true + + cd "../buildreleasev7/${PLATFORM}" + make -j 8 +} + +build_for_android diff --git a/mobile/tools/build_android_armv8.sh b/mobile/tools/build_android_armv8.sh new file mode 100755 index 0000000000..3517227eaa --- /dev/null +++ b/mobile/tools/build_android_armv8.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# merge cl to so +merge_cl_to_so=1 +opencl_kernels="opencl_kernels.cpp" +cd ../src/operators/kernel/cl +if [[ -f "${opencl_kernels}" ]]; then + rm "${opencl_kernels}" +fi +python gen_code.py "${merge_cl_to_so}" >"${opencl_kernels}" +cd - + +# get cl headers +opencl_header_dir="../third_party/opencl/OpenCL-Headers" +commit_id="320d7189b3e0e7b6a8fc5c10334c79ef364b5ef6" +if [[ -d "$opencl_header_dir" && -d "$opencl_header_dir/.git" ]]; then + echo "pulling opencl headers" + cd $opencl_header_dir + git stash + git pull + git checkout $commit_id + cd - +else + echo "cloning opencl headers" + rm -rf $opencl_header_dir + git clone https://github.com/KhronosGroup/OpenCL-Headers $opencl_header_dir + git checkout $commit_id +fi + +build_for_android() { + # rm -rf "../build" + if [ -z "${NDK_ROOT}" ]; then + echo "NDK_ROOT not found!" + exit -1 + fi + + if [ -z "$PLATFORM" ]; then + # PLATFORM="arm-v7a" # Users could choose "arm-v8a" platform. + PLATFORM="arm-v8a" + fi + + if [ "${PLATFORM}" = "arm-v7a" ]; then + ABI="armeabi-v7a with NEON" + ARM_PLATFORM="V7" + CXX_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -pie -fPIE -w -Wno-error=format-security" + elif [ "${PLATFORM}" = "arm-v8a" ]; then + ABI="arm64-v8a" + ARM_PLATFORM="V8" + CXX_FLAGS="-march=armv8-a -pie -fPIE -w -Wno-error=format-security -llog -fuse-ld=gold" + else + echo "unknown platform!" + exit -1 + fi + + MODE="Release" + ANDROID_PLATFORM_VERSION="android-19" + TOOLCHAIN_FILE="./tools/android-cmake/android.toolchain.cmake" + ANDROID_ARM_MODE="arm" + + cmake .. \ + -B"../buildreleasev8/${PLATFORM}" \ + -DANDROID_ABI="${ABI}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -DANDROID_STL=c++_static \ + -DANDROID=true \ + -DWITH_LOGGING=OFF \ + -DWITH_PROFILE=OFF \ + -DWITH_TEST=OFF \ + -D"${ARM_PLATFORM}"=true + + cd "../buildreleasev8/${PLATFORM}" + make -j 8 +} + +build_for_android -- GitLab