Update android build scripts.

This commit is contained in:
M 2021-08-31 12:27:30 +03:00
parent 2a0556720c
commit 9d7e465211
10 changed files with 148 additions and 102 deletions

View file

@ -1,16 +1,16 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
ORIGINAL_PATH=$PATH
. ./config.sh
BOOST_SRC_DIR=$WORKDIR/boost_1_74_0
BOOST_FILENAME=boost_1_74_0.tar.bz2
BOOST_VERSION=1.74.0
for arch in "aarch" "aarch64" "i686" "x86_64"
do
PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
./init_boost.sh $arch
./finish_boost.sh $arch
./init_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_FILENAME $BOOST_VERSION
./finish_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_SRC_DIR
done

View file

@ -1,29 +1,27 @@
# /bin/bash
#!/bin/sh
export WORKDIR=/opt/android
export ICONV_FILENAME=libiconv-1.15.tar.gz
. ./config.sh
export ICONV_FILENAME=libiconv-1.16.tar.gz
export ICONV_FILE_PATH=$WORKDIR/$ICONV_FILENAME
export ICONV_SRC_DIR=$WORKDIR/libiconv-1.15
export ICONV_SRC_DIR=$WORKDIR/libiconv-1.16
ICONV_SHA256="e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04"
wget http://ftp.gnu.org/pub/gnu/libiconv/$ICONV_FILENAME -O $ICONV_FILE_PATH
ORIGINAL_PATH=$PATH
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
curl http://ftp.gnu.org/pub/gnu/libiconv/$ICONV_FILENAME -o $ICONV_FILE_PATH
echo $ICONV_SHA256 $ICONV_FILE_PATH | sha256sum -c - || exit 1
for arch in aarch aarch64 i686 x86_64
do
PREFIX=${WORKDIR}/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in
"aarch" )
CLANG=arm-linux-androideabi-clang
CXXLANG=arm-linux-androideabi-clang++
HOST="arm-linux-android";;
CLANG=armv7a-linux-androideabi${API}-clang
CXXLANG=armv7a-linux-androideabi${API}-clang++
HOST="arm";;
* )
CLANG=${arch}-linux-android-clang
CXXLANG=${arch}-linux-android-clang++
CLANG=${arch}-linux-android${API}-clang
CXXLANG=${arch}-linux-android${API}-clang++
HOST="${arch}-linux-android";;
esac
@ -36,3 +34,4 @@ make
make install
done

View file

