build_android.sh 1.7 KB
Newer Older
1 2 3 4
#!/bin/bash

set -xe

5 6
BUILD_ROOT=/paddle/build_android
DEST_ROOT=/paddle/install
7

8 9 10 11
rm -rf $BUILD_ROOT 2>/dev/null || true
mkdir -p $BUILD_ROOT
cd $BUILD_ROOT

12 13 14 15 16 17 18 19
if [ $ANDROID_ABI == "armeabi-v7a" ]; then
  cmake -DCMAKE_SYSTEM_NAME=Android \
        -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_ARM_STANDALONE_TOOLCHAIN \
        -DANDROID_ABI=$ANDROID_ABI \
        -DANDROID_ARM_NEON=ON \
        -DANDROID_ARM_MODE=ON \
        -DHOST_C_COMPILER=/usr/bin/gcc \
        -DHOST_CXX_COMPILER=/usr/bin/g++ \
20
        -DCMAKE_INSTALL_PREFIX=$DEST_ROOT \
21
        -DCMAKE_BUILD_TYPE=Release \
22
        -DUSE_EIGEN_FOR_BLAS=ON \
23 24
        -DWITH_C_API=ON \
        -DWITH_SWIG_PY=OFF \
25 26 27
        -DWITH_STYLE_CHECK=OFF \
        ..
elif [ $ANDROID_ABI == "arm64-v8a" ]; then
28 29 30 31 32 33
  cmake -DCMAKE_SYSTEM_NAME=Android \
        -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_ARM64_STANDALONE_TOOLCHAIN \
        -DANDROID_ABI=$ANDROID_ABI \
        -DANDROID_ARM_MODE=ON \
        -DHOST_C_COMPILER=/usr/bin/gcc \
        -DHOST_CXX_COMPILER=/usr/bin/g++ \
34
        -DCMAKE_INSTALL_PREFIX=$DEST_ROOT \
35
        -DCMAKE_BUILD_TYPE=Release \
36
        -DUSE_EIGEN_FOR_BLAS=OFF \
37 38
        -DWITH_C_API=ON \
        -DWITH_SWIG_PY=OFF \
39
        ..
40 41 42 43 44 45 46 47 48 49 50
elif [ $ANDROID_ABI == "armeabi" ]; then
  cmake -DCMAKE_SYSTEM_NAME=Android \
        -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_ARM_STANDALONE_TOOLCHAIN \
        -DANDROID_ABI=$ANDROID_ABI \
        -DANDROID_ARM_MODE=ON \
        -DHOST_C_COMPILER=/usr/bin/gcc \
        -DHOST_CXX_COMPILER=/usr/bin/g++ \
        -DCMAKE_INSTALL_PREFIX=/paddle/install \
        -DCMAKE_BUILD_TYPE=Release \
        -DWITH_C_API=ON \
        -DWITH_SWIG_PY=OFF \
51
        ..
52 53 54 55
else
  echo "Invalid ANDROID_ABI: $ANDROID_ABI"
fi

56 57
make VERBOSE=1 -j2
make install -j2