2011-09-25 04:57:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# android shell
|
|
|
|
|
2012-09-02 23:27:52 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
NDK_ARCH="$1"
|
|
|
|
shift
|
|
|
|
fi
|
2015-01-24 22:17:55 +00:00
|
|
|
export ANDROID=1
|
2019-08-01 02:39:40 +00:00
|
|
|
ARCH=${NDK_ARCH}
|
2012-09-02 23:27:52 +00:00
|
|
|
case "${NDK_ARCH}" in
|
2014-11-11 00:26:05 +00:00
|
|
|
mips64)
|
2015-04-12 23:16:01 +00:00
|
|
|
export NDK_ARCH
|
2014-11-11 00:26:05 +00:00
|
|
|
AR=mips64el-linux-android-ar
|
|
|
|
RANLIB=mips64el-linux-android-ranlib
|
|
|
|
;;
|
|
|
|
mips)
|
2015-04-12 23:16:01 +00:00
|
|
|
export NDK_ARCH
|
2014-11-11 00:26:05 +00:00
|
|
|
AR=mipsel-linux-android-ar
|
|
|
|
RANLIB=mipsel-linux-android-ranlib
|
|
|
|
;;
|
2019-05-14 13:02:13 +00:00
|
|
|
x64)
|
|
|
|
NDK_ARCH=x86_64
|
|
|
|
export NDK_ARCH
|
|
|
|
;;
|
|
|
|
x86|x86_64)
|
2012-09-02 23:27:52 +00:00
|
|
|
export NDK_ARCH
|
|
|
|
;;
|
2018-10-20 00:10:03 +00:00
|
|
|
aarch64|arm64)
|
2019-08-01 02:39:40 +00:00
|
|
|
NDK_ARCH=aarch64
|
2014-11-10 00:09:38 +00:00
|
|
|
export NDK_ARCH
|
|
|
|
AR=aarch64-linux-android-ar
|
2019-08-01 02:39:40 +00:00
|
|
|
ARCH=arm64
|
2014-11-10 00:09:38 +00:00
|
|
|
RANLIB=aarch64-linux-android-ranlib
|
|
|
|
;;
|
|
|
|
arm)
|
|
|
|
export NDK_ARCH
|
|
|
|
AR=arm-linux-androideabi-ar
|
|
|
|
RANLIB=arm-linux-androideabi-ranlib
|
|
|
|
;;
|
2015-01-24 22:17:55 +00:00
|
|
|
local)
|
|
|
|
export ANDROID=1
|
|
|
|
;;
|
2012-09-02 23:27:52 +00:00
|
|
|
*)
|
2019-05-14 13:02:13 +00:00
|
|
|
echo "Usage: $0 [arm64|arm|mips|mips64|x86|x64]"
|
2012-09-02 23:27:52 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-03-30 11:33:38 +00:00
|
|
|
LANG=C
|
|
|
|
export LANG
|
2017-04-18 09:25:26 +00:00
|
|
|
ROOT=`dirname $0`
|
2011-09-25 19:07:34 +00:00
|
|
|
OS=`uname|tr 'A-Z' 'a-z'`
|
2012-03-31 01:54:44 +00:00
|
|
|
[ "${OS}" = macosx ] && OS=darwin
|
2011-09-25 04:57:13 +00:00
|
|
|
|
2017-03-10 00:12:23 +00:00
|
|
|
if [ ! -x /work ]; then
|
2017-03-09 11:09:26 +00:00
|
|
|
echo "Building android locally with NDK instead of dockcross..."
|
|
|
|
# TODO: autodetect or gtfo
|
|
|
|
if [ -f ~/.r2androidrc ]; then
|
|
|
|
. ~/.r2androidrc
|
|
|
|
echo "Using data from ${HOME}/.r2androidrc.."
|
|
|
|
else
|
|
|
|
#[ -z "${SDK}" ] && SDK="${HOME}/Downloads/android-sdk-${OS}"
|
2017-11-09 12:11:25 +00:00
|
|
|
if [ -z "${NDK}" ]; then
|
|
|
|
# Checking if Android NDK is installed with macOS's brew
|
|
|
|
D=/usr/local/Caskroom/android-ndk/
|
|
|
|
if [ -d "${D}" ]; then
|
|
|
|
for a in $(cd "$D" && ls) ; do
|
|
|
|
N="$D/$a/android-ndk-r$a"
|
|
|
|
if [ -f "$N/README.md" ]; then
|
|
|
|
NDK="$N"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
2017-03-09 11:09:26 +00:00
|
|
|
if [ -z "${NDK}" ]; then
|
|
|
|
if [ "`uname`" = "Darwin" ]; then
|
|
|
|
NDK="${HOME}/Library/Android/sdk/ndk-bundle/"
|
|
|
|
else
|
2021-01-25 10:34:08 +00:00
|
|
|
NDK="${HOME}/Downloads/android-ndk-r21d"
|
2017-03-09 11:09:26 +00:00
|
|
|
fi
|
2016-06-22 00:27:32 +00:00
|
|
|
fi
|
2021-01-25 10:34:08 +00:00
|
|
|
[ -z "${NDK}" ] && NDK="${HOME}/Downloads/android-ndk-r21d"
|
2016-06-22 00:27:32 +00:00
|
|
|
fi
|
2017-03-10 00:12:23 +00:00
|
|
|
fi
|
2017-03-09 11:09:26 +00:00
|
|
|
|
2017-04-18 09:25:26 +00:00
|
|
|
echo ROOT=$ROOT
|
2021-01-25 10:34:08 +00:00
|
|
|
echo NDK="$NDK"
|
2017-04-18 09:25:26 +00:00
|
|
|
echo NDK_ARCH=$NDK_ARCH
|
2011-09-25 04:57:13 +00:00
|
|
|
|
2021-01-25 10:34:08 +00:00
|
|
|
if [ -x /tmp/ndk/bin/ndk-gcc ]; then
|
|
|
|
echo "NDK toolchain already initialized."
|
|
|
|
else
|
|
|
|
echo "Building the standalone NDK toolchain..."
|
|
|
|
${NDK}/build/tools/make_standalone_toolchain.py --arch=${ARCH} --install-dir=/tmp/ndk/ --api=28 --force
|
|
|
|
(
|
|
|
|
cd /tmp/ndk/bin/ && \
|
|
|
|
ln -fs clang ndk-gcc && \
|
|
|
|
ln -fs clang++ ndk-g++
|
|
|
|
)
|
|
|
|
fi
|
2017-01-23 01:15:17 +00:00
|
|
|
if [ "${BUILD}" != 0 ]; then
|
|
|
|
if [ ! -d "${NDK}" ]; then
|
2017-01-31 21:13:32 +00:00
|
|
|
echo "Cannot find Android NDK ${NDK}" >&2
|
|
|
|
echo "echo NDK=/path/to/ndk > ~/.r2androidrc" >&2
|
2017-01-23 01:15:17 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-01-25 10:34:08 +00:00
|
|
|
PATH="/tmp/ndk/bin:$PATH"
|
2017-03-09 11:09:26 +00:00
|
|
|
export PATH
|
|
|
|
export CFLAGS
|
|
|
|
export NDK
|
|
|
|
export NDK_ARCH
|
|
|
|
[ -z "${SHELL}" ] && SHELL=sh
|
|
|
|
SHELL=sh
|
|
|
|
CC=ndk-gcc
|
2018-04-10 22:22:46 +00:00
|
|
|
CXX=ndk-g++
|
2017-03-09 11:09:26 +00:00
|
|
|
PS1="[r2-android-${NDK_ARCH}]> "
|
|
|
|
export CC
|
2018-04-10 22:22:46 +00:00
|
|
|
export CXX
|
2017-03-09 11:09:26 +00:00
|
|
|
export PS1
|
|
|
|
export AR
|
|
|
|
export RANLIB
|
|
|
|
A=$@
|
|
|
|
if [ -n "$A" ]; then
|
2018-10-20 00:10:03 +00:00
|
|
|
${SHELL} -c "$A"
|
2017-03-09 11:09:26 +00:00
|
|
|
else
|
2018-10-20 00:10:03 +00:00
|
|
|
${SHELL}
|
2017-03-09 11:09:26 +00:00
|
|
|
fi
|
2012-09-02 23:27:52 +00:00
|
|
|
fi
|