Update android build scripts.

This commit is contained in:
M 2021-12-29 22:12:54 +02:00
parent dd784a7829
commit e5e525edae
8 changed files with 50 additions and 84 deletions

View file

@ -9,7 +9,7 @@ for arch in "aarch" "aarch64" "i686" "x86_64"
do do
PREFIX=$WORKDIR/prefix_${arch} PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
./init_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_FILENAME $BOOST_VERSION ./init_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_FILENAME $BOOST_VERSION
./finish_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_SRC_DIR ./finish_boost.sh $arch $PREFIX $BOOST_SRC_DIR $BOOST_SRC_DIR

View file

@ -13,15 +13,16 @@ for arch in aarch aarch64 i686 x86_64
do do
PREFIX=${WORKDIR}/prefix_${arch} PREFIX=${WORKDIR}/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in case $arch in
"aarch" ) "aarch" )
CLANG=armv7a-linux-androideabi${API}-clang CLANG=armv7a-linux-androideabi-clang
CXXLANG=armv7a-linux-androideabi${API}-clang++ CXXLANG=arm-linux-androideabi-clang++
HOST="arm";; HOST="arm-linux-android";;
* ) * )
CLANG=${arch}-linux-android${API}-clang CLANG=${arch}-linux-android-clang
CXXLANG=${arch}-linux-android${API}-clang++ CXXLANG=${arch}-linux-android-clang++
HOST="${arch}-linux-android";; HOST="${arch}-linux-android";;
esac esac

View file

@ -3,7 +3,6 @@
. ./config.sh . ./config.sh
MONERO_BRANCH=v0.17.2.3-android MONERO_BRANCH=v0.17.2.3-android
MONERO_SRC_DIR=${WORKDIR}/monero 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} git clone https://github.com/cake-tech/monero.git ${MONERO_SRC_DIR} --branch ${MONERO_BRANCH}
cd $MONERO_SRC_DIR cd $MONERO_SRC_DIR
@ -18,36 +17,38 @@ DEST_LIB_DIR=${PREFIX}/lib/monero
DEST_INCLUDE_DIR=${PREFIX}/include DEST_INCLUDE_DIR=${PREFIX}/include
export CMAKE_INCLUDE_PATH="${PREFIX}/include" export CMAKE_INCLUDE_PATH="${PREFIX}/include"
export CMAKE_LIBRARY_PATH="${PREFIX}/lib" export CMAKE_LIBRARY_PATH="${PREFIX}/lib"
ANDROID_STANDALONE_TOOLCHAIN_PATH="${TOOLCHAIN_BASE_DIR}_${arch}"
PATH="${ANDROID_STANDALONE_TOOLCHAIN_PATH}/bin:${ORIGINAL_PATH}"
mkdir -p $DEST_LIB_DIR mkdir -p $DEST_LIB_DIR
mkdir -p $DEST_INCLUDE_DIR mkdir -p $DEST_INCLUDE_DIR
case $arch in case $arch in
"aarch" ) "aarch" )
ANDROID_CLANG=armv7a-linux-androideabi${API}-clang CLANG=arm-linux-androideabi-clang
ANDROID_CLANGPP=armv7a-linux-androideabi${API}-clang++ CXXLANG=arm-linux-androideabi-clang++
BUILD_64=OFF BUILD_64=OFF
TAG="android-armv7" TAG="android-armv7"
ARCH="armv7-a" ARCH="armv7-a"
ARCH_ABI="armeabi-v7a" ARCH_ABI="armeabi-v7a"
FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";; FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";;
"aarch64" ) "aarch64" )
ANDROID_CLANG=aarch64-linux-androideabi${API}-clang CLANG=aarch64-linux-androideabi-clang
ANDROID_CLANGPP=aarch64-linux-androideabi${API}-clang++ CXXLANG=aarch64-linux-androideabi-clang++
BUILD_64=ON BUILD_64=ON
TAG="android-armv8" TAG="android-armv8"
ARCH="armv8-a" ARCH="armv8-a"
ARCH_ABI="arm64-v8a";; ARCH_ABI="arm64-v8a";;
"i686" ) "i686" )
ANDROID_CLANG=i686-linux-androideabi${API}-clang CLANG=i686-linux-androideabi-clang
ANDROID_CLANGPP=i686-linux-androideabi${API}-clang++ CXXLANG=i686-linux-androideabi-clang++
BUILD_64=OFF BUILD_64=OFF
TAG="android-x86" TAG="android-x86"
ARCH="i686" ARCH="i686"
ARCH_ABI="x86";; ARCH_ABI="x86";;
"x86_64" ) "x86_64" )
ANDROID_CLANG=x86_64-linux-androideabi${API}-clang CLANG=x86_64-linux-androideabi-clang
ANDROID_CLANGPP=x86_64-linux-androideabi${API}-clang++ CXXLANG=x86_64-linux-androideabi-clang++
BUILD_64=ON BUILD_64=ON
TAG="android-x86_64" TAG="android-x86_64"
ARCH="x86-64" ARCH="x86-64"
@ -58,24 +59,7 @@ cd $MONERO_SRC_DIR
rm -rf ./build/release rm -rf ./build/release
mkdir -p ./build/release mkdir -p ./build/release
cd ./build/release cd ./build/release
cmake \ 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 ../..
-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 make wallet_api -j4
find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \; find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \;