@ -1,10 +1,9 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
ORIGINAL_PATH=$PATH
. ./config.sh
MONERO_BRANCH=v0.17.1.9-android
MONERO_SRC_DIR=${WORKDIR}/monero
CMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake"
git clone https://github.com/cake-tech/monero.git ${MONERO_SRC_DIR} --branch ${MONERO_BRANCH}
cd $MONERO_SRC_DIR
@ -15,8 +14,6 @@ for arch in "aarch" "aarch64" "i686" "x86_64"
do
FLAGS=""
PREFIX=${WORKDIR}/prefix_${arch}
ANDROID_STANDALONE_TOOLCHAIN_PATH="${TOOLCHAIN_BASE_DIR}_${arch}"
PATH="${ANDROID_STANDALONE_TOOLCHAIN_PATH}/bin:${ORIGINAL_PATH}"
DEST_LIB_DIR=${PREFIX}/lib/monero
DEST_INCLUDE_DIR=${PREFIX}/include
export CMAKE_INCLUDE_PATH="${PREFIX}/include"
@ -27,30 +24,30 @@ mkdir -p $DEST_INCLUDE_DIR
case $arch in
"aarch" )
CLANG=arm-linux-androideabi-clang
CXXLANG=arm-linux-androideabi-clang++
ANDROID_CLANG=armv7a-linux-androideabi${API}-clang
ANDROID_CLANGPP=armv7a-linux-androideabi${API}-clang++
BUILD_64=OFF
TAG="android-armv7"
ARCH="armv7-a"
ARCH_ABI="armeabi-v7a"
FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";;
"aarch64" )
CLANG=aarch64-linux-androideabi-clang
CXXLANG=aarch64-linux-androideabi-clang++
ANDROID_CLANG=aarch64-linux-androideabi${API}-clang
ANDROID_CLANGPP=aarch64-linux-androideabi${API}-clang++
BUILD_64=ON
TAG="android-armv8"
ARCH="armv8-a"
ARCH_ABI="arm64-v8a";;
"i686" )
CLANG=i686-linux-androideabi-clang
CXXLANG=i686-linux-androideabi-clang++
ANDROID_CLANG=i686-linux-androideabi${API}-clang
ANDROID_CLANGPP=i686-linux-androideabi${API}-clang++
BUILD_64=OFF
TAG="android-x86"
ARCH="i686"
ARCH_ABI="x86";;
"x86_64" )
CLANG=x86_64-linux-androideabi-clang
CXXLANG=x86_64-linux-androideabi-clang++
ANDROID_CLANG=x86_64-linux-androideabi${API}-clang
ANDROID_CLANGPP=x86_64-linux-androideabi${API}-clang++
BUILD_64=ON
TAG="android-x86_64"
ARCH="x86-64"
@ -61,7 +58,25 @@ cd $MONERO_SRC_DIR
rm -rf ./build/release
mkdir -p ./build/release
cd ./build/release
CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} $FLAGS ../..
cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_PREFIX_PATH="${PREFIX}" \
-DCMAKE_FIND_ROOT_PATH="${PREFIX}" \
-DCMAKE_BUILD_TYPE=release \
-DARCH=$ARCH \
-DANDROID=true \
-DANDROID_NATIVE_API_LEVEL=$API \
-DANDROID_ABI=$ARCH_ABI \
-DANDROID_TOOLCHAIN=clang \
-DLRELEASE_PATH="${PREFIX}/bin" \
-DSTATIC=ON \
-DBUILD_64=$BUILD_64 \
-DINSTALL_VENDORED_LIBUNBOUND=ON \
-DUSE_DEVICE_TREZOR=OFF \
-DBUILD_GUI_DEPS=1 \
-DBUILD_TESTS=OFF \
${FLAGS} ../..
make wallet_api -j4
find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \;

View file

@ -1,44 +1,62 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
OPENSSL_FILENAME=openssl-1.0.2p.tar.gz
. ./config.sh
OPENSSL_FILENAME=openssl-1.1.1k.tar.gz
OPENSSL_FILE_PATH=$WORKDIR/$OPENSSL_FILENAME
OPENSSL_SRC_DIR=$WORKDIR/openssl-1.0.2p
OPENSSL_SRC_DIR=$WORKDIR/openssl-1.1.1k
OPENSSL_SHA256="892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5"
ZLIB_FILENAME=zlib-1.2.11.tar.gz
ZLIB_FILE_PATH=$WORKDIR/$ZLIB_FILENAME
ZLIB_SRC_DIR=$WORKDIR/zlib-1.2.11
ORIGINAL_PATH=$PATH
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
ZLIB_SHA256="c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
curl https://zlib.net/$ZLIB_FILENAME -o $ZLIB_FILE_PATH
echo $ZLIB_SHA256 $ZLIB_FILE_PATH | sha256sum -c - || exit 1
wget https://zlib.net/$ZLIB_FILENAME -O $ZLIB_FILE_PATH
tar -xzf $ZLIB_FILE_PATH -C $WORKDIR
cd $ZLIB_SRC_DIR
CC=clang CXX=clang++ ./configure --static
make
wget https://www.openssl.org/source/$OPENSSL_FILENAME -O $OPENSSL_FILE_PATH
curl https://www.openssl.org/source/$OPENSSL_FILENAME -o $OPENSSL_FILE_PATH
echo $OPENSSL_SHA256 $OPENSSL_FILE_PATH | sha256sum -c - || exit 1
for arch in "aarch" "aarch64" "i686" "x86_64"
do
PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in
"aarch" ) TARGET="armv7";;
* ) TARGET="${arch}";;
"aarch") CLANG=armv7a-linux-androideabi${API}-clang
CXXLANG=armv7a-linux-androideabi${API}-clang++
X_ARCH="android-arm";;
"aarch64") CLANG=${arch}-linux-android${API}-clang
CXXLANG=${arch}-linux-android${API}-clang++
X_ARCH="android-arm64";;
"i686") CLANG=${arch}-linux-android${API}-clang
CXXLANG=${arch}-linux-android${API}-clang++
X_ARCH="android-x86";;
"x86_64") CLANG=${arch}-linux-android${API}-clang
CXXLANG=${arch}-linux-android${API}-clang++
X_ARCH="android-x86_64";;
*) CLANG=${arch}-linux-android${API}-clang
CXXLANG=${arch}-linux-android${API}-clang++
X_ARCH="android-${arch}";;
esac
cd $WORKDIR
rm -rf $OPENSSL_SRC_DIR
tar -xzf $OPENSSL_FILE_PATH -C $WORKDIR
cd $OPENSSL_SRC_DIR
sed -i -e "s/mandroid/target\ ${TARGET}\-linux\-android/" Configure
CC=clang CXX=clang++ ./Configure android no-asm no-shared --static --with-zlib-include=${WORKDIR}/zlib --with-zlib-lib=${ZLIB_SRC_DIR} --prefix=${PREFIX} --openssldir=${PREFIX}
make
./Configure CC=${CLANG} CXX=${CXXLANG} ${X_ARCH} \
no-asm no-shared --static \
--with-zlib-include=${PREFIX}/include \
--with-zlib-lib=${PREFIX}/lib \
--prefix=${PREFIX} \
--openssldir=${PREFIX} \
-D__ANDROID_API__=$API
sed -i 's/CNF_EX_LIBS=-ldl -pthread//g;s/BIN_CFLAGS=-pie $(CNF_CFLAGS) $(CFLAGS)//g' Makefile
make -j4
make install
done

