From 0191d6a228c3280504bd7a5045a040083e147a59 Mon Sep 17 00:00:00 2001 From: r4sas Date: Tue, 8 Feb 2022 19:29:39 +0000 Subject: [PATCH] update libraries, add binary build files Signed-off-by: r4sas --- app/jni/Android.mk | 3 +- app/jni/android-ifaddrs | 2 +- app/jni/build_miniupnpc.sh | 35 +++++++++------- app/jni/build_openssl.sh | 8 +++- binary/jni/Android.mk | 79 +++++++++++++++++++++++++++++++++++ binary/jni/Application.mk | 34 +++++++++++++++ binary/jni/android-ifaddrs | 1 + binary/jni/boost | 1 + binary/jni/build_boost.sh | 1 + binary/jni/build_miniupnpc.sh | 1 + binary/jni/build_openssl.sh | 1 + binary/jni/i2pd | 1 + binary/jni/miniupnp | 1 + binary/jni/openssl | 1 + 14 files changed, 151 insertions(+), 18 deletions(-) create mode 100644 binary/jni/Android.mk create mode 100644 binary/jni/Application.mk create mode 120000 binary/jni/android-ifaddrs create mode 120000 binary/jni/boost create mode 120000 binary/jni/build_boost.sh create mode 120000 binary/jni/build_miniupnpc.sh create mode 120000 binary/jni/build_openssl.sh create mode 120000 binary/jni/i2pd create mode 120000 binary/jni/miniupnp create mode 120000 binary/jni/openssl diff --git a/app/jni/Android.mk b/app/jni/Android.mk index 777258c..712cecd 100644 --- a/app/jni/Android.mk +++ b/app/jni/Android.mk @@ -16,7 +16,8 @@ LOCAL_LDLIBS := -lz LOCAL_SRC_FILES := \ DaemonAndroid.cpp \ i2pd_android.cpp \ - $(IFADDRS_PATH)/ifaddrs.c \ + $(IFADDRS_PATH)/ifaddrs.cpp \ + $(IFADDRS_PATH)/boinic_netlink.cpp \ $(wildcard $(LIB_SRC_PATH)/*.cpp) \ $(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \ $(wildcard $(LANG_SRC_PATH)/*.cpp) \ diff --git a/app/jni/android-ifaddrs b/app/jni/android-ifaddrs index 41f6ba6..f302cc7 160000 --- a/app/jni/android-ifaddrs +++ b/app/jni/android-ifaddrs @@ -1 +1 @@ -Subproject commit 41f6ba66f28c3e321e640c249071f332f91f57f6 +Subproject commit f302cc7ead971d4068661d34c2f3ba06063d8ea2 diff --git a/app/jni/build_miniupnpc.sh b/app/jni/build_miniupnpc.sh index dd4dfa4..c9f9da6 100755 --- a/app/jni/build_miniupnpc.sh +++ b/app/jni/build_miniupnpc.sh @@ -2,27 +2,32 @@ set -e +CMAKE_VERSION=3.18.1 + function build_one { mkdir -p out/${CPU} cd out/${CPU} - cmake \ - -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 \ - ../.. + cmake \ + -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 \ + ../.. - echo "Building..." - cmake --build . -- libminiupnpc-static + echo "Building..." + cmake --build . -- libminiupnpc-static - cd ../.. + cd ../.. - if [[ -n 'out/include' ]]; then - mkdir -p out/include/miniupnpc - cp include/* out/include/miniupnpc - fi + if [[ -n 'out/include' ]]; then + mkdir -p out/include/miniupnpc + cp include/* out/include/miniupnpc + fi } function checkPreRequisites { @@ -50,7 +55,7 @@ cd miniupnp/miniupnpc rm -rf out # add cmake from Android SDK to PATH -PATH=$ANDROID_SDK_ROOT/cmake/3.10.2.4988404/bin:$PATH +PATH=$ANDROID_SDK_ROOT/cmake/${CMAKE_VERSION}/bin:$PATH function build { for arg in "$@"; do diff --git a/app/jni/build_openssl.sh b/app/jni/build_openssl.sh index ec00d7f..4f1c5b0 100755 --- a/app/jni/build_openssl.sh +++ b/app/jni/build_openssl.sh @@ -18,6 +18,7 @@ function build_one { echo "Building OpenSSL for ${CPU}..." make -j $(nproc) > output/build.log + echo "Installing to temporary directory..." make install_sw >> output/build.log cp output/lib/*.a out/${CPU} @@ -48,7 +49,12 @@ function checkPreRequisites { checkPreRequisites cd openssl -rm -rf out +rm -rf out output + +if [[ -f 'Makefile' ]]; then + make clean +fi + PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH diff --git a/binary/jni/Android.mk b/binary/jni/Android.mk new file mode 100644 index 0000000..ebeeb57 --- /dev/null +++ b/binary/jni/Android.mk @@ -0,0 +1,79 @@ +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 := \ + $(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)/UnixDaemon.cpp \ + $(DAEMON_SRC_PATH)/Daemon.cpp \ + $(DAEMON_SRC_PATH)/UPnP.cpp \ + $(DAEMON_SRC_PATH)/HTTPServer.cpp \ + $(DAEMON_SRC_PATH)/I2PControl.cpp \ + $(DAEMON_SRC_PATH)/i2pd.cpp \ + +include $(BUILD_EXECUTABLE) + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := boost_system +LOCAL_SRC_FILES := $(BOOST_PATH)/out/$(TARGET_ARCH_ABI)/libboost_system.a +LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/out/include +include $(PREBUILT_STATIC_LIBRARY) + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := boost_date_time +LOCAL_SRC_FILES := $(BOOST_PATH)/out/$(TARGET_ARCH_ABI)/libboost_date_time.a +LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/out/include +include $(PREBUILT_STATIC_LIBRARY) + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := boost_filesystem +LOCAL_SRC_FILES := $(BOOST_PATH)/out/$(TARGET_ARCH_ABI)/libboost_filesystem.a +LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/out/include +include $(PREBUILT_STATIC_LIBRARY) + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := boost_program_options +LOCAL_SRC_FILES := $(BOOST_PATH)/out/$(TARGET_ARCH_ABI)/libboost_program_options.a +LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/out/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)/libcrypto.a +LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/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)/libssl.a +LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/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)/libminiupnpc.a +LOCAL_EXPORT_C_INCLUDES := $(MINIUPNP_PATH)/miniupnpc/out/include +include $(PREBUILT_STATIC_LIBRARY) diff --git a/binary/jni/Application.mk b/binary/jni/Application.mk new file mode 100644 index 0000000..faf2498 --- /dev/null +++ b/binary/jni/Application.mk @@ -0,0 +1,34 @@ +APP_ABI += all +#APP_ABI += arm64-v8a +#APP_ABI += armeabi-v7a +#APP_ABI += x86_64 +#APP_ABI += x86 + +APP_PLATFORM := android-16 +#APP_PLATFORM := android-21 + +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_BINARY -DANDROID -D__ANDROID__ -DUSE_UPNP -Wno-deprecated-declarations +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) +APP_CPPFLAGS += -DANDROID_ARM7A +endif + +APP_LDFLAGS += -fPIE + +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/binary/jni/android-ifaddrs b/binary/jni/android-ifaddrs new file mode 120000 index 0000000..67835ab --- /dev/null +++ b/binary/jni/android-ifaddrs @@ -0,0 +1 @@ +../../app/jni/android-ifaddrs \ No newline at end of file diff --git a/binary/jni/boost b/binary/jni/boost new file mode 120000 index 0000000..fa5fd0f --- /dev/null +++ b/binary/jni/boost @@ -0,0 +1 @@ +../../app/jni/boost \ No newline at end of file diff --git a/binary/jni/build_boost.sh b/binary/jni/build_boost.sh new file mode 120000 index 0000000..775549c --- /dev/null +++ b/binary/jni/build_boost.sh @@ -0,0 +1 @@ +../../app/jni/build_boost.sh \ No newline at end of file diff --git a/binary/jni/build_miniupnpc.sh b/binary/jni/build_miniupnpc.sh new file mode 120000 index 0000000..7912d3c --- /dev/null +++ b/binary/jni/build_miniupnpc.sh @@ -0,0 +1 @@ +../../app/jni/build_miniupnpc.sh \ No newline at end of file diff --git a/binary/jni/build_openssl.sh b/binary/jni/build_openssl.sh new file mode 120000 index 0000000..4dad068 --- /dev/null +++ b/binary/jni/build_openssl.sh @@ -0,0 +1 @@ +../../app/jni/build_openssl.sh \ No newline at end of file diff --git a/binary/jni/i2pd b/binary/jni/i2pd new file mode 120000 index 0000000..c8e0a50 --- /dev/null +++ b/binary/jni/i2pd @@ -0,0 +1 @@ +../../app/jni/i2pd \ No newline at end of file diff --git a/binary/jni/miniupnp b/binary/jni/miniupnp new file mode 120000 index 0000000..a9e989c --- /dev/null +++ b/binary/jni/miniupnp @@ -0,0 +1 @@ +../../app/jni/miniupnp \ No newline at end of file diff --git a/binary/jni/openssl b/binary/jni/openssl new file mode 120000 index 0000000..a291c81 --- /dev/null +++ b/binary/jni/openssl @@ -0,0 +1 @@ +../../app/jni/openssl \ No newline at end of file