Skip to content

Commit

Permalink
Sagernet (#4194)
Browse files Browse the repository at this point in the history
* switch to sagernet/gomobile

* arguments for rb

* match ndk version

* with more options

* nttld/setup-ndk#518
  • Loading branch information
UjuiUjuMandan authored Dec 28, 2024
1 parent f96073a commit affb107
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit affb107

Please sign in to comment.