From 734693ba94115a660b716761a52219993f194a6a Mon Sep 17 00:00:00 2001 From: r4sas Date: Sun, 21 Jul 2024 20:12:40 +0000 Subject: [PATCH] move submodules, delete jni, remove ndkBuild from gradle Signed-off-by: r4sas --- .github/workflows/android.yml | 17 +--- .gitmodules | 10 +- app/build.gradle | 17 +--- app/jni/Android.mk | 80 --------------- app/jni/Application.mk | 23 ----- app/jni/DaemonAndroid.cpp | 138 ------------------------- app/jni/DaemonAndroid.h | 53 ---------- app/jni/android-ifaddrs | 1 - app/jni/boost | 1 - app/jni/build_boost.sh | 80 --------------- app/jni/build_miniupnpc.sh | 92 ----------------- app/jni/build_openssl.sh | 93 ----------------- app/jni/i2pd | 1 - app/jni/i2pd_android.cpp | 141 -------------------------- app/jni/miniupnp | 1 - app/jni/openssl | 1 - app/jni/org_purplei2p_i2pd_I2PD_JNI.h | 73 ------------- app/src/main/assets/certificates | 2 +- binary/jni/android-ifaddrs | 2 +- binary/jni/boost | 2 +- binary/jni/build_boost.sh | 81 ++++++++++++++- binary/jni/build_miniupnpc.sh | 93 ++++++++++++++++- binary/jni/build_openssl.sh | 94 ++++++++++++++++- binary/jni/i2pd | 2 +- binary/jni/miniupnp | 2 +- binary/jni/openssl | 2 +- gradle.properties | 1 - 27 files changed, 282 insertions(+), 821 deletions(-) delete mode 100644 app/jni/Android.mk delete mode 100644 app/jni/Application.mk delete mode 100644 app/jni/DaemonAndroid.cpp delete mode 100644 app/jni/DaemonAndroid.h delete mode 160000 app/jni/android-ifaddrs delete mode 160000 app/jni/boost delete mode 100755 app/jni/build_boost.sh delete mode 100755 app/jni/build_miniupnpc.sh delete mode 100755 app/jni/build_openssl.sh delete mode 160000 app/jni/i2pd delete mode 100644 app/jni/i2pd_android.cpp delete mode 160000 app/jni/miniupnp delete mode 160000 app/jni/openssl delete mode 100644 app/jni/org_purplei2p_i2pd_I2PD_JNI.h mode change 120000 => 160000 binary/jni/android-ifaddrs mode change 120000 => 160000 binary/jni/boost mode change 120000 => 100755 binary/jni/build_boost.sh mode change 120000 => 100755 binary/jni/build_miniupnpc.sh mode change 120000 => 100755 binary/jni/build_openssl.sh mode change 120000 => 160000 binary/jni/i2pd mode change 120000 => 160000 binary/jni/miniupnp mode change 120000 => 160000 binary/jni/openssl diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 85c3683..85cdc94 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -20,10 +20,8 @@ jobs: - name: Build required modules run: | export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 - pushd app/jni - ./build_boost.sh - ./build_openssl.sh - ./build_miniupnpc.sh + pushd binary/jni + ./build.sh -md popd - name: Build with Gradle run: ./gradlew --no-daemon assembleDebug @@ -47,18 +45,11 @@ jobs: run: export JAVA_HOME=$JAVA_HOME_11_X64 - name: Install required Android SDK packages run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "cmake;3.22.1" "ndk;23.2.8568313" - - name: Build required modules - run: | - export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 - pushd binary/jni - ./build_boost.sh - ./build_openssl.sh - ./build_miniupnpc.sh - popd - name: Build binaries with NDK run: | + export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 pushd binary/jni - $ANDROID_NDK_HOME/ndk-build -j2 NDK_MODULE_PATH=$PWD + ./build.sh popd - name: Create package with built binaries run: | diff --git a/.gitmodules b/.gitmodules index 919c43c..81ae69d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,16 @@ [submodule "android-ifaddrs"] - path = app/jni/android-ifaddrs + path = binary/jni/android-ifaddrs url = https://github.com/PurpleI2P/android-ifaddrs.git [submodule "i2pd"] - path = app/jni/i2pd + path = binary/jni/i2pd url = https://github.com/PurpleI2P/i2pd.git branch = openssl [submodule "miniupnp"] - path = app/jni/miniupnp + path = binary/jni/miniupnp url = https://github.com/miniupnp/miniupnp.git [submodule "openssl"] - path = app/jni/openssl + path = binary/jni/openssl url = https://github.com/openssl/openssl.git [submodule "boost"] - path = app/jni/boost + path = binary/jni/boost url = https://github.com/moritz-wundke/Boost-for-Android.git diff --git a/app/build.gradle b/app/build.gradle index 1e05076..896a828 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,8 +29,8 @@ android { targetSdkVersion 33 // TODO: 24? minSdkVersion 16 - versionCode 2520000 - versionName "2.52.0" + versionCode 2530000 + versionName "2.53.0" archivesBaseName += "-$versionName" ndkVersion "23.2.8568313" @@ -40,13 +40,6 @@ android { abiFilters "arm64-v8a" abiFilters "x86_64" } - - externalNativeBuild { - ndkBuild { - arguments "NDK_MODULE_PATH:=${rootProject.projectDir}/binary/jni" - arguments "-j${Runtime.getRuntime().availableProcessors()}" - } - } } splits { @@ -78,12 +71,6 @@ android { } } - externalNativeBuild { - ndkBuild { - path "${rootProject.projectDir}/binary/jni/Android.mk" - } - } - sourceSets { main { jniLibs.srcDir file("${rootProject.projectDir}/binary/libs") diff --git a/app/jni/Android.mk b/app/jni/Android.mk deleted file mode 100644 index 3938cf4..0000000 --- a/app/jni/Android.mk +++ /dev/null @@ -1,80 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := i2pd -LOCAL_CPP_FEATURES := rtti exceptions -LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(LANG_SRC_PATH) $(DAEMON_SRC_PATH) -LOCAL_STATIC_LIBRARIES := \ - boost_system \ - boost_date_time \ - boost_filesystem \ - boost_program_options \ - crypto \ - ssl \ - miniupnpc -LOCAL_LDLIBS := -lz - -LOCAL_SRC_FILES := \ - DaemonAndroid.cpp \ - i2pd_android.cpp \ - $(IFADDRS_PATH)/ifaddrs.cpp \ - $(IFADDRS_PATH)/bionic_netlink.cpp \ - $(wildcard $(LIB_SRC_PATH)/*.cpp) \ - $(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \ - $(wildcard $(LANG_SRC_PATH)/*.cpp) \ - $(DAEMON_SRC_PATH)/Daemon.cpp \ - $(DAEMON_SRC_PATH)/UPnP.cpp \ - $(DAEMON_SRC_PATH)/HTTPServer.cpp \ - $(DAEMON_SRC_PATH)/I2PControl.cpp \ - $(DAEMON_SRC_PATH)/I2PControlHandlers.cpp - -include $(BUILD_SHARED_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := boost_system -LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_system.a -LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := boost_date_time -LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_date_time.a -LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := boost_filesystem -LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_filesystem.a -LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := boost_program_options -LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_program_options.a -LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := crypto -LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libcrypto.a -LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := ssl -LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libssl.a -LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include -LOCAL_STATIC_LIBRARIES := crypto -include $(PREBUILT_STATIC_LIBRARY) - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := miniupnpc -LOCAL_SRC_FILES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/lib/libminiupnpc.a -LOCAL_EXPORT_C_INCLUDES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/include -include $(PREBUILT_STATIC_LIBRARY) diff --git a/app/jni/Application.mk b/app/jni/Application.mk deleted file mode 100644 index f167780..0000000 --- a/app/jni/Application.mk +++ /dev/null @@ -1,23 +0,0 @@ -NDK_TOOLCHAIN_VERSION := clang -APP_STL := c++_static - -# Enable c++17 extensions in source code -APP_CPPFLAGS += -std=c++17 -fexceptions -frtti - -APP_CPPFLAGS += -DANDROID -D__ANDROID__ -DUSE_UPNP -Wno-deprecated-declarations -ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) -APP_CPPFLAGS += -DANDROID_ARM7A -endif - -IFADDRS_PATH = $(NDK_MODULE_PATH)/android-ifaddrs -BOOST_PATH = $(NDK_MODULE_PATH)/boost -MINIUPNP_PATH = $(NDK_MODULE_PATH)/miniupnp -OPENSSL_PATH = $(NDK_MODULE_PATH)/openssl - -# don't change me -I2PD_SRC_PATH = $(NDK_MODULE_PATH)/i2pd - -LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd -LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client -LANG_SRC_PATH = $(I2PD_SRC_PATH)/i18n -DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon diff --git a/app/jni/DaemonAndroid.cpp b/app/jni/DaemonAndroid.cpp deleted file mode 100644 index 097e694..0000000 --- a/app/jni/DaemonAndroid.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* -* Copyright (c) 2013-2022, The PurpleI2P Project -* -* This file is part of Purple i2pd project and licensed under BSD3 -* -* See full license text in LICENSE file at top of project tree -*/ - -#include -#include -#include -#include -#include -#include -//#include "mainwindow.h" -#include "FS.h" -#include "DaemonAndroid.h" -#include "Daemon.h" -#include "I18N.h" - -namespace i2p -{ -namespace android -{ - std::string dataDir = ""; - std::string language = ""; - - DaemonAndroidImpl::DaemonAndroidImpl () - { - } - - DaemonAndroidImpl::~DaemonAndroidImpl () - { - } - - bool DaemonAndroidImpl::init(int argc, char* argv[]) - { - return Daemon.init(argc, argv); - } - - void DaemonAndroidImpl::start() - { - Daemon.start(); - } - - void DaemonAndroidImpl::stop() - { - Daemon.stop(); - } - - void DaemonAndroidImpl::restart() - { - stop(); - start(); - } - - void DaemonAndroidImpl::setDataDir(std::string path) - { - Daemon.setDataDir(path); - } - - static DaemonAndroidImpl daemon; - static char* argv[1]={strdup("tmp")}; - /** - * returns error details if failed - * returns "ok" if daemon initialized and started okay - */ - std::string start(/*int argc, char* argv[]*/) - { - try - { - { - // make sure assets are ready before proceed - i2p::fs::DetectDataDir(dataDir, false); - int numAttempts = 0; - do - { - if (i2p::fs::Exists (i2p::fs::DataDirPath("assets.ready"))) break; // assets ready - numAttempts++; - std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second - } - while (numAttempts <= 10); // 10 seconds max - - // Set application directory - daemon.setDataDir(dataDir); - - bool daemonInitSuccess = daemon.init(1, argv); - if(!daemonInitSuccess) - { - return "Daemon init failed"; - } - - // Set webconsole language from application - i2p::i18n::SetLanguage(language); - - daemon.start(); - } - } - catch (boost::exception& ex) - { - std::stringstream ss; - ss << boost::diagnostic_information(ex); - return ss.str(); - } - catch (std::exception& ex) - { - std::stringstream ss; - ss << ex.what(); - return ss.str(); - } - catch(...) - { - return "unknown exception"; - } - return "ok"; - } - - void stop() - { - daemon.stop(); - } - - void SetDataDir(std::string jdataDir) - { - dataDir = jdataDir; - } - - std::string GetDataDir(void) - { - return dataDir; - } - - void SetLanguage(std::string jlanguage) - { - language = jlanguage; - } -} -} diff --git a/app/jni/DaemonAndroid.h b/app/jni/DaemonAndroid.h deleted file mode 100644 index 6dbed75..0000000 --- a/app/jni/DaemonAndroid.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2013-2022, The PurpleI2P Project -* -* This file is part of Purple i2pd project and licensed under BSD3 -* -* See full license text in LICENSE file at top of project tree -*/ - -#ifndef DAEMON_ANDROID_H -#define DAEMON_ANDROID_H - -#include - -namespace i2p -{ -namespace android -{ - class DaemonAndroidImpl - { - public: - - DaemonAndroidImpl (); - ~DaemonAndroidImpl (); - - /** - * @return success - */ - bool init (int argc, char* argv[]); - void start (); - void stop (); - void restart (); - - void setDataDir (std::string path); - }; - - /** - * returns "ok" if daemon init failed - * returns errinfo if daemon initialized and started okay - */ - std::string start (); - - void stop (); - - // set datadir received from jni - void SetDataDir (std::string jdataDir); - // get datadir - std::string GetDataDir (void); - // set webconsole language - void SetLanguage (std::string jlanguage); -} -} - -#endif // DAEMON_ANDROID_H diff --git a/app/jni/android-ifaddrs b/app/jni/android-ifaddrs deleted file mode 160000 index f302cc7..0000000 --- a/app/jni/android-ifaddrs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f302cc7ead971d4068661d34c2f3ba06063d8ea2 diff --git a/app/jni/boost b/app/jni/boost deleted file mode 160000 index 53e6c16..0000000 --- a/app/jni/boost +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 53e6c16ea80c7dcb2683fd548e0c7a09ddffbfc1 diff --git a/app/jni/build_boost.sh b/app/jni/build_boost.sh deleted file mode 100755 index 92c345f..0000000 --- a/app/jni/build_boost.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -set -e - -BOOST_VERSION=1.78.0 -BOOST_LIBS=date_time,filesystem,program_options,system - -function build_one { - echo "Configuring and building..." - CXXFLAGS="-std=c++14" \ - NCPU=$(nproc) \ - ./build-android.sh \ - --boost=$BOOST_VERSION \ - --arch=$CPU \ - --target-version=$API \ - --with-libraries=$BOOST_LIBS \ - --layout=system \ - $ANDROID_NDK_HOME -} - -function checkPreRequisites { - - if ! [ -d "boost" ] || ! [ "$(ls -A boost)" ]; then - echo -e "\033[31mFailed! Submodule 'boost' not found!\033[0m" - echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" - exit - fi - - 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 - fi -} - -function build { - for arg in "$@"; do - case "$arg" in - x86_64) - API=21 - TARGET=x86_64 - build_one - ;; - arm64) - API=21 - CPU=arm64-v8a - build_one - ;; - x86) - API=16 - CPU=x86 - build_one - ;; - arm) - API=16 - CPU=armeabi-v7a - build_one - ;; - all) - API=16 - build_one - ;; - *) - ;; - esac - done -} - -checkPreRequisites - -cd boost - -# disable verbose output -sed -i -E -e 's/d\+2/d\+0/' build-android.sh -sed -i -E -e 's/\"23\.1\"\|\"25\.0\"/\"23\.1\"\|\"23\.2\"\|\"25\.0\"/' build-android.sh - -if (( $# == 0 )); then - build all -else - build $@ -fi diff --git a/app/jni/build_miniupnpc.sh b/app/jni/build_miniupnpc.sh deleted file mode 100755 index 42381b4..0000000 --- a/app/jni/build_miniupnpc.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -set -e - -CMAKE_VERSION=3.22.1 - -function build_one { - mkdir -p build out/$CPU - cd build - - cmake \ - -G "Unix Makefiles" \ - -DUPNPC_BUILD_SHARED=False \ - -DUPNPC_BUILD_TESTS=False \ - -DUPNPC_BUILD_SAMPLE=False \ - -DANDROID_NATIVE_API_LEVEL=$API \ - -DANDROID_ABI=$CPU \ - -DCMAKE_BUILD_TYPE=Release \ - -DANDROID_NDK=$ANDROID_NDK_HOME \ - -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ - -DCMAKE_INSTALL_PREFIX=../out/$CPU \ - .. - - echo "Building..." - cmake --build . -- libminiupnpc-static - make install - - cd .. - rm -rf build -} - -function checkPreRequisites { - - if ! [ -d "miniupnp" ] || ! [ "$(ls -A miniupnp)" ]; then - echo -e "\033[31mFailed! Submodule 'miniupnp' not found!\033[0m" - echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" - exit - fi - - 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 - - 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 - fi -} - -function build { - for arg in "$@"; do - case "$arg" in - x86_64) - API=21 - CPU=x86_64 - build_one - ;; - arm64) - API=21 - CPU=arm64-v8a - build_one - ;; - arm) - API=16 - CPU=armeabi-v7a - build_one - ;; - x86) - API=16 - CPU=x86 - build_one - ;; - *) - ;; - esac - done -} - -checkPreRequisites - -cd miniupnp/miniupnpc -rm -rf build out - -# add cmake from Android SDK to PATH -PATH=$ANDROID_HOME/cmake/$CMAKE_VERSION/bin:$PATH - -if (( $# == 0 )); then - build x86_64 arm64 arm x86 -else - build $@ -fi diff --git a/app/jni/build_openssl.sh b/app/jni/build_openssl.sh deleted file mode 100755 index f89db18..0000000 --- a/app/jni/build_openssl.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash - -set -e - -HOST_OS=`uname -a` - -function build_one { - mkdir -p out/$CPU - - echo "Configuring OpenSSL for $CPU..." - ./Configure \ - --prefix="$PWD/out/$CPU" \ - $TARGET \ - no-shared \ - no-tests \ - -D__ANDROID_API__=$API \ - -Wno-macro-redefined - - echo "Building OpenSSL for $CPU..." - make -j $(nproc) > out/build.log - - make install_sw >> out/build.log - - make clean -} - -function checkPreRequisites { - - if ! [ -d "openssl" ] || ! [ "$(ls -A openssl)" ]; then - echo -e "\033[31mFailed! Submodule 'openssl' not found!\033[0m" - echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" - exit - fi - - 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 - fi -} - -function build { - for arg in "$@"; do - case "$arg" in - x86_64) - API=21 - CPU=x86_64 - TARGET=android-x86_64 - build_one - ;; - arm64) - API=21 - CPU=arm64-v8a - TARGET=android-arm64 - build_one - ;; - arm) - API=16 - CPU=armeabi-v7a - TARGET=android-arm - build_one - ;; - x86) - API=16 - CPU=x86 - TARGET=android-x86 - build_one - ;; - *) - ;; - esac - done -} - -checkPreRequisites - -cd openssl -rm -rf out - -if [[ "$HOST_OS" == *"_NT-"* ]]; then - PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin:$PATH -else - PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH -fi - -if [[ -f 'Makefile' ]]; then - make clean -fi - -if (( $# == 0 )); then - build x86_64 arm64 arm x86 -else - build $@ -fi diff --git a/app/jni/i2pd b/app/jni/i2pd deleted file mode 160000 index 9a66549..0000000 --- a/app/jni/i2pd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9a6654943d9b90687fa474ba0ffbf024851d92f2 diff --git a/app/jni/i2pd_android.cpp b/app/jni/i2pd_android.cpp deleted file mode 100644 index 94a52c5..0000000 --- a/app/jni/i2pd_android.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* -* Copyright (c) 2013-2022, The PurpleI2P Project -* -* This file is part of Purple i2pd project and licensed under BSD3 -* -* See full license text in LICENSE file at top of project tree -*/ - -#include -#include "org_purplei2p_i2pd_I2PD_JNI.h" -#include "DaemonAndroid.h" -#include "Config.h" -#include "RouterContext.h" -#include "ClientContext.h" -#include "Transports.h" -#include "Tunnel.h" - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith - (JNIEnv *env, jclass clazz) { -#if defined(__arm__) - #if defined(__ARM_ARCH_7A__) - #if defined(__ARM_NEON__) - #if defined(__ARM_PCS_VFP) - #define ABI "armeabi-v7a/NEON (hard-float)" - #else - #define ABI "armeabi-v7a/NEON" - #endif - #else - #if defined(__ARM_PCS_VFP) - #define ABI "armeabi-v7a (hard-float)" - #else - #define ABI "armeabi-v7a" - #endif - #endif - #else - #define ABI "armeabi" - #endif - #elif defined(__i386__) - #define ABI "x86" - #elif defined(__x86_64__) - #define ABI "x86_64" - #elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */ - #define ABI "mips64" - #elif defined(__mips__) - #define ABI "mips" - #elif defined(__aarch64__) - #define ABI "arm64-v8a" - #else - #define ABI "unknown" -#endif - - return env->NewStringUTF(ABI); -} - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon - (JNIEnv *env, jclass clazz) { - return env->NewStringUTF(i2p::android::start().c_str()); -} - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir - (JNIEnv *env, jclass clazz) { - return env->NewStringUTF(i2p::android::GetDataDir().c_str()); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon - (JNIEnv *env, jclass clazz) { - i2p::android::stop(); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels - (JNIEnv *env, jclass clazz) { - i2p::context.SetAcceptsTunnels (false); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels - (JNIEnv *env, jclass clazz) { - i2p::context.SetAcceptsTunnels (true); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs - (JNIEnv *env, jclass clazz) { - i2p::client::context.ReloadConfig(); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged - (JNIEnv *env, jclass clazz, jboolean isConnected) { - bool isConnectedBool = (bool) isConnected; - i2p::transport::transports.SetOnline (isConnectedBool); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir - (JNIEnv *env, jclass clazz, jstring jdataDir) { - auto dataDir = env->GetStringUTFChars(jdataDir, NULL); - i2p::android::SetDataDir(dataDir); - env->ReleaseStringUTFChars(jdataDir, dataDir); -} - -JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getTransitTunnelsCount - (JNIEnv *env, jclass clazz) { - return i2p::tunnel::tunnels.CountTransitTunnels(); -} - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr - (JNIEnv *env, jclass clazz) { - std::string httpAddr; i2p::config::GetOption("http.address", httpAddr); - uint16_t httpPort; i2p::config::GetOption("http.port", httpPort); - std::string result = "http://" + httpAddr + ":" + std::to_string(httpPort) + "/"; - return env->NewStringUTF(result.c_str()); -} - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage - (JNIEnv *env, jclass clazz, jstring jlanguage) { - auto language = env->GetStringUTFChars(jlanguage, NULL); - i2p::android::SetLanguage(language); - env->ReleaseStringUTFChars(jlanguage, language); -} - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getHTTPProxyState - (JNIEnv *, jclass) { - return i2p::client::context.GetHttpProxy () ? true : false; -} - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSOCKSProxyState - (JNIEnv *, jclass) { - return i2p::client::context.GetSocksProxy() ? true : false; -} - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getBOBState - (JNIEnv *, jclass) { - return i2p::client::context.GetBOBCommandChannel() ? true : false; -} - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSAMState - (JNIEnv *, jclass) { - return i2p::client::context.GetSAMBridge() ? true : false; -} - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getI2CPState - (JNIEnv *, jclass) { - return i2p::client::context.GetI2CPServer() ? true : false; -} diff --git a/app/jni/miniupnp b/app/jni/miniupnp deleted file mode 160000 index 6576eb6..0000000 --- a/app/jni/miniupnp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6576eb611b670c4841cc65095914275d6be008b2 diff --git a/app/jni/openssl b/app/jni/openssl deleted file mode 160000 index e04bd34..0000000 --- a/app/jni/openssl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e04bd3433fd84e1861bf258ea37928d9845e6a86 diff --git a/app/jni/org_purplei2p_i2pd_I2PD_JNI.h b/app/jni/org_purplei2p_i2pd_I2PD_JNI.h deleted file mode 100644 index 4c37e3d..0000000 --- a/app/jni/org_purplei2p_i2pd_I2PD_JNI.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -* Copyright (c) 2013-2022, The PurpleI2P Project -* -* This file is part of Purple i2pd project and licensed under BSD3 -* -* See full license text in LICENSE file at top of project tree -*/ - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_purplei2p_i2pd_I2PD_JNI */ - -#ifndef _Included_org_purplei2p_i2pd_I2PD_JNI -#define _Included_org_purplei2p_i2pd_I2PD_JNI -#ifdef __cplusplus -extern "C" { -#endif - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith - (JNIEnv *, jclass); - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir - (JNIEnv *env, jclass clazz, jstring jdataDir); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage - (JNIEnv *env, jclass clazz, jstring jlanguage); - -JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getTransitTunnelsCount - (JNIEnv *, jclass); - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr - (JNIEnv *, jclass); - -JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir - (JNIEnv *, jclass); - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getHTTPProxyState - (JNIEnv *, jclass); - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSOCKSProxyState - (JNIEnv *, jclass); - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getBOBState - (JNIEnv *, jclass); - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSAMState - (JNIEnv *, jclass) ; - -JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getI2CPState - (JNIEnv *, jclass); - -JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged - (JNIEnv * env, jclass clazz, jboolean isConnected); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/app/src/main/assets/certificates b/app/src/main/assets/certificates index 7a11d56..ffc7743 120000 --- a/app/src/main/assets/certificates +++ b/app/src/main/assets/certificates @@ -1 +1 @@ -../../../jni/i2pd/contrib/certificates \ No newline at end of file +../../../../binary/jni/i2pd/contrib/certificates \ No newline at end of file diff --git a/binary/jni/android-ifaddrs b/binary/jni/android-ifaddrs deleted file mode 120000 index 67835ab..0000000 --- a/binary/jni/android-ifaddrs +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/android-ifaddrs \ No newline at end of file diff --git a/binary/jni/android-ifaddrs b/binary/jni/android-ifaddrs new file mode 160000 index 0000000..f302cc7 --- /dev/null +++ b/binary/jni/android-ifaddrs @@ -0,0 +1 @@ +Subproject commit f302cc7ead971d4068661d34c2f3ba06063d8ea2 diff --git a/binary/jni/boost b/binary/jni/boost deleted file mode 120000 index fa5fd0f..0000000 --- a/binary/jni/boost +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/boost \ No newline at end of file diff --git a/binary/jni/boost b/binary/jni/boost new file mode 160000 index 0000000..53e6c16 --- /dev/null +++ b/binary/jni/boost @@ -0,0 +1 @@ +Subproject commit 53e6c16ea80c7dcb2683fd548e0c7a09ddffbfc1 diff --git a/binary/jni/build_boost.sh b/binary/jni/build_boost.sh deleted file mode 120000 index 775549c..0000000 --- a/binary/jni/build_boost.sh +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/build_boost.sh \ No newline at end of file diff --git a/binary/jni/build_boost.sh b/binary/jni/build_boost.sh new file mode 100755 index 0000000..92c345f --- /dev/null +++ b/binary/jni/build_boost.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +set -e + +BOOST_VERSION=1.78.0 +BOOST_LIBS=date_time,filesystem,program_options,system + +function build_one { + echo "Configuring and building..." + CXXFLAGS="-std=c++14" \ + NCPU=$(nproc) \ + ./build-android.sh \ + --boost=$BOOST_VERSION \ + --arch=$CPU \ + --target-version=$API \ + --with-libraries=$BOOST_LIBS \ + --layout=system \ + $ANDROID_NDK_HOME +} + +function checkPreRequisites { + + if ! [ -d "boost" ] || ! [ "$(ls -A boost)" ]; then + echo -e "\033[31mFailed! Submodule 'boost' not found!\033[0m" + echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" + exit + fi + + 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 + fi +} + +function build { + for arg in "$@"; do + case "$arg" in + x86_64) + API=21 + TARGET=x86_64 + build_one + ;; + arm64) + API=21 + CPU=arm64-v8a + build_one + ;; + x86) + API=16 + CPU=x86 + build_one + ;; + arm) + API=16 + CPU=armeabi-v7a + build_one + ;; + all) + API=16 + build_one + ;; + *) + ;; + esac + done +} + +checkPreRequisites + +cd boost + +# disable verbose output +sed -i -E -e 's/d\+2/d\+0/' build-android.sh +sed -i -E -e 's/\"23\.1\"\|\"25\.0\"/\"23\.1\"\|\"23\.2\"\|\"25\.0\"/' build-android.sh + +if (( $# == 0 )); then + build all +else + build $@ +fi diff --git a/binary/jni/build_miniupnpc.sh b/binary/jni/build_miniupnpc.sh deleted file mode 120000 index 7912d3c..0000000 --- a/binary/jni/build_miniupnpc.sh +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/build_miniupnpc.sh \ No newline at end of file diff --git a/binary/jni/build_miniupnpc.sh b/binary/jni/build_miniupnpc.sh new file mode 100755 index 0000000..42381b4 --- /dev/null +++ b/binary/jni/build_miniupnpc.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +set -e + +CMAKE_VERSION=3.22.1 + +function build_one { + mkdir -p build out/$CPU + cd build + + cmake \ + -G "Unix Makefiles" \ + -DUPNPC_BUILD_SHARED=False \ + -DUPNPC_BUILD_TESTS=False \ + -DUPNPC_BUILD_SAMPLE=False \ + -DANDROID_NATIVE_API_LEVEL=$API \ + -DANDROID_ABI=$CPU \ + -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_NDK=$ANDROID_NDK_HOME \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=../out/$CPU \ + .. + + echo "Building..." + cmake --build . -- libminiupnpc-static + make install + + cd .. + rm -rf build +} + +function checkPreRequisites { + + if ! [ -d "miniupnp" ] || ! [ "$(ls -A miniupnp)" ]; then + echo -e "\033[31mFailed! Submodule 'miniupnp' not found!\033[0m" + echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" + exit + fi + + 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 + + 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 + fi +} + +function build { + for arg in "$@"; do + case "$arg" in + x86_64) + API=21 + CPU=x86_64 + build_one + ;; + arm64) + API=21 + CPU=arm64-v8a + build_one + ;; + arm) + API=16 + CPU=armeabi-v7a + build_one + ;; + x86) + API=16 + CPU=x86 + build_one + ;; + *) + ;; + esac + done +} + +checkPreRequisites + +cd miniupnp/miniupnpc +rm -rf build out + +# add cmake from Android SDK to PATH +PATH=$ANDROID_HOME/cmake/$CMAKE_VERSION/bin:$PATH + +if (( $# == 0 )); then + build x86_64 arm64 arm x86 +else + build $@ +fi diff --git a/binary/jni/build_openssl.sh b/binary/jni/build_openssl.sh deleted file mode 120000 index 4dad068..0000000 --- a/binary/jni/build_openssl.sh +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/build_openssl.sh \ No newline at end of file diff --git a/binary/jni/build_openssl.sh b/binary/jni/build_openssl.sh new file mode 100755 index 0000000..f89db18 --- /dev/null +++ b/binary/jni/build_openssl.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +set -e + +HOST_OS=`uname -a` + +function build_one { + mkdir -p out/$CPU + + echo "Configuring OpenSSL for $CPU..." + ./Configure \ + --prefix="$PWD/out/$CPU" \ + $TARGET \ + no-shared \ + no-tests \ + -D__ANDROID_API__=$API \ + -Wno-macro-redefined + + echo "Building OpenSSL for $CPU..." + make -j $(nproc) > out/build.log + + make install_sw >> out/build.log + + make clean +} + +function checkPreRequisites { + + if ! [ -d "openssl" ] || ! [ "$(ls -A openssl)" ]; then + echo -e "\033[31mFailed! Submodule 'openssl' not found!\033[0m" + echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m" + exit + fi + + 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 + fi +} + +function build { + for arg in "$@"; do + case "$arg" in + x86_64) + API=21 + CPU=x86_64 + TARGET=android-x86_64 + build_one + ;; + arm64) + API=21 + CPU=arm64-v8a + TARGET=android-arm64 + build_one + ;; + arm) + API=16 + CPU=armeabi-v7a + TARGET=android-arm + build_one + ;; + x86) + API=16 + CPU=x86 + TARGET=android-x86 + build_one + ;; + *) + ;; + esac + done +} + +checkPreRequisites + +cd openssl +rm -rf out + +if [[ "$HOST_OS" == *"_NT-"* ]]; then + PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin:$PATH +else + PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH +fi + +if [[ -f 'Makefile' ]]; then + make clean +fi + +if (( $# == 0 )); then + build x86_64 arm64 arm x86 +else + build $@ +fi diff --git a/binary/jni/i2pd b/binary/jni/i2pd deleted file mode 120000 index c8e0a50..0000000 --- a/binary/jni/i2pd +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/i2pd \ No newline at end of file diff --git a/binary/jni/i2pd b/binary/jni/i2pd new file mode 160000 index 0000000..9a66549 --- /dev/null +++ b/binary/jni/i2pd @@ -0,0 +1 @@ +Subproject commit 9a6654943d9b90687fa474ba0ffbf024851d92f2 diff --git a/binary/jni/miniupnp b/binary/jni/miniupnp deleted file mode 120000 index a9e989c..0000000 --- a/binary/jni/miniupnp +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/miniupnp \ No newline at end of file diff --git a/binary/jni/miniupnp b/binary/jni/miniupnp new file mode 160000 index 0000000..6576eb6 --- /dev/null +++ b/binary/jni/miniupnp @@ -0,0 +1 @@ +Subproject commit 6576eb611b670c4841cc65095914275d6be008b2 diff --git a/binary/jni/openssl b/binary/jni/openssl deleted file mode 120000 index a291c81..0000000 --- a/binary/jni/openssl +++ /dev/null @@ -1 +0,0 @@ -../../app/jni/openssl \ No newline at end of file diff --git a/binary/jni/openssl b/binary/jni/openssl new file mode 160000 index 0000000..e04bd34 --- /dev/null +++ b/binary/jni/openssl @@ -0,0 +1 @@ +Subproject commit e04bd3433fd84e1861bf258ea37928d9845e6a86 diff --git a/gradle.properties b/gradle.properties index 40532e6..dfb2fa4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.parallel=true -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8