From d5b7e92cab3f08f898da5bdb3f576dc9e3a166b3 Mon Sep 17 00:00:00 2001 From: Liu Yiqun Date: Wed, 10 May 2017 10:53:46 +0800 Subject: [PATCH] Add dockerfile and build script for Android. --- Dockerfile.android | 43 ++++++++++++++++++++++++++ paddle/scripts/docker/build_android.sh | 25 +++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Dockerfile.android create mode 100644 paddle/scripts/docker/build_android.sh diff --git a/Dockerfile.android b/Dockerfile.android new file mode 100644 index 00000000000..9df291250dc --- /dev/null +++ b/Dockerfile.android @@ -0,0 +1,43 @@ +FROM ubuntu:16.04 +MAINTAINER PaddlePaddle Authors + +ARG UBUNTU_MIRROR +RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' + +ENV HOME=/root \ + ANDROID_HOME=/opt/android-sdk-linux \ + ANDROID_NDK_HOME=/opt/android-ndk-linux \ + ANDROID_STANDALONE_TOOLCHAIN=/opt/android-toolchain-gcc \ + PATH=${PATH}:${ANDROID_HOME}:${ANDROID_NDK_HOME} + +RUN apt-get update && \ + apt-get install -y git python-dev python-pip python-numpy && \ + apt-get install -y wget curl tar unzip && \ + apt-get install -y gcc g++ locales swig && \ + apt-get clean -y + +RUN pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' && \ + pip install -U wheel sphinx && \ + pip install pre-commit + +# git credential to skip password typing +RUN git config --global credential.helper store + +# Fix locales to en_US.UTF-8 +RUN localedef -i en_US -f UTF-8 en_US.UTF-8 + +RUN curl -sSL https://cmake.org/files/v3.2/cmake-3.2.2.tar.gz | tar -xz && \ + cd cmake-3.2.2 && ./bootstrap && make -j `nproc` && make install && \ + cd .. && rm -rf cmake-3.2.2 + +# Android NDK +RUN mkdir /opt/android-ndk-tmp && \ + cd /opt/android-ndk-tmp && \ + wget -q https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip && \ + unzip -q android-ndk-r14b-linux-x86_64.zip && \ + mv android-ndk-r14b ${ANDROID_NDK_HOME} && \ + ${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-21 --install-dir=${ANDROID_STANDALONE_TOOLCHAIN} && \ + rm -rf /opt/android-ndk-tmp + +CMD ["bash", "paddle/paddle/scripts/docker/build_android.sh"] diff --git a/paddle/scripts/docker/build_android.sh b/paddle/scripts/docker/build_android.sh new file mode 100644 index 00000000000..ab432c8524e --- /dev/null +++ b/paddle/scripts/docker/build_android.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -xe + +mkdir -p /paddle/build +cd /paddle/build +cmake -DCMAKE_SYSTEM_NAME=Android \ + -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_STANDALONE_TOOLCHAIN \ + -DANDROID_ABI=armeabi-v7a \ + -DANDROID_ARM_NEON=ON \ + -DANDROID_ARM_MODE=ON \ + -DHOST_C_COMPILER=/usr/bin/gcc \ + -DHOST_CXX_COMPILER=/usr/bin/g++ \ + -DCMAKE_INSTALL_PREFIX=/paddle/install \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3" \ + -DWITH_C_API=ON \ + -DWITH_SWIG_PY=OFF \ + .. +make -j `nproc` +make install + +export PATH=/paddle/install/bin:/paddle/install/opt/paddle/bin:$PATH +paddle version -- GitLab