View file

@ -1,21 +1,24 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
. ./config.sh
SODIUM_SRC_DIR=${WORKDIR}/libsodium
SODIUM_BRANCH=1.0.16
ORIGINAL_PATH=$PATH
for arch in "aarch" "aarch64" "i686" "x86_64"
do
PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
PREFIX=${WORKDIR}/prefix_${arch}
case $arch in
"aarch" ) TARGET="arm";;
"i686" ) TARGET="x86";;
* ) TARGET="${arch}";;
"aarch" ) TARGET="arm"
CC=armv7a-linux-androideabi${API}-clang
CXX=armv7a-linux-androideabi${API}-clang++;;
"i686" ) TARGET="x86"
CC=${arch}-linux-android${API}-clang
CXX=${arch}-linux-android${API}-clang++;;
* ) TARGET="${arch}"
CC=${arch}-linux-android${API}-clang
CXX=${arch}-linux-android${API}-clang++;;
esac
HOST="${TARGET}-linux-android"
@ -24,8 +27,9 @@ rm -rf $SODIUM_SRC_DIR
git clone https://github.com/jedisct1/libsodium.git $SODIUM_SRC_DIR -b $SODIUM_BRANCH
cd $SODIUM_SRC_DIR
./autogen.sh
CC=clang CXX=clang++ ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
make
make install
done

View file

@ -1,25 +1,28 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain
. ./config.sh
ZMQ_SRC_DIR=$WORKDIR/libzmq
ZMQ_BRANCH=master
ZMQ_COMMIT_HASH=501d0815bf2b0abb93be8214fc66519918ef6c40
ORIGINAL_PATH=$PATH
ZMQ_BRANCH=v4.3.3
ZMQ_COMMIT_HASH=04f5bbedee58c538934374dc45182d8fc5926fa3
for arch in "aarch" "aarch64" "i686" "x86_64"
do
PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in
"aarch" ) TARGET="arm";;
"i686" ) TARGET="x86";;
* ) TARGET="${arch}";;
"aarch" ) TARGET="arm"
ANDROID_CLANG=armv7a-linux-androideabi${API}-clang
ANDROID_CLANGPP=armv7a-linux-androideabi${API}-clang++;;
"i686" ) TARGET="x86"
ANDROID_CLANG=${arch}-linux-android${API}-clang
ANDROID_CLANGPP=${arch}-linux-android${API}-clang++;;
* ) TARGET="${arch}"
ANDROID_CLANG=${arch}-linux-android${API}-clang
ANDROID_CLANGPP=${arch}-linux-android${API}-clang++;;
esac
HOST="${TARGET}-linux-android"
cd $WORKDIR
rm -rf $ZMQ_SRC_DIR
@ -27,7 +30,7 @@ git clone https://github.com/zeromq/libzmq.git ${ZMQ_SRC_DIR} -b ${ZMQ_BRANCH}
cd $ZMQ_SRC_DIR
git checkout ${ZMQ_COMMIT_HASH}
./autogen.sh
CC=clang CXX=clang++ ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
CC=${ANDROID_CLANG} CXX=${ANDROID_CLANGPP} ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
make
make install

