mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-27 11:50:29 +00:00
Update install-ndk.sh
This commit is contained in:
parent
bdd1975934
commit
5f14a73bb1
@ -16,15 +16,13 @@
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
|
||||
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
|
||||
echo "NDK root is ${ANDROID_NDK_ROOT}"
|
||||
echo "ERROR: ANDROID_NDK_ROOT is not set. Please set it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
|
||||
echo "ERROR: ANDROID_SDK_ROOT is not a valid path. Please set it."
|
||||
echo "SDK root is ${ANDROID_SDK_ROOT}"
|
||||
echo "ERROR: ANDROID_SDK_ROOT is not set. Please set it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -35,29 +35,31 @@
|
||||
# Mac: https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
|
||||
# Windows: https://dl.google.com/android/repository/platform-tools-latest-windows.zip
|
||||
|
||||
if [ -z "$ANDROID_SDK_ROOT" ]; then
|
||||
if [ -z "${ANDROID_SDK_ROOT}" ]; then
|
||||
echo "ERROR: ANDROID_SDK_ROOT is not set. Please set it."
|
||||
echo "SDK root is $ANDROID_SDK_ROOT"
|
||||
echo "SDK root is ${ANDROID_SDK_ROOT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
if [ -z "${ANDROID_NDK_ROOT}" ]; then
|
||||
echo "ERROR: ANDROID_NDK_ROOT is not set. Please set it."
|
||||
echo "NDK root is $ANDROID_NDK_ROOT"
|
||||
echo "NDK root is ${ANDROID_NDK_ROOT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IS_DARWIN=$(uname -s 2>/dev/null | grep -i -c darwin)
|
||||
IS_LINUX=$(uname -s 2>/dev/null | grep -i -c linux)
|
||||
|
||||
# Change NDK_NAME as required
|
||||
NDK_NAME=android-ndk-r20b
|
||||
NDK_TOP=$(dirname "${ANDROID_NDK_ROOT}")
|
||||
|
||||
# Keep this in sync with the move at the end.
|
||||
if [ "$IS_LINUX" -eq 1 ]; then
|
||||
NDK_NAME=android-ndk-r20b
|
||||
NDK_URL=https://dl.google.com/android/repository/${NDK_NAME}-linux-x86_64.zip
|
||||
SDK_URL=https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
|
||||
TOOLS_URL=https://dl.google.com/android/repository/platform-tools-latest-linux.zip
|
||||
elif [ "$IS_DARWIN" -eq 1 ]; then
|
||||
NDK_NAME=android-ndk-r20b
|
||||
NDK_URL=https://dl.google.com/android/repository/${NDK_NAME}-darwin-x86_64.zip
|
||||
SDK_URL=https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
|
||||
TOOLS_URL=https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
|
||||
@ -72,68 +74,68 @@ if [ -n "$(command -v apt-get)" ]; then
|
||||
fi
|
||||
|
||||
echo "Downloading SDK"
|
||||
if ! curl -L -s -o android-sdk.zip "$SDK_URL";
|
||||
if ! curl -L -s -o android-sdk.zip "${SDK_URL}";
|
||||
then
|
||||
echo "Failed to download SDK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading NDK"
|
||||
if ! curl -L -s -o android-ndk.zip "$NDK_URL";
|
||||
if ! curl -L -s -o android-ndk.zip "${NDK_URL}";
|
||||
then
|
||||
echo "Failed to download NDK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading Platform Tools"
|
||||
if ! curl -L -s -o platform-tools.zip "$TOOLS_URL";
|
||||
if ! curl -L -s -o platform-tools.zip "${TOOLS_URL}";
|
||||
then
|
||||
echo "Failed to download Platform Tools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Unpacking SDK to $ANDROID_SDK_ROOT"
|
||||
if ! unzip -u -qq android-sdk.zip -d "$ANDROID_SDK_ROOT";
|
||||
echo "Unpacking SDK to ${ANDROID_SDK_ROOT}"
|
||||
if ! unzip -u -qq android-sdk.zip -d "${ANDROID_SDK_ROOT}";
|
||||
then
|
||||
echo "Failed to unpack SDK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Unpacking NDK to $ANDROID_NDK_ROOT"
|
||||
echo "Unpacking NDK to ${ANDROID_NDK_ROOT}"
|
||||
if ! unzip -u -qq android-ndk.zip -d "$HOME";
|
||||
then
|
||||
echo "Failed to unpack NDK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Unpacking Platform Tools to $ANDROID_SDK_ROOT"
|
||||
if ! unzip -u -qq platform-tools.zip -d "$ANDROID_SDK_ROOT";
|
||||
echo "Unpacking Platform Tools to ${ANDROID_SDK_ROOT}"
|
||||
if ! unzip -u -qq platform-tools.zip -d "${ANDROID_SDK_ROOT}";
|
||||
then
|
||||
echo "Failed to unpack Platform Tools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unlink as needed
|
||||
if [[ -d "$ANDROID_NDK_ROOT" ]];then
|
||||
ls_output=$(ls -l "$ANDROID_NDK_ROOT" 2>/dev/null | head -n 1)
|
||||
if [[ -d "${ANDROID_NDK_ROOT}" ]];then
|
||||
ls_output=$(ls -l "${ANDROID_NDK_ROOT}" 2>/dev/null | head -n 1)
|
||||
if [[ ${ls_output:0:1} == "l" ]]; then
|
||||
unlink "$ANDROID_NDK_ROOT"
|
||||
unlink "${ANDROID_NDK_ROOT}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove an old directory
|
||||
rm -rf "$(dirname "$ANDROID_NDK_ROOT")/${NDK_NAME}"
|
||||
rm -rf "${NDK_TOP})/${NDK_NAME}"
|
||||
|
||||
# Place the new directory. mv should be faster on the same partition.
|
||||
if ! mv "$HOME/${NDK_NAME}" $(dirname "$ANDROID_NDK_ROOT");
|
||||
if ! mv "$HOME/${NDK_NAME}" ${NDK_TOP});
|
||||
then
|
||||
echo "Failed to move $HOME/${NDK_NAME} to $(dirname "$ANDROID_NDK_ROOT")"
|
||||
echo "Failed to move $HOME/${NDK_NAME} to ${NDK_TOP})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run in a subshell
|
||||
(
|
||||
cd $(dirname "$ANDROID_NDK_ROOT")
|
||||
cd ${NDK_TOP})
|
||||
ln -s ${NDK_NAME} android-ndk
|
||||
)
|
||||
|
||||
@ -143,7 +145,7 @@ rm -f platform-tools.zip
|
||||
|
||||
# We don't set ANDROID_HOME to ANDROID_SDK_ROOT.
|
||||
# https://stackoverflow.com/a/47028911/608639
|
||||
touch "$ANDROID_SDK_ROOT/repositories.cfg"
|
||||
touch "${ANDROID_SDK_ROOT}/repositories.cfg"
|
||||
|
||||
echo "Finished preparing SDK and NDK"
|
||||
|
||||
|
@ -69,15 +69,15 @@ unset ANDROID_SYSROOT
|
||||
# ANDROID_NDK_ROOT=/opt/android-ndk-r19c or ANDROID_NDK_ROOT=/usr/local/android-ndk-r20.
|
||||
|
||||
if [ -n "${ANDROID_NDK_ROOT}" ]; then
|
||||
echo "ANDROID_NDK_ROOT is $ANDROID_NDK_ROOT"
|
||||
echo "ANDROID_NDK_ROOT is ${ANDROID_NDK_ROOT"
|
||||
else
|
||||
echo "ANDROID_NDK_ROOT is empty. Searching for the NDK"
|
||||
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
|
||||
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
if [ -z "${ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
|
||||
fi
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
if [ -z "${ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_NDK_ROOT=$(find "$HOME" -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
|
||||
fi
|
||||
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
|
||||
@ -86,9 +86,9 @@ else
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_NDK_ROOT" ]; then
|
||||
if [ ! -d "${ANDROID_NDK_ROOT" ]; then
|
||||
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
|
||||
echo "Root is $ANDROID_NDK_ROOT"
|
||||
echo "Root is ${ANDROID_NDK_ROOT"
|
||||
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
@ -106,8 +106,8 @@ else
|
||||
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/bin"
|
||||
ANDROID_SYSROOT="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/sysroot"
|
||||
ANDROID_TOOLCHAIN="${ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/bin"
|
||||
ANDROID_SYSROOT="${ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/sysroot"
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
|
||||
@ -244,18 +244,18 @@ fi
|
||||
# need to copy cpu-features.h and cpu-features.c from the NDK into our source
|
||||
# directory and then build it.
|
||||
|
||||
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" ]]; then
|
||||
if [[ ! -e "${ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" ]]; then
|
||||
echo "ERROR: Unable to locate cpu-features.h"
|
||||
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" ]]; then
|
||||
if [[ ! -e "${ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" ]]; then
|
||||
echo "ERROR: Unable to locate cpu-features.c"
|
||||
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" .
|
||||
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" .
|
||||
cp "${ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" .
|
||||
cp "${ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" .
|
||||
|
||||
# Cleanup the sources for the C++ compiler
|
||||
# https://github.com/weidai11/cryptopp/issues/926
|
||||
|
Loading…
Reference in New Issue
Block a user