From 031c536945776f9953a243d9a37322c17f055e80 Mon Sep 17 00:00:00 2001 From: r4sas Date: Sun, 21 Jul 2024 19:23:54 +0000 Subject: [PATCH] [chore] update i2pd to 2.53.0, change build script Signed-off-by: r4sas --- .gitignore | 1 - app/jni/build_miniupnpc.sh | 2 +- app/jni/i2pd | 2 +- binary/jni/build.sh | 83 ++++++++++++++++++++++++++++++++++ binary/jni/build_debug.sh | 23 ---------- binary/jni/build_release.sh | 20 -------- binary/jni/ndkbuild-wrapper.sh | 16 ------- 7 files changed, 85 insertions(+), 62 deletions(-) create mode 100755 binary/jni/build.sh delete mode 100755 binary/jni/build_debug.sh delete mode 100755 binary/jni/build_release.sh delete mode 100755 binary/jni/ndkbuild-wrapper.sh diff --git a/.gitignore b/.gitignore index 57a0a6c..e79c41e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ obj .externalNativeBuild ant.properties local.properties -build.sh android.iml build *.iml diff --git a/app/jni/build_miniupnpc.sh b/app/jni/build_miniupnpc.sh index c9cb987..42381b4 100755 --- a/app/jni/build_miniupnpc.sh +++ b/app/jni/build_miniupnpc.sh @@ -38,7 +38,7 @@ function checkPreRequisites { fi if [ -z "$ANDROID_HOME" -a "$ANDROID_HOME" == "" ]; then - echo -e "\033[31mFailed! ANDROID_HOME is empty. Run 'export ANDROID_HOME=[PATH_TO_NDK]'\033[0m" + echo -e "\033[31mFailed! ANDROID_HOME is empty. Run 'export ANDROID_HOME=[PATH_TO_SDK]'\033[0m" exit fi diff --git a/app/jni/i2pd b/app/jni/i2pd index 4163542..9a66549 160000 --- a/app/jni/i2pd +++ b/app/jni/i2pd @@ -1 +1 @@ -Subproject commit 4163542125925e0b098d43e1471c86e1bd935cdd +Subproject commit 9a6654943d9b90687fa474ba0ffbf024851d92f2 diff --git a/binary/jni/build.sh b/binary/jni/build.sh new file mode 100755 index 0000000..174c4cd --- /dev/null +++ b/binary/jni/build.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# https://stackoverflow.com/a/246128 +SOURCE="${0}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + +# Checking Android SDK +if [ -z "$ANDROID_HOME" -a "$ANDROID_HOME" == "" ]; then + echo -e "\033[31mFailed! ANDROID_HOME is empty. Run 'export ANDROID_HOME=[PATH_TO_SDK]'\033[0m" + exit +fi + +# Checking Android NDK +if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then + echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m" + exit 1 +fi + +_NDK_OPTS="-j `nproc` NDK_MODULE_PATH=$DIR" + +help() +{ + echo "Syntax: $(basename "$SOURCE") [-m|d|s|h|v]" + echo "Options:" + echo "m Rename binaries as libraries." + echo "d Debug build." + echo "s Strip binaries." + echo "h Print this Help." + echo "v Verbose NDK output." + echo +} + +while getopts ":dmsvh" option; do + case $option in + d) # debug build + _NDK_OPTS="$_NDK_OPTS NDK_DEBUG=1" + ;; + m) # make module + _MODULE=1 + ;; + s) # strip binaries + _STRIP=1 + ;; + v) # verbose output + _NDK_OPTS="$_NDK_OPTS V=1 NDK_LOG=1" + ;; + h) # display help + help + exit;; + \?) # Invalid option + echo "Error: Invalid option. Use $(basename "$SOURCE") -h for help" + exit;; + esac +done + +# Building +echo Building boost... +./build_boost.sh + +echo Building openssl... +./build_openssl.sh + +echo Building miniupnpc... +./build_miniupnpc.sh + +echo Building i2pd... +$ANDROID_NDK_HOME/ndk-build $_NDK_OPTS + +pushd $DIR/../libs +for xarch in $(ls .); do + if [ ! -z "$_STRIP" ]; then + $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip -s $xarch/i2pd + fi + if [ ! -z "$_MODULE" ]; then + mv $xarch/i2pd $xarch/libi2pd.so + fi +done +popd diff --git a/binary/jni/build_debug.sh b/binary/jni/build_debug.sh deleted file mode 100755 index 7718ded..0000000 --- a/binary/jni/build_debug.sh +++ /dev/null @@ -1,23 +0,0 @@ -export I2PD_DEBUG=1 -if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then - echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m" - exit 1 -fi -echo Building boost... -./build_boost.sh -echo Building miniupnpc... -./build_miniupnpc.sh -echo Building openssl... -./build_openssl.sh -echo Building i2pd... -pushd . -NDK_MODULE_PATH=`pwd` -cd .. -NDK_PROJECT_PATH=`pwd` -popd -if [ -z "$BUILD_SO" -a "$BUILD_SO" == "" ]; then -export NDK_MODULE_PATH=$NDK_MODULE_PATH && export NDK_PROJECT_PATH=$NDK_PROJECT_PATH && $ANDROID_NDK_HOME/ndk-build V=1 NDK_LOG=1 -j`nproc` NDK_DEBUG=1 -else -export NDK_MODULE_PATH=$NDK_MODULE_PATH && export NDK_PROJECT_PATH=$NDK_PROJECT_PATH && ./ndkbuild-wrapper.sh V=1 NDK_LOG=1 -j`nproc` NDK_DEBUG=1 -fi -echo "$0 completed." diff --git a/binary/jni/build_release.sh b/binary/jni/build_release.sh deleted file mode 100755 index be0bc66..0000000 --- a/binary/jni/build_release.sh +++ /dev/null @@ -1,20 +0,0 @@ -if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then - echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m" - exit 1 -fi -echo Building boost... -./build_boost.sh -echo Building miniupnpc... -./build_miniupnpc.sh -echo Building openssl... -./build_openssl.sh -echo Building i2pd... -NDK_MODULE_PATH=`pwd` -cd .. -NDK_PROJECT_PATH=`pwd` -if [ -z "$BUILD_SO" -a "$BUILD_SO" == "" ]; then -export NDK_MODULE_PATH=$NDK_MODULE_PATH && export NDK_PROJECT_PATH=$NDK_PROJECT_PATH && $ANDROID_NDK_HOME/ndk-build V=1 NDK_LOG=1 -j`nproc` -else -export NDK_MODULE_PATH=$NDK_MODULE_PATH && export NDK_PROJECT_PATH=$NDK_PROJECT_PATH && ./ndkbuild-wrapper.sh V=1 NDK_LOG=1 -j`nproc` -fi -echo "$0 completed." \ No newline at end of file diff --git a/binary/jni/ndkbuild-wrapper.sh b/binary/jni/ndkbuild-wrapper.sh deleted file mode 100755 index 0891017..0000000 --- a/binary/jni/ndkbuild-wrapper.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -cd $NDK_PROJECT_PATH/jni -$ANDROID_NDK_HOME/ndk-build $* - -# if it doesn't exist, then create -if [ ! -d $NDK_PROJECT_PATH/libs ]; then mkdir $NDK_PROJECT_PATH/libs; fi - -cd $NDK_PROJECT_PATH/libs -for f in $(ls .); -do - if [ -z "$I2PD_DEBUG" -a "$I2PD_DEBUG" == "" ]; then - strip $f/i2pd - fi - mv $f/i2pd $f/libi2pd.so -done