View file

@ -24,37 +24,31 @@ echo $OPENSSL_SHA256 $OPENSSL_FILE_PATH | sha256sum -c - || exit 1
for arch in "aarch" "aarch64" "i686" "x86_64" for arch in "aarch" "aarch64" "i686" "x86_64"
do do
PREFIX=$WORKDIR/prefix_${arch} PREFIX=$WORKDIR/prefix_${arch}
TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64
PATH="${TOOLCHAIN}/bin:${ORIGINAL_PATH}"
case $arch in case $arch in
"aarch") CLANG=armv7a-linux-androideabi${API}-clang "aarch") X_ARCH="android-arm";;
CXXLANG=armv7a-linux-androideabi${API}-clang++ "aarch64") X_ARCH="android-arm64";;
X_ARCH="android-arm";; "i686") X_ARCH="android-x86";;
"aarch64") CLANG=${arch}-linux-android${API}-clang "x86_64") X_ARCH="android-x86_64";;
CXXLANG=${arch}-linux-android${API}-clang++ *) X_ARCH="android-${arch}";;
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 esac
cd $WORKDIR cd $WORKDIR
rm -rf $OPENSSL_SRC_DIR rm -rf $OPENSSL_SRC_DIR
tar -xzf $OPENSSL_FILE_PATH -C $WORKDIR tar -xzf $OPENSSL_FILE_PATH -C $WORKDIR
cd $OPENSSL_SRC_DIR cd $OPENSSL_SRC_DIR
./Configure CC=${CLANG} CXX=${CXXLANG} ${X_ARCH} \
no-asm no-shared --static \ sed -i -e "s/mandroid/target\ ${TARGET}\-linux\-android/" Configure
CC=clang ANDROID_NDK=$TOOLCHAIN \
./Configure ${X_ARCH} \
no-asm no-shared \
--with-zlib-include=${PREFIX}/include \ --with-zlib-include=${PREFIX}/include \
--with-zlib-lib=${PREFIX}/lib \ --with-zlib-lib=${PREFIX}/lib \
--prefix=${PREFIX} \ --prefix=${PREFIX} \
--openssldir=${PREFIX} \ --openssldir=${PREFIX} \
-D__ANDROID_API__=$API -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 -j4
make install make install

View file

