From affb107b9d6a19c32f48dd5adb029dcf6434a2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=A1=A0=E1=A0=B5=E1=A1=A0=E1=A1=B3=20=E1=A1=A0=E1=A0=B5?= =?UTF-8?q?=E1=A1=A0=20=E1=A0=AE=E1=A0=A0=E1=A0=A8=E1=A1=A9=E1=A0=8B?= =?UTF-8?q?=E1=A0=A0=E1=A0=A8?= <125150101+UjuiUjuMandan@users.noreply.github.com> Date: Sat, 28 Dec 2024 19:29:00 +0800 Subject: [PATCH] Sagernet (#4194) * switch to sagernet/gomobile * arguments for rb * match ndk version * with more options * nttld/setup-ndk#518 --- .github/workflows/build.yml | 46 +++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7587dc28..6d1e8be6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,13 +36,39 @@ jobs: path: ${{ github.workspace }}/build/AndroidLibV2rayLite/libs key: libtun2socks-${{ runner.os }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/refs/heads/master') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/badvpn/HEAD') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/libancillary/HEAD') }} + - name: Fetch AndroidLibXrayLite + run: | + cd ${{ github.workspace }}/build + git clone --depth=1 -b main https://github.com/2dust/AndroidLibXrayLite.git + + - name: Restore cached libv2ray + id: cache-libv2ray-restore + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/build/AndroidLibXrayLite/ + key: libv2ray-${{ runner.os }}-${{ hashFiles('build/AndroidLibXrayLite/.git/refs/heads/main') }} + - name: Setup Android NDK - if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' + if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' || steps.cache-libv2ray-restore.outputs.cache-hit != 'true' uses: nttld/setup-ndk@v1 id: setup-ndk # Same version as https://gitlab.com/fdroid/fdroiddata/metadata/com.v2ray.ang.yml with: ndk-version: r27 + add-to-path: true + link-to-sdk: true + local-cache: true + + - name: Restore Android Symlinks + if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' || steps.cache-libv2ray-restore.outputs.cache-hit != 'true' + run: | + directory="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin" + find "$directory" -type l | while read link; do + current_target=$(readlink "$link") + new_target="$directory/$(basename "$current_target")" + ln -sf "$new_target" "$link" + echo "Changed $(basename "$link") from $current_target to $new_target" + done - name: Build libtun2socks if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' @@ -65,18 +91,6 @@ jobs: run: | cp -r ${{ github.workspace }}/build/AndroidLibV2rayLite/libs/* ${{ github.workspace }}/V2rayNG/app/libs/ - - name: Fetch AndroidLibXrayLite - run: | - cd ${{ github.workspace }}/build - git clone --depth=1 -b main https://github.com/2dust/AndroidLibXrayLite.git - - - name: Restore cached libv2ray - id: cache-libv2ray-restore - uses: actions/cache/restore@v4 - with: - path: ${{ github.workspace }}/build/AndroidLibXrayLite/ - key: libv2ray-${{ runner.os }}-${{ hashFiles('build/AndroidLibXrayLite/.git/refs/heads/main') }} - - name: Setup Golang if: steps.cache-libv2ray-restore.outputs.cache-hit != 'true' uses: actions/setup-go@v5 @@ -94,7 +108,7 @@ jobs: - name: Install gomobile if: steps.cache-libv2ray-restore.outputs.cache-hit != 'true' run: | - go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20240806205939-81131f6468ab + CGO_ENABLED=0 go install -trimpath -ldflags="-w -s" github.com/sagernet/gomobile/cmd/gomobile@v0.1.4 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - name: Build libv2ray @@ -103,7 +117,9 @@ jobs: cd ${{ github.workspace }}/build/AndroidLibXrayLite gomobile init go mod tidy -v - gomobile bind -v -androidapi 21 -ldflags='-s -w' ./ + gomobile bind -trimpath -buildvcs=false -v -androidapi 21 -ldflags='-s -w -buildid=' ./ + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - name: Save libv2ray if: steps.cache-libv2ray-restore.outputs.cache-hit != 'true'