add Android NDK param to CI docker build script (#18782)
authorJiakai Liu <liujiakai@fb.com>
Wed, 3 Apr 2019 17:42:30 +0000 (10:42 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 3 Apr 2019 19:47:20 +0000 (12:47 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18782
ghimport-source-id: 6c4bde7dc835b59209c1d5f7b243f00c9fe99de2

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18782 [pytorch] add Android NDK param to CI docker build script**

Inspired by discussion: https://github.com/pytorch/pytorch/pull/16242

Reviewed By: dreiss

Differential Revision: D14739471

fbshipit-source-id: 0a081045186cbf359eb3cdadee722741cd8cd62f

docker/caffe2/jenkins/build.sh
docker/caffe2/jenkins/common/install_android.sh
docker/caffe2/jenkins/ubuntu/Dockerfile

index 9c7fa48..8c2ed69 100755 (executable)
@@ -58,6 +58,10 @@ if [[ "$image" == *-android-* ]]; then
   # The Android NDK requires CMake 3.6 or higher.
   # See https://github.com/caffe2/caffe2/pull/1740 for more info.
   CMAKE_VERSION=3.6.3
+
+  if [[ "$image" == *-ndk-* ]]; then
+    ANDROID_NDK_VERSION="$(echo "${image}" | perl -n -e'/-ndk-([^-]+)/ && print $1')"
+  fi
 fi
 
 if [[ "$image" == *-gcc* ]]; then
@@ -98,6 +102,7 @@ docker build \
        --build-arg "CUDNN_VERSION=${CUDNN_VERSION}" \
        --build-arg "MKL=${MKL}" \
        --build-arg "ANDROID=${ANDROID}" \
+       --build-arg "ANDROID_NDK=${ANDROID_NDK_VERSION}" \
        --build-arg "GCC_VERSION=${GCC_VERSION}" \
        --build-arg "CLANG_VERSION=${CLANG_VERSION}" \
        --build-arg "CMAKE_VERSION=${CMAKE_VERSION:-}" \
index 431a7ca..7ebf0f5 100755 (executable)
@@ -2,13 +2,15 @@
 
 set -ex
 
+[ -n "${ANDROID_NDK}" ] || ANDROID_NDK=r13b
+
 apt-get update
 apt-get install -y --no-install-recommends autotools-dev autoconf unzip
 apt-get autoclean && apt-get clean
 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
 pushd /tmp
-curl -Os https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip
+curl -Os https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK}-linux-x86_64.zip
 popd
 _ndk_dir=/opt/ndk
 mkdir -p "$_ndk_dir"
index 843cb1b..8c33197 100644 (file)
@@ -31,6 +31,7 @@ RUN rm install_mkl.sh
 
 # (optional) Install Android NDK
 ARG ANDROID
+ARG ANDROID_NDK
 ADD ./install_android.sh install_android.sh
 RUN if [ -n "${ANDROID}" ]; then bash ./install_android.sh; fi
 RUN rm install_android.sh