forked from SaeedDev94/Xray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildXrayCore.sh
executable file
·57 lines (48 loc) · 1.12 KB
/
buildXrayCore.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
TARGET="$1"
ARCHS=(arm arm64 386 amd64)
DEST="../app/libs"
is_in_array() {
local value="$1"
local array=("${@:2}")
for item in "${array[@]}"; do
if [[ "$item" == "$value" ]]; then
return 0
fi
done
return 1
}
check_target() {
if ! is_in_array "$TARGET" "${ARCHS[@]}"; then
echo "Not supported"
exit 1
fi
}
prepare_go() {
echo "Install dependencies"
cd XrayCore
# rm go*
# go mod init XrayCore
# go mod edit -replace github.com/xtls/xray-core=./Xray-core
# go mod edit -replace github.com/xtls/libxray=./libXray
# go mod tidy
# go get golang.org/x/mobile
# go get google.golang.org/genproto
go install golang.org/x/mobile/cmd/[email protected]
go mod download
}
build_android() {
echo "Building XrayCore for $TARGET"
rm -f "$DEST/XrayCore*"
gomobile init
gomobile bind -o "$DEST/XrayCore.aar" -androidapi 26 -target "android/$TARGET" -ldflags="-buildid=" -trimpath
}
refresh_dependencies() {
echo "Gradle: refresh dependencies"
cd ..
./gradlew --refresh-dependencies clean
}
check_target
prepare_go
build_android
refresh_dependencies