3 # Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Setup Android Cross-Build Environment
21 echo "Usage: $0 [--ndk-version=NDKVersion] [--install-dir=InstallDir]"
22 echo " NDKVersion : r20(default) or higher"
23 echo " InstallDir : Path to be installed"
27 __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
29 __UnprocessedBuildArgs=
33 key="$(echo $1 | awk '{print tolower($0)}')"
44 __NDKVersion="${1#*=}"
51 __InstallDir="${1#*=}"
54 echo "Invalid option '$1'"
62 __InstallDir=${__InstallDir:-"${__CrossDir}/ndk/${__NDKVersion}"}
64 NDK_DIR=android-ndk-${__NDKVersion}
65 NDK_ZIP=${NDK_DIR}-linux-x86_64.zip
67 if [[ -e $__InstallDir ]]; then
68 echo "ERROR: $__InstallDir already exists"
72 echo "Downloading Android NDK ${__NDKVersion}"
73 mkdir -p "$__InstallDir"
75 wget -nv -nc https://dl.google.com/android/repository/$NDK_ZIP -O $__InstallDir/$NDK_ZIP
78 echo "Failed downloading. Please check NDK version and network connection."
82 echo "Unzipping Android NDK"
83 unzip -qq -o $__InstallDir/$NDK_ZIP -d $__InstallDir
84 rm $__InstallDir/$NDK_ZIP
85 mv $__InstallDir/${NDK_DIR} "$__InstallDir/ndk" # This is necessary since Tensorflow Lite does include like `#include "ndk/sources/..."`