From d9b0a80e1b97fae695d54eec6627c6b7fe840d3b Mon Sep 17 00:00:00 2001 From: Siva Date: Mon, 27 Feb 2023 09:36:27 +0530 Subject: [PATCH] [DOCKER] Configurable NDK version support (#14000) Let the Android NDK version configurable as a command line argument --- docker/Dockerfile.ci_adreno | 5 +-- docker/Dockerfile.ci_cpu | 3 -- docker/Dockerfile.ci_hexagon | 2 - docker/Dockerfile.demo_android | 2 - docker/install/ubuntu_install_androidsdk.sh | 43 +++++++++++++++++---- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/docker/Dockerfile.ci_adreno b/docker/Dockerfile.ci_adreno index 8f4ede3a5ed3..11be0a8baac7 100644 --- a/docker/Dockerfile.ci_adreno +++ b/docker/Dockerfile.ci_adreno @@ -22,10 +22,7 @@ COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear # Android SDK COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh -RUN bash /install/ubuntu_install_androidsdk.sh -ENV ANDROID_HOME=/opt/android-sdk-linux -ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147 -ENV ANDROID_NDK_MAJOR=21 +RUN bash /install/ubuntu_install_androidsdk.sh 25.2.9519653 3.22.1 33.0.2 33 ENV PATH /opt/android-sdk-linux/platform-tools:$PATH # Clang tool for CLML source codegen diff --git a/docker/Dockerfile.ci_cpu b/docker/Dockerfile.ci_cpu index 74e90670ab23..c75bf3136121 100644 --- a/docker/Dockerfile.ci_cpu +++ b/docker/Dockerfile.ci_cpu @@ -128,9 +128,6 @@ RUN bash /install/ubuntu_install_vitis_ai_packages_ci.sh # Android SDK COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh RUN bash /install/ubuntu_install_androidsdk.sh -ENV ANDROID_HOME=/opt/android-sdk-linux/ -ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147/ -ENV ANDROID_NDK_MAJOR=21 # PaddlePaddle deps COPY install/ubuntu_install_paddle.sh /install/ubuntu_install_paddle.sh diff --git a/docker/Dockerfile.ci_hexagon b/docker/Dockerfile.ci_hexagon index bf4e33fc7c18..3b4c58ef43c9 100644 --- a/docker/Dockerfile.ci_hexagon +++ b/docker/Dockerfile.ci_hexagon @@ -62,8 +62,6 @@ RUN bash /install/ubuntu_install_java.sh COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh RUN bash /install/ubuntu_install_androidsdk.sh ENV ANDROID_HOME=/opt/android-sdk-linux -ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147 -ENV ANDROID_NDK_MAJOR=21 ENV PATH /opt/android-sdk-linux/platform-tools:$PATH # Hexagon diff --git a/docker/Dockerfile.demo_android b/docker/Dockerfile.demo_android index ebfacabb4e67..42bf705106e6 100644 --- a/docker/Dockerfile.demo_android +++ b/docker/Dockerfile.demo_android @@ -81,5 +81,3 @@ RUN cd /usr && \ # Environment variables ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/vta/python:${PYTHONPATH} ENV ANDROID_HOME=/opt/android-sdk-linux/ -ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147/ -ENV ANDROID_NDK_MAJOR=21 diff --git a/docker/install/ubuntu_install_androidsdk.sh b/docker/install/ubuntu_install_androidsdk.sh index bf2d80cd28ba..5e7278c5d631 100755 --- a/docker/install/ubuntu_install_androidsdk.sh +++ b/docker/install/ubuntu_install_androidsdk.sh @@ -26,6 +26,32 @@ ASDKTOOLS_HOME=/opt/android-sdk-tools ASDKTOOLS_VERSION=3859397 ASDKTOOLS_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +ANDROID_NDK_VERSION=21.3.6528147 +CMAKE_VERSION=3.6.4111459 +BUILD_TOOLS_VERSION=27.0.3 +ANDROID_PLATFORM=27 +ANDROID_NDK_MAJOR=21 + +if [ $# -gt 0 ] ; then + ANDROID_NDK_VERSION=$1 + ANDROID_NDK_MAJOR=`echo $1 | cut -d "." -f1` +fi +if [ $# -gt 1 ] ; then + CMAKE_VERSION=$2 +fi +if [ $# -gt 2 ] ; then + BUILD_TOOLS_VERSION=$3 +fi +if [ $# -gt 3 ] ; then + ANDROID_PLATFORM=$4 +fi + +echo "NDK Version: ${ANDROID_NDK_VERSION}" +echo "NDK Major : ${ANDROID_NDK_MAJOR}" +echo "Cmake Version: ${CMAKE_VERSION}" +echo "Build Tools: ${BUILD_TOOLS_VERSION}" +echo "Android Platform: ${ANDROID_PLATFORM}" + wget -q http://dl.google.com/android/repository/sdk-tools-linux-${ASDKTOOLS_VERSION}.zip -O sdk-tools-linux.zip echo "${ASDKTOOLS_SHA256} *sdk-tools-linux.zip" | sha256sum --check - unzip sdk-tools-linux.zip @@ -52,8 +78,8 @@ done cat >/install/package-list-minimal.txt </dev/null || true @@ -77,9 +103,12 @@ touch /root/.android/repositories.cfg # NOTE: sdkmanager returns exit code 141 (yes || true) | sdkmanager --licenses --sdk_root="$ANDROID_HOME" || true sdkmanager --verbose --package_file=/install/package-list-minimal.txt --sdk_root="$ANDROID_HOME" -test -d "${ANDROID_HOME}/build-tools/27.0.3" -test -d "${ANDROID_HOME}/ndk/21.3.6528147" -for f in ${ANDROID_HOME}/ndk/21.3.6528147/* ; do +test -d "${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}" +test -d "${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}" +for f in ${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/* ; do ln --symbolic "$f" "/usr/bin/`basename $f`" done echo "export ANDROID_HOME=${ANDROID_HOME}" >> /etc/profile +echo "export ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/${ANDROID_NDK_VERSION}/" >> /etc/profile +echo "export ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION}" >> /etc/profile +echo "export ANDROID_NDK_MAJOR=${ANDROID_NDK_MAJOR}" >> /etc/profile