diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh new file mode 100755 index 000000000..208a4f9ef --- /dev/null +++ b/scripts/android/build_all.sh @@ -0,0 +1,8 @@ +# /bin/bash + +./build_iconv.sh +./build_boost.sh +./build_openssl.sh +./build_sodium.sh +./build_zmq.sh +./build_monero.sh diff --git a/scripts/android/build_boost.sh b/scripts/android/build_boost.sh new file mode 100755 index 000000000..2da334703 --- /dev/null +++ b/scripts/android/build_boost.sh @@ -0,0 +1,16 @@ +# /bin/bash + +WORKDIR=/opt/android +TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain +ORIGINAL_PATH=$PATH + +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 + +done diff --git a/scripts/android/build_iconv.sh b/scripts/android/build_iconv.sh new file mode 100755 index 000000000..9c0350a01 --- /dev/null +++ b/scripts/android/build_iconv.sh @@ -0,0 +1,38 @@ +# /bin/bash + +export WORKDIR=/opt/android +export ICONV_FILENAME=libiconv-1.15.tar.gz +export ICONV_FILE_PATH=$WORKDIR/$ICONV_FILENAME +export ICONV_SRC_DIR=$WORKDIR/libiconv-1.15 + +wget http://ftp.gnu.org/pub/gnu/libiconv/$ICONV_FILENAME -O $ICONV_FILE_PATH + +ORIGINAL_PATH=$PATH +TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain + +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=${arch}-linux-android-clang + CXXLANG=${arch}-linux-android-clang++ + HOST="${arch}-linux-android";; +esac + +cd $WORKDIR +rm -rf $ICONV_SRC_DIR +tar -xzf $ICONV_FILE_PATH -C $WORKDIR +cd $ICONV_SRC_DIR +CC=${CLANG} CXX=${CXXLANG} ./configure --build=x86_64-linux-gnu --host=${HOST} --prefix=${PREFIX} --disable-rpath +make +make install + +done diff --git a/scripts/android/build_monero.sh b/scripts/android/build_monero.sh new file mode 100755 index 000000000..c2db7c085 --- /dev/null +++ b/scripts/android/build_monero.sh @@ -0,0 +1,70 @@ +# /bin/bash + +WORKDIR=/opt/android +TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain +ORIGINAL_PATH=$PATH +MONERO_BRANCH=v0.17.1.9-android +MONERO_SRC_DIR=${WORKDIR}/monero + +git clone https://github.com/cake-tech/monero.git ${MONERO_SRC_DIR} --branch ${MONERO_BRANCH} +cd $MONERO_SRC_DIR +git submodule init +git submodule update + +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" +export CMAKE_LIBRARY_PATH="${PREFIX}/lib" + +mkdir -p $DEST_LIB_DIR +mkdir -p $DEST_INCLUDE_DIR + +case $arch in + "aarch" ) + CLANG=arm-linux-androideabi-clang + CXXLANG=arm-linux-androideabi-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++ + BUILD_64=ON + TAG="android-armv8" + ARCH="armv8-a" + ARCH_ABI="arm64-v8a";; + "i686" ) + CLANG=i686-linux-androideabi-clang + CXXLANG=i686-linux-androideabi-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++ + BUILD_64=ON + TAG="android-x86_64" + ARCH="x86-64" + ARCH_ABI="x86_64";; +esac + +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 ../.. +make wallet_api -j4 +find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \; + +cp -r ./lib/* $DEST_LIB_DIR +cp ../../src/wallet/api/wallet2_api.h $DEST_INCLUDE_DIR +done diff --git a/scripts/android/build_openssl.sh b/scripts/android/build_openssl.sh new file mode 100755 index 000000000..3674612b0 --- /dev/null +++ b/scripts/android/build_openssl.sh @@ -0,0 +1,44 @@ +# /bin/bash + +WORKDIR=/opt/android +OPENSSL_FILENAME=openssl-1.0.2p.tar.gz +OPENSSL_FILE_PATH=$WORKDIR/$OPENSSL_FILENAME +OPENSSL_SRC_DIR=$WORKDIR/openssl-1.0.2p +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 + +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 + +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}";; +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 +make install + + +done + + diff --git a/scripts/android/build_sodium.sh b/scripts/android/build_sodium.sh new file mode 100755 index 000000000..e13541924 --- /dev/null +++ b/scripts/android/build_sodium.sh @@ -0,0 +1,31 @@ +# /bin/bash + +WORKDIR=/opt/android +TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain +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}" + +case $arch in + "aarch" ) TARGET="arm";; + "i686" ) TARGET="x86";; + * ) TARGET="${arch}";; +esac + +HOST="${TARGET}-linux-android" +cd $WORKDIR +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 +make +make install + +done diff --git a/scripts/android/build_zmq.sh b/scripts/android/build_zmq.sh new file mode 100755 index 000000000..c161e6044 --- /dev/null +++ b/scripts/android/build_zmq.sh @@ -0,0 +1,34 @@ +# /bin/bash + +WORKDIR=/opt/android +TOOLCHAIN_BASE_DIR=${WORKDIR}/toolchain +ZMQ_SRC_DIR=$WORKDIR/libzmq +ZMQ_BRANCH=master +ZMQ_COMMIT_HASH=501d0815bf2b0abb93be8214fc66519918ef6c40 +ORIGINAL_PATH=$PATH + + +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}";; +esac + +HOST="${TARGET}-linux-android" +cd $WORKDIR +rm -rf $ZMQ_SRC_DIR +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 +make +make install + +done diff --git a/scripts/android/copy_monero_deps.sh b/scripts/android/copy_monero_deps.sh new file mode 100755 index 000000000..dc5e53fec --- /dev/null +++ b/scripts/android/copy_monero_deps.sh @@ -0,0 +1,34 @@ +# /bin/bash + +WORKDIR=/opt/android +CW_DIR=${WORKDIR}/cake_wallet +CW_EXRTERNAL_DIR=${CW_DIR}/cw_monero/ios/External/android + +for arch in "aarch" "aarch64" "i686" "x86_64" +do + +PREFIX=${WORKDIR}/prefix_${arch} +ABI="" + +case $arch in + "aarch" ) + ABI="armeabi-v7a";; + "aarch64" ) + ABI="arm64-v8a";; + "i686" ) + ABI="x86";; + "x86_64" ) + ABI="x86_64";; +esac + +LIB_DIR=${CW_EXRTERNAL_DIR}/${ABI}/lib +INCLUDE_DIR=${CW_EXRTERNAL_DIR}/${ABI}/include + +mkdir -p $LIB_DIR +mkdir -p $INCLUDE_DIR + +cp -r ${PREFIX}/lib/* $LIB_DIR +cp -r ${PREFIX}/include/* $INCLUDE_DIR + + +done diff --git a/scripts/android/finish_boost.sh b/scripts/android/finish_boost.sh new file mode 100755 index 000000000..0016b3152 --- /dev/null +++ b/scripts/android/finish_boost.sh @@ -0,0 +1,9 @@ +# /bin/bash + +WORKDIR=/opt/android +ARCH=$1 +PREFIX="${WORKDIR}/prefix_${ARCH}" +BOOST_SRC_DIR=$WORKDIR/boost_1_68_0 + +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 diff --git a/scripts/android/init_boost.sh b/scripts/android/init_boost.sh new file mode 100755 index 000000000..ac2527b17 --- /dev/null +++ b/scripts/android/init_boost.sh @@ -0,0 +1,18 @@ +# /bin/bash + +WORKDIR=/opt/android +ARCH=$1 +PREFIX="${WORKDIR}/prefix_${ARCH}" +BOOST_FILENAME=boost_1_68_0.tar.bz2 +BOOST_FILE_PATH=$WORKDIR/$BOOST_FILENAME +BOOST_SRC_DIR=$WORKDIR/boost_1_68_0 + +if [ ! -e "$BOOST_FILE_PATH" ]; then + wget https://dl.bintray.com/boostorg/release/1.68.0/source/$BOOST_FILENAME -O $BOOST_FILE_PATH +fi + +cd $WORKDIR +rm -rf $BOOST_SRC_DIR +tar -xvf $BOOST_FILE_PATH -C $WORKDIR +cd $BOOST_SRC_DIR +./bootstrap.sh --prefix=${PREFIX} diff --git a/scripts/android/install_ndk.sh b/scripts/android/install_ndk.sh new file mode 100755 index 000000000..619bdc118 --- /dev/null +++ b/scripts/android/install_ndk.sh @@ -0,0 +1,17 @@ +# /bin/bash + +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 + +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++