@ -8,18 +8,13 @@ for arch in "aarch" "aarch64" "i686" "x86_64"
do do
PREFIX=${WORKDIR}/prefix_${arch} PREFIX=${WORKDIR}/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in case $arch in
"aarch" ) TARGET="arm" "aarch" ) TARGET="arm";;
CC=armv7a-linux-androideabi${API}-clang "i686" ) TARGET="x86";;
CXX=armv7a-linux-androideabi${API}-clang++;; * ) TARGET="${arch}";;
"i686" ) TARGET="x86" esac
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" HOST="${TARGET}-linux-android"
cd $WORKDIR cd $WORKDIR
@ -27,7 +22,7 @@ rm -rf $SODIUM_SRC_DIR
git clone https://github.com/jedisct1/libsodium.git $SODIUM_SRC_DIR -b $SODIUM_BRANCH git clone https://github.com/jedisct1/libsodium.git $SODIUM_SRC_DIR -b $SODIUM_BRANCH
cd $SODIUM_SRC_DIR cd $SODIUM_SRC_DIR
./autogen.sh ./autogen.sh
./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared CC=clang CXX=clang++ ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
make make
make install make install

View file

@ -9,17 +9,12 @@ for arch in "aarch" "aarch64" "i686" "x86_64"
do do
PREFIX=$WORKDIR/prefix_${arch} PREFIX=$WORKDIR/prefix_${arch}
PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}"
case $arch in case $arch in
"aarch" ) TARGET="arm" "aarch" ) TARGET="arm";;
ANDROID_CLANG=armv7a-linux-androideabi${API}-clang "i686" ) TARGET="x86";;
ANDROID_CLANGPP=armv7a-linux-androideabi${API}-clang++;; * ) TARGET="${arch}";;
"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 esac
@ -30,7 +25,7 @@ git clone https://github.com/zeromq/libzmq.git ${ZMQ_SRC_DIR} -b ${ZMQ_BRANCH}
cd $ZMQ_SRC_DIR cd $ZMQ_SRC_DIR
git checkout ${ZMQ_COMMIT_HASH} git checkout ${ZMQ_COMMIT_HASH}
./autogen.sh ./autogen.sh
CC=${ANDROID_CLANG} CXX=${ANDROID_CLANGPP} ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared CC=clang CXX=clang++ ./configure --prefix=${PREFIX} --host=${HOST} --enable-static --disable-shared
make make
make install make install

View file

@ -2,12 +2,9 @@
export API=21 export API=21
export WORKDIR=/opt/android export WORKDIR=/opt/android
export ANDROID_NDK_ZIP=${WORKDIR}/android-ndk-r20b.zip export ANDROID_NDK_ZIP=${WORKDIR}/android-ndk-r17c.zip
export ANDROID_NDK_ROOT=${WORKDIR}/android-ndk-r20b export ANDROID_NDK_ROOT=${WORKDIR}/android-ndk-r17c
export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT
export TOOLCHAIN_DIR="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64" export TOOLCHAIN_DIR="${WORKDIR}/toolchain"
export TOOLCHAIN_BASE_DIR=$TOOLCHAIN_DIR
case :${PATH:=${TOOLCHAIN_DIR}/bin}: in export ORIGINAL_PATH=$PATH
(*:"${TOOLCHAIN_DIR}/bin":*) ;; (*)
export PATH=${TOOLCHAIN_DIR}/bin:$PATH
esac;

View file

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
. ./config.sh . ./config.sh
ANDROID_NDK_SHA256="8381c440fe61fcbb01e209211ac01b519cd6adf51ab1c2281d5daad6ca4c8c8c" ANDROID_NDK_SHA256="3f541adbd0330a9205ba12697f6d04ec90752c53d6b622101a2a8a856e816589"
curl https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip -o ${ANDROID_NDK_ZIP} curl https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip -o ${ANDROID_NDK_ZIP}
echo $ANDROID_NDK_SHA256 $ANDROID_NDK_ZIP | sha256sum -c || exit 1 echo $ANDROID_NDK_SHA256 $ANDROID_NDK_ZIP | sha256sum -c || exit 1
unzip /opt/android/android-ndk-r20b.zip -d $WORKDIR unzip /opt/android/android-ndk-r17c.zip -d $WORKDIR