From ce9a556993008ff73c472638a3714c8a20ddad6f Mon Sep 17 00:00:00 2001 From: eval Nya <60149113+nexplorer-3e@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:04:23 +0800 Subject: [PATCH] chore: build infra change --- .github/workflows/debug.yml | 27 +++++++++++++++++---------- build.gradle | 2 +- build.sh | 25 +++++++++++++++++++++++++ buildenv.sh | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 build.sh create mode 100644 buildenv.sh diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index c588dda54..b4453ac9f 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -62,10 +62,14 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: | sudo apt-get install yasm -y - ./run init libs libvpx - ./run init libs ffmpeg - ./run init action boringssl - ./run init libs boringssl + sudo apt-get install bison gcc make curl ninja-build -y + . buildenv.sh + cd TMessagesProj/jni + ./build_libvpx_clang.sh + ./build_ffmpeg_clang.sh + ./patch_ffmpeg.sh + ./patch_boringssl.sh + ./build_boringssl.sh native: name: Native Build (Telegram) runs-on: ubuntu-latest @@ -81,6 +85,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + submodules: 'recursive' - name: Fetch Status run: | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status @@ -105,6 +111,7 @@ jobs: TMessagesProj/jni/ffmpeg/build TMessagesProj/jni/libvpx/build key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} + fail-on-cache-miss: 'true' - name: BoringSSL Cache uses: actions/cache@v3 if: steps.cache.outputs.cache-hit != 'true' @@ -112,6 +119,7 @@ jobs: path: | TMessagesProj/jni/boringssl/build key: ${{ hashFiles('boringssl_status') }} + fail-on-cache-miss: 'true' - name: Setup Android SDK Tools uses: android-actions/setup-android@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -121,11 +129,6 @@ jobs: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties - - name: Fix BoringSSL - if: steps.cache.outputs.cache-hit != 'true' - run: | - cd TMessagesProj/jni - ./patch_boringssl.sh - uses: actions/setup-java@v3 name: Setup Java with: @@ -173,7 +176,11 @@ jobs: - name: Native Build if: steps.cache.outputs.cache-hit != 'true' run: | - ./run libs v2ray + . buildenv.sh + cd v2ray + make all + make downloadGoMobile + make BuildMobile build: name: Gradle Build runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index 6b68f4d79..6b53d8eff 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { static String detectNdkVersion() { - def version = "21.4.7075529" + def version = System.getenv("NDK_VER") def androidHome = System.getenv("ANDROID_HOME") diff --git a/build.sh b/build.sh new file mode 100644 index 000000000..dd7bc66fb --- /dev/null +++ b/build.sh @@ -0,0 +1,25 @@ +#/usr/bin/env bash + +. buildenv.sh + +cd TMessagesProj/jni +./build_libvpx_clang.sh +./build_ffmpeg_clang.sh +./patch_ffmpeg.sh +./patch_boringssl.sh +./build_boringssl.sh + +cd $PROJECT/v2ray +if [ $(command -v go) ]; then + export PATH=$PATH:$(go env GOPATH)/bin +else + echo "Error: go is not installed." + echo "To build libv2ray install latest stable go version first." + exit 1 +fi +make all +make downloadGoMobile +make BuildMobile +mv libv2ray.aar ../TMessagesProj/libs + +./gradlew assembleFullRelease \ No newline at end of file diff --git a/buildenv.sh b/buildenv.sh new file mode 100644 index 000000000..e6679b0e7 --- /dev/null +++ b/buildenv.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [ -z "$NDK_VER" ]; then export NDK_VER="21.4.7075529"; fi + +if [ -z "$ANDROID_HOME" ]; then + if [ -d "$HOME/Android/Sdk" ]; then + export ANDROID_HOME="$HOME/Android/Sdk" + elif [ -d "$HOME/.local/lib/android/sdk" ]; then + export ANDROID_HOME="$HOME/.local/lib/android/sdk" + fi +fi + + +_NDK="$ANDROID_HOME/ndk/$NDK_VER" +[ -f "$_NDK/source.properties" ] || _NDK="$ANDROID_NDK_HOME" +[ -f "$_NDK/source.properties" ] || _NDK="$NDK" +[ -f "$_NDK/source.properties" ] || _NDK="$ANDROID_HOME/ndk-bundle" + +if [ ! -f "$_NDK/source.properties" ]; then + echo "Error: NDK not found." + exit 1 +fi + +export ANDROID_NDK_HOME=$_NDK +export NDK=$_NDK +export PROJECT=$(realpath .) + +if [ $(command -v go) ]; then + export PATH=$PATH:$(go env GOPATH)/bin +else + echo "Warning: go is not installed." + echo "To build libv2ray install latest stable go version first." +fi