diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 8efc9ff1f..2710721b3 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - dev paths-ignore: - '**.md' - '.github/**' @@ -13,44 +14,213 @@ on: - dev jobs: - native: - name: Native Build + ffmpeg: + name: Native Build ( FFmpeg ) runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - - name: Setup Android SDK Tools - uses: android-actions/setup-android@v2 - - name: Native Cache - uses: actions/cache@main + - name: Fetch Status + run: git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status + - name: FFmpeg Cache + id: cache + uses: actions/cache@v2 with: path: | - TMessagesProj/libs - TMessagesProj/src/main/libs - key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} - - name: Check Cache - run: | - [ -f "TMessagesProj/libs/libv2ray.aar" ] && echo "Cache found." || echo "CONTINUE=true" >> $GITHUB_ENV + TMessagesProj/jni/ffmpeg/build + key: ${{ hashFiles('ffmpeg_status') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' - name: Install NDK - if: env.CONTINUE + if: steps.cache.outputs.cache-hit != 'true' run: | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties - - uses: actions/setup-go@v2 - if: env.CONTINUE + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: | + ./run init libs ffmpeg + boringssl: + name: Native Build ( BoringSSL ) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status TMessagesProj/jni/boringssl > boringssl_status + - name: BoringSSL Cache + id: cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/jni/boringssl/build + key: ${{ hashFiles('boringssl_status') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' + - name: Install NDK + if: steps.cache.outputs.cache-hit != 'true' + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: | + ./run init action boringssl + ./run init libs boringssl + native: + name: Native Build ( Telegram ) + runs-on: ubuntu-latest + needs: + - ffmpeg + - boringssl + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: | + git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status + git submodule status TMessagesProj/jni/boringssl > boringssl_status + - name: Native Cache + id: cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/src/main/libs + key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }} + - name: Checkout Library + if: steps.cache.outputs.cache-hit != 'true' + run: | + git submodule update --init 'TMessagesProj/jni/*' + - name: FFmpeg Cache + uses: actions/cache@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + path: | + TMessagesProj/jni/ffmpeg/build + key: ${{ hashFiles('ffmpeg_status') }} + - name: BoringSSL Cache + uses: actions/cache@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + path: | + TMessagesProj/jni/boringssl/build + key: ${{ hashFiles('boringssl_status') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' + - name: Install NDK + if: steps.cache.outputs.cache-hit != 'true' + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - name: Fix BoringSSL + run: | + cd TMessagesProj/jni + ./patch_boringssl.sh + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: | + ./run libs native + v2ray: + name: Native Build (V2ray) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: V2ray Cache + id: cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/libv2ray.aar + key: ${{ hashFiles('bin/libs/v2ray.sh') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' + - name: Install NDK + if: steps.cache.outputs.cache-hit != 'true' + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - name: Install Golang + uses: actions/setup-go@v2 + if: steps.cache.outputs.cache-hit != 'true' with: go-version: ^1.15 - name: Native Build - if: env.CONTINUE + if: steps.cache.outputs.cache-hit != 'true' + run: ./run libs v2ray + shadowsocks: + name: Native Build (Shadowsocks) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status + - name: Shadowsocks Cache + id: cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/ss-rust-release.aar + key: ${{ hashFiles('shadowsocks_status') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' + - name: Install NDK + if: steps.cache.outputs.cache-hit != 'true' run: | - ./run init action - ./run init libs - ./run libs update + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - name: Install Rust + if: steps.cache.outputs.cache-hit != 'true' + run: ./run init action shadowsocks + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run libs shadowsocks + shadowsocksr: + name: Native Build (ShadowsocksR) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'ssr-libev/*' > shadowsocksr_status + - name: ShadowsocksR Cache + id: cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/ssr-libev-release.aar + key: ${{ hashFiles('shadowsocksr_status') }} + - name: Setup Android SDK Tools + uses: android-actions/setup-android@v2 + if: steps.cache.outputs.cache-hit != 'true' + - name: Install NDK + if: steps.cache.outputs.cache-hit != 'true' + run: | + echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run libs ssr debug: name: Debug Build runs-on: ubuntu-latest - needs: native + needs: + - native + - v2ray + - shadowsocks + - shadowsocksr strategy: matrix: flavor: @@ -67,19 +237,43 @@ jobs: uses: actions/checkout@v2 - name: Setup Android SDK Tools uses: android-actions/setup-android@v2 + - name: Fetch Status + run: | + git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status + git submodule status TMessagesProj/jni/boringssl > boringssl_status + git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status + git submodule status 'ssr-libev/*' > shadowsocksr_status - name: Native Cache - uses: actions/cache@main + id: cache + uses: actions/cache@v2 with: path: | - TMessagesProj/libs TMessagesProj/src/main/libs - key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} + key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }} + - name: V2ray Cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/libv2ray.aar + key: ${{ hashFiles('bin/libs/v2ray.sh') }} + - name: Shadowsocks Cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/ss-rust-release.aar + key: ${{ hashFiles('shadowsocks_status') }} + - name: ShadowsocksR Cache + uses: actions/cache@v2 + with: + path: | + TMessagesProj/libs/ssr-libev-release.aar + key: ${{ hashFiles('shadowsocksr_status') }} - name: Fix Gradle Memoery run: | sed -i -e "s/16384/6144/g" gradle.properties echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties - name: Gradle cache - uses: actions/cache@main + uses: actions/cache@v2 with: path: ~/.gradle key: gradle-${{ hashFiles('**/*.gradle') }} diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml deleted file mode 100644 index c116a5d5f..000000000 --- a/.github/workflows/native.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Native build - -on: - push: - branches: - - dev - paths: - - 'TMessagesProj/jni/**' - - 'ss-rust/src/main/rust/**' -jobs: - native: - name: Native Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Android SDK Tools - uses: android-actions/setup-android@v2 - - name: Install NDK - run: | - echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null - echo "sdk.dir=${ANDROID_HOME}" > local.properties - echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties - - uses: actions/setup-go@v2 - with: - go-version: ^1.15 - - name: Native Cache - uses: actions/cache@main - with: - path: | - TMessagesProj/libs - TMessagesProj/src/main/libs - key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} - - name: Fix Gradle Memoery - run: sed -i -e "s/16384/6144/g" gradle.properties - - name: Native Build - run: | - test -f TMessagesProj/libs/libv2ray.aar && exit 0 - ./run init action - ./run init libs - ./run libs update \ No newline at end of file diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index eedec01cb..24f4299f2 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -59,7 +59,7 @@ repositories { dependencies { implementation "androidx.browser:browser:1.3.0" - implementation 'androidx.core:core-ktx:1.5.0-beta01' + implementation 'androidx.core:core-ktx:1.5.0-beta02' implementation 'androidx.palette:palette-ktx:1.0.0' implementation 'androidx.viewpager:viewpager:1.0.0' implementation 'androidx.exifinterface:exifinterface:1.3.2' @@ -93,7 +93,8 @@ dependencies { implementation project(":openpgp-api") - compileOnly files('libs/libv2ray.aar') + compileOnly fileTree("libs") + compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" compileOnly "com.google.android.play:core:$playCoreVersion" @@ -336,7 +337,7 @@ android { sourceSets.all { set -> if (set.name.startsWith("full")) { set.dependencies { - implementation files('libs/libv2ray.aar', 'libs/ss-rust-release.aar', 'libs/ssr-libev-release.aar') + implementation fileTree("libs") } } if (set.name.matches("(mini|full).*")) { diff --git a/bin/init/action/boringssl.sh b/bin/init/action/boringssl.sh new file mode 100755 index 000000000..369ff4956 --- /dev/null +++ b/bin/init/action/boringssl.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo apt-get install bison gcc make curl ninja-build -y diff --git a/bin/init/action.sh b/bin/init/action/shadowsocks.sh similarity index 74% rename from bin/init/action.sh rename to bin/init/action/shadowsocks.sh index 5f70c1a82..bebd9e745 100755 --- a/bin/init/action.sh +++ b/bin/init/action/shadowsocks.sh @@ -1,10 +1,8 @@ -#!/bin/bash - -sudo apt-get install bison gcc make curl ninja-build -y +#!/usr/bin/env bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y echo "source \$HOME/.cargo/env" >>$HOME/.bashrc && source $HOME/.cargo/env -git submodule update --init --recursive +git submodule update --init ss-rust/src/main/rust/shadowsocks-rust cd ss-rust/src/main/rust/shadowsocks-rust rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android diff --git a/bin/init/libs.sh b/bin/init/libs.sh index a7df10785..e54365f4d 100755 --- a/bin/init/libs.sh +++ b/bin/init/libs.sh @@ -2,24 +2,5 @@ source "bin/init/env.sh" -export NINJA_PATH="$(command -v ninja)" -export PATH=$(echo "$ANDROID_HOME"/cmake/*/bin):$PATH - -cd TMessagesProj/jni || exit 1 -git submodule update --init --recursive - -cd ffmpeg -git reset --hard -git clean -fdx -cd .. - -./build_ffmpeg_clang.sh || exit 1 -./patch_ffmpeg.sh || exit 1 - -cd boringssl -git reset --hard -git clean -fdx -cd .. - -./patch_boringssl.sh || exit 1 -./build_boringssl.sh \ No newline at end of file +bin/init/libs/ffmpeg.sh +bin/init/libs/boringssl.sh diff --git a/bin/init/libs/boringssl.sh b/bin/init/libs/boringssl.sh new file mode 100755 index 000000000..c9471ff52 --- /dev/null +++ b/bin/init/libs/boringssl.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +source "bin/init/env.sh" + +export NINJA_PATH="$(command -v ninja)" +export PATH=$(echo "$ANDROID_HOME"/cmake/*/bin):$PATH + +cd TMessagesProj/jni || exit 1 +git submodule update --init boringssl + +cd boringssl +git reset --hard +git clean -fdx +cd .. + +./patch_boringssl.sh || exit 1 +./build_boringssl.sh diff --git a/bin/init/libs/ffmpeg.sh b/bin/init/libs/ffmpeg.sh new file mode 100755 index 000000000..78f5c1d6a --- /dev/null +++ b/bin/init/libs/ffmpeg.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source "bin/init/env.sh" + +cd TMessagesProj/jni || exit 1 +git submodule update --init ffmpeg + +cd ffmpeg +git reset --hard +git clean -fdx +cd .. + +./build_ffmpeg_clang.sh || exit 1 +./patch_ffmpeg.sh || exit 1 diff --git a/bin/libs/shadowsocks.sh b/bin/libs/shadowsocks.sh new file mode 100755 index 000000000..5c9d65c78 --- /dev/null +++ b/bin/libs/shadowsocks.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +source "bin/init/env.sh" + +git submodule update --init ss-rust/src/main/rust/shadowsocks-rust +./gradlew ss-rust:assembleRelease || exit 1 +cp ss-rust/build/outputs/aar/* TMessagesProj/libs diff --git a/bin/libs/ss.sh b/bin/libs/ss.sh deleted file mode 100755 index a5465a07a..000000000 --- a/bin/libs/ss.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -source "bin/init/env.sh" - -./gradlew ss-rust:assembleRelease || exit 1 -cp ss-rust/build/outputs/aar/* TMessagesProj/libs \ No newline at end of file diff --git a/bin/libs/ssr.sh b/bin/libs/ssr.sh index aaebc8a51..43445be5c 100755 --- a/bin/libs/ssr.sh +++ b/bin/libs/ssr.sh @@ -2,5 +2,6 @@ source "bin/init/env.sh" +git submodule update --init 'ssr-libev/src/main/jni/*' ./gradlew ssr-libev:assembleRelease || exit 1 -cp ssr-libev/build/outputs/aar/* TMessagesProj/libs \ No newline at end of file +cp ssr-libev/build/outputs/aar/* TMessagesProj/libs diff --git a/bin/libs/update.sh b/bin/libs/update.sh index 585ed1ac3..7f2c1fd0b 100755 --- a/bin/libs/update.sh +++ b/bin/libs/update.sh @@ -1,6 +1,6 @@ #!/bin/bash bin/libs/v2ray.sh || exit 1 -bin/libs/ss.sh || exit 1 +bin/libs/shadowsocks.sh || exit 1 bin/libs/ssr.sh || exit 1 bin/libs/native.sh || exit 1 diff --git a/bin/libs/v2ray.sh b/bin/libs/v2ray.sh index b884c2177..5d0e4e870 100755 --- a/bin/libs/v2ray.sh +++ b/bin/libs/v2ray.sh @@ -1,19 +1,9 @@ #!/bin/bash -V2RAY_CORE_VERSION="4.34.0" +// v4.34.0 +V2RAY_CORE_VERSION="a6efb4d60b86789a68ed8ac8d52cfcec2d80229a" source "bin/init/env.sh" -#v2rayCore="$(go env GOPATH)/src/v2ray.com/core" -# -#if [ ! -f "$v2rayCore/go.mod" ]; then -# git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1 -#fi -# -#cd "$v2rayCore" -#git fetch origin "v$V2RAY_CORE_VERSION" -#git checkout -b master -#git reset "v$V2RAY_CORE_VERSION" --hard - export GO111MOUDLE=on export PATH="$PATH:$(go env GOPATH)/bin" @@ -21,8 +11,9 @@ cd "$PROJECT/build" [ -d "v2ray" ] || git clone https://github.com/2dust/AndroidLibV2rayLite v2ray cd v2ray git reset --hard && git clean -fdx -sed -i -e "s|go 1.14|go 1.15|g" go.mod -go mod download -x +sed -i -e "s|go 1.14|go 1.16|g" go.mod +sed -i -e "s|core master|core $V2RAY_CORE_VERSION|g" go.mod +go mod download -x || exit 1 go get -v golang.org/x/mobile/cmd/... gomobile init gomobile bind -v -ldflags='-s -w' . || exit 1