From 470cc90b6a21cf656d15d6be57ca2b371cce7fde Mon Sep 17 00:00:00 2001 From: R4SAS Date: Thu, 19 May 2022 13:02:13 +0300 Subject: [PATCH] Make possible to build on Windows with MSYS2 Signed-off-by: R4SAS --- README.md | 12 ++++++++++++ app/jni/build_miniupnpc.sh | 1 + app/jni/build_openssl.sh | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edab604..fb32cba 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This repository contains Android application sources of i2pd ## How to build ### Install g++, OpenJDK 11+, gradle 5.1+ + ```bash sudo apt-get install g++ openjdk-11-jdk gradle ``` @@ -22,6 +23,7 @@ If your system provides gradle with version < 5.1, download it from gradle homep https://gradle.org/install/ ### Download and prepare Android SDK for building + Android SDK Available here: https://developer.android.com/studio#downloads @@ -37,11 +39,13 @@ unzip commandlinetools-linux-8092744_latest.zip ``` ### Clone repository with submodules + ```bash git clone --recurse-submodules https://github.com/PurpleI2P/i2pd-android.git ``` ### Compile application + ```bash export ANDROID_SDK_ROOT=/opt/android-sdk export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.4.7075529 @@ -56,3 +60,11 @@ gradle clean assembleDebug ``` You will find APKs in `app/build/outputs/apk` + +### Building on Windows + +For building on Windows you must use MSYS2 with `mingw64` or `ucrt64` shell and preinstalled `gcc` ( package `mingw-w64-x86_64-gcc` or `mingw-w64-ucrt-x86_64-gcc`). + +Download Android SDK command line tools for Windows, unpack and isntall replacing `--sdk_root=` path. + +`ANDROID_SDK_ROOT` variable must point to SDK using linux-way path, like `/c/dev/android-sdk` when SDK installed to `C:\dev\android-sdk`. diff --git a/app/jni/build_miniupnpc.sh b/app/jni/build_miniupnpc.sh index 41bc422..b1085ab 100755 --- a/app/jni/build_miniupnpc.sh +++ b/app/jni/build_miniupnpc.sh @@ -9,6 +9,7 @@ function build_one { cd build cmake \ + -G "Unix Makefiles" \ -DUPNPC_BUILD_SHARED=False \ -DUPNPC_BUILD_TESTS=False \ -DUPNPC_BUILD_SAMPLE=False \ diff --git a/app/jni/build_openssl.sh b/app/jni/build_openssl.sh index e5d8bfe..f89db18 100755 --- a/app/jni/build_openssl.sh +++ b/app/jni/build_openssl.sh @@ -2,6 +2,8 @@ set -e +HOST_OS=`uname -a` + function build_one { mkdir -p out/$CPU @@ -74,7 +76,11 @@ checkPreRequisites cd openssl rm -rf out -PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH +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