13
scripts/android/config.sh Normal file
View file

@ -0,0 +1,13 @@
#!/bin/sh
export API=21
export WORKDIR=/opt/android
export ANDROID_NDK_ZIP=${WORKDIR}/android-ndk-r20b.zip
export ANDROID_NDK_ROOT=${WORKDIR}/android-ndk-r20b
export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT
export TOOLCHAIN_DIR="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64"
case :${PATH:=${TOOLCHAIN_DIR}/bin}: in
(*:"${TOOLCHAIN_DIR}/bin":*) ;; (*)
export PATH=${TOOLCHAIN_DIR}/bin:$PATH
esac;

View file

@ -1,9 +1,9 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
ARCH=$1
PREFIX="${WORKDIR}/prefix_${ARCH}"
BOOST_SRC_DIR=$WORKDIR/boost_1_68_0
PREFIX=$2
BOOST_SRC_DIR=$3
cd $BOOST_SRC_DIR
./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --with-locale --build-dir=android --stagedir=android toolset=clang threading=multi threadapi=pthread target-os=android -sICONV_PATH=${PREFIX} install

View file

@ -1,16 +1,19 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
ARCH=$1
PREFIX="${WORKDIR}/prefix_${ARCH}"
BOOST_FILENAME=boost_1_68_0.tar.bz2
PREFIX=$2
BOOST_SRC_DIR=$3
BOOST_FILENAME=$4
BOOST_VERSION=$5
BOOST_FILE_PATH=$WORKDIR/$BOOST_FILENAME
BOOST_SRC_DIR=$WORKDIR/boost_1_68_0
BOOST_SHA256="83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1"
if [ ! -e "$BOOST_FILE_PATH" ]; then
wget https://dl.bintray.com/boostorg/release/1.68.0/source/$BOOST_FILENAME -O $BOOST_FILE_PATH
curl -L http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/${BOOST_FILENAME} > $BOOST_FILE_PATH
fi
echo $BOOST_SHA256 $BOOST_FILE_PATH | sha256sum -c - || exit 1
cd $WORKDIR
rm -rf $BOOST_SRC_DIR
tar -xvf $BOOST_FILE_PATH -C $WORKDIR

View file

@ -1,17 +1,8 @@
# /bin/bash
#!/bin/sh
WORKDIR=/opt/android
ANDROID_NDK_ZIP=${WORKDIR}/android-ndk-r17c.zip
ANDROID_NDK_ROOT=${WORKDIR}/android-ndk-r17c
TOOLCHAIN_DIR=${WORKDIR}/toolchain
TOOLCHAIN_A32_DIR=${TOOLCHAIN_DIR}_aarch
TOOLCHAIN_A64_DIR=${TOOLCHAIN_DIR}_aarch64
TOOLCHAIN_x86_DIR=${TOOLCHAIN_DIR}_i686
TOOLCHAIN_x86_64_DIR=${TOOLCHAIN_DIR}_x86_64
. ./config.sh
ANDROID_NDK_SHA256="8381c440fe61fcbb01e209211ac01b519cd6adf51ab1c2281d5daad6ca4c8c8c"
wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip -O /opt/android/android-ndk-r17c.zip
unzip /opt/android/android-ndk-r17c.zip -d $WORKDIR
${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch arm64 --api 21 --install-dir ${TOOLCHAIN_A64_DIR} --stl=libc++
${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch arm --api 21 --install-dir ${TOOLCHAIN_A32_DIR} --stl=libc++
${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch x86 --api 21 --install-dir ${TOOLCHAIN_x86_DIR} --stl=libc++
${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch x86_64 --api 21 --install-dir ${TOOLCHAIN_x86_64_DIR} --stl=libc++
curl https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip -o ${ANDROID_NDK_ZIP}
echo $ANDROID_NDK_SHA256 $ANDROID_NDK_ZIP | sha256sum -c || exit 1
unzip /opt/android/android-ndk-r20b.zip -d $WORKDIR