mirror of
https://github.com/2dust/v2rayNG.git
synced 2025-06-28 12:19:52 +00:00
Build and cache libhysteria2.so (#4226)
* add submodule apernet/hysteria * remove libhysteria2 binary from git repo * libhysteria2.sh * ignore *.so
This commit is contained in:
parent
26bee229a1
commit
7dbda3cee7
9 changed files with 66 additions and 4 deletions
43
.github/workflows/build.yml
vendored
43
.github/workflows/build.yml
vendored
|
@ -17,6 +17,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
- name: Prepare build dir
|
||||
run: |
|
||||
|
@ -62,7 +64,6 @@ jobs:
|
|||
cd ${{ github.workspace }}/build/AndroidLibV2rayLite
|
||||
bash compile-tun2socks.sh
|
||||
tar -xvzf libtun2socks.so.tgz
|
||||
cp -r libs/* ${{ github.workspace }}/V2rayNG/app/libs/
|
||||
env:
|
||||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
|
||||
|
@ -75,7 +76,7 @@ jobs:
|
|||
|
||||
- name: Copy libtun2socks
|
||||
run: |
|
||||
cp -r ${{ github.workspace }}/build/AndroidLibV2rayLite/libs/* ${{ github.workspace }}/V2rayNG/app/libs/
|
||||
cp -r ${{ github.workspace }}/build/AndroidLibV2rayLite/libs ${{ github.workspace }}/V2rayNG/app
|
||||
|
||||
- name: Download libv2ray
|
||||
uses: robinraju/release-downloader@v1
|
||||
|
@ -85,6 +86,44 @@ jobs:
|
|||
fileName: 'libv2ray.aar'
|
||||
out-file-path: V2rayNG/app/libs/
|
||||
|
||||
- name: Restore cached libhysteria2
|
||||
id: cache-libhysteria2-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/hysteria/libs
|
||||
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }}-${{ hashFiles('libhysteria.sh') }}
|
||||
|
||||
- name: Fetch Go version from AndroidLibXrayLite
|
||||
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
GO_VERSION=$(curl -sL https://github.com/2dust/AndroidLibXrayLite/raw/refs/heads/main/go.mod | sed -n -E 's/.*go ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p')
|
||||
echo "Go version: $GO_VERSION"
|
||||
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Golang
|
||||
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '${{ env.GO_VERSION }}'
|
||||
|
||||
- name: Build libhysteria2
|
||||
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
bash libhysteria2.sh
|
||||
env:
|
||||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
|
||||
- name: Save libhysteria2
|
||||
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/hysteria/libs
|
||||
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }}-${{ hashFiles('libhysteria.sh') }}
|
||||
|
||||
- name: Copy libhysteria2
|
||||
run: |
|
||||
cp -r ${{ github.workspace }}/hysteria/libs ${{ github.workspace }}/V2rayNG/app
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,5 +3,4 @@
|
|||
V2rayNG/app/release/output.json
|
||||
.idea/
|
||||
.gradle/
|
||||
libtun2socks.so
|
||||
libhysteria2.so
|
||||
*.so
|
||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "hysteria"]
|
||||
path = hysteria
|
||||
url = https://github.com/apernet/hysteria
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
hysteria
Submodule
1
hysteria
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 15e31d48a09af0835773bd5c62cedbb3fc0e351d
|
20
libhysteria2.sh
Normal file
20
libhysteria2.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
targets=(
|
||||
"aarch64-linux-android21 arm64 arm64-v8a"
|
||||
"armv7a-linux-androideabi21 arm armeabi-v7a"
|
||||
"x86_64-linux-android21 amd64 x86_64"
|
||||
"i686-linux-android21 386 x86"
|
||||
)
|
||||
|
||||
cd "hysteria" || exit
|
||||
|
||||
for target in "${targets[@]}"; do
|
||||
IFS=' ' read -r ndk_target goarch abi <<< "$target"
|
||||
|
||||
echo "Building for ${abi} with ${ndk_target} (${goarch})"
|
||||
|
||||
CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/${ndk_target}-clang" CGO_ENABLED=1 CGO_LDFLAGS="-Wl,-z,max-page-size=16384" GOOS=android GOARCH=$goarch go build -o libs/$abi/libhysteria2.so -trimpath -ldflags "-s -w -buildid=" ./app
|
||||
|
||||
echo "Built libhysteria2.so for ${abi}"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue