-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate-ndk-standalone.sh
46 lines (37 loc) · 1.19 KB
/
create-ndk-standalone.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
set -eu
if [ -d NDK ]; then
printf '\033[33;1mStandalone NDK already exists... Delete the NDK folder to make a new one.\033[0m\n\n'
printf ' $ rm -rf NDK\n'
exit 0
fi
if [ ! -d "${ANDROID_SDK_ROOT-}" ]; then
ANDROID_SDK_ROOT=/usr/local/share/android-sdk
fi
if [ ! -d "${ANDROID_HOME-}" ]; then
ANDROID_HOME="$ANDROID_SDK_ROOT"
fi
if [ ! -d "${ANDROID_NDK_HOME-}" ]; then
ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"
fi
MAKER="${ANDROID_NDK_HOME}/build/tools/make_standalone_toolchain.py"
if [ -x "$MAKER" ]; then
echo 'Creating standalone NDK...'
else
printf '\033[91;1mPlease install Android NDK!\033[0m\n\n'
printf ' $ sdkmanager ndk-bundle\n\n'
printf "\033[33;1mnote\033[0m: file \033[34;4m$MAKER\033[0m not found.\n"
printf 'If you have installed the NDK in non-standard location, please define the \033[1m$ANDROID_NDK_HOME\033[0m variable.\n'
exit 1
fi
mkdir NDK
create_ndk() {
echo "($1)..."
"$MAKER" --api "$2" --arch "$1" --install-dir "NDK/$1"
}
create_ndk arm64 21
create_ndk arm 21
create_ndk x86 21
create_ndk x86_64 21
echo 'Updating cargo-config.toml...'
sed 's|$PWD|'"${PWD}"'|g' cargo-config.toml.template > cargo-config.toml