Skip to content

Commit

Permalink
[DOCKER] Configurable NDK version support (#14000)
Browse files Browse the repository at this point in the history
Let the Android NDK version configurable as a command line argument
  • Loading branch information
srkreddy1238 authored Feb 27, 2023
1 parent f21a17b commit d9b0a80
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
5 changes: 1 addition & 4 deletions docker/Dockerfile.ci_adreno
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.ci_hexagon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.demo_android
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 36 additions & 7 deletions docker/install/ubuntu_install_androidsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,8 +78,8 @@ done

cat >/install/package-list-minimal.txt <<EOF
build-tools;26.0.3
build-tools;27.0.3
cmake;3.6.4111459
build-tools;${BUILD_TOOLS_VERSION}
cmake;${CMAKE_VERSION}
emulator
extras;android;m2repository
extras;google;auto
Expand All @@ -67,19 +93,22 @@ extras;google;webdriver
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2
platforms;android-26
platforms;android-27
platforms;android-${ANDROID_PLATFORM}
tools
ndk;21.3.6528147
ndk;${ANDROID_NDK_VERSION}
EOF

mkdir /root/.android 2>/dev/null || true
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

0 comments on commit d9b0a80

Please sign in to comment.