Skip to content

Commit f7bf0b8

Browse files
committed
Migrate to go mod
1 parent 4a838a3 commit f7bf0b8

File tree

9 files changed

+43
-81
lines changed

9 files changed

+43
-81
lines changed

.circleci/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ jobs:
1212
- run: git submodule update --init --recursive
1313
- restore_cache:
1414
key: jars-{{ checksum "build.gradle" }}
15+
- restore_cache:
16+
key: go
1517
- run:
1618
name: Run Build and Tests
1719
command: ./gradlew assembleDebug check
20+
- save_cache:
21+
paths:
22+
- ~/go
23+
key: go
1824
- save_cache:
1925
paths:
2026
- ~/.gradle

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "app/src/v2ray-plugin"]
2-
path = app/src/v2ray-plugin
3-
url = https://github.com/madeye/v2ray-plugin
1+
[submodule "app/src/main/go/v2ray-plugin"]
2+
path = app/src/main/go/v2ray-plugin
3+
url = https://github.com/shadowsocks/v2ray-plugin.git

app/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@
33
# no tests written yet
44
/src/androidTest
55
/src/test
6-
/src/bin
7-
/src/pkg
8-
/src/src
9-
/.deps

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ android {
4141
universalApk true
4242
}
4343
}
44-
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "src/bin")
44+
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "build/go")
4545
}
4646

4747
task goBuild(type: Exec) {
4848
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
4949
println "Warning: Building on Windows is not supported"
5050
} else {
51-
executable "sh"
52-
args "-c", "src/make.bash " + minSdkVersion
51+
executable "/bin/bash"
52+
args "go-build.bash", minSdkVersion
5353
environment "ANDROID_HOME", android.sdkDirectory
5454
environment "ANDROID_NDK_HOME", android.ndkDirectory
5555
}

app/go-build.bash

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
[[ -z "${ANDROID_NDK_HOME}" ]] && ANDROID_NDK_HOME="${ANDROID_HOME}/ndk-bundle"
4+
TOOLCHAIN="$(find ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/* -maxdepth 1 -type d -print -quit)/bin"
5+
ABIS=(armeabi-v7a arm64-v8a x86 x86_64)
6+
GO_ARCHS=('arm GOARM=7' arm64 386 amd64)
7+
CLANG_ARCHS=(armv7a-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android)
8+
STRIP_ARCHS=(arm-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android)
9+
10+
MIN_API="$1"
11+
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
12+
OUT_DIR="$ROOT/build/go"
13+
14+
cd "$ROOT/src/main/go/v2ray-plugin"
15+
BIN="libv2ray.so"
16+
for i in "${!ABIS[@]}"; do
17+
ABI="${ABIS[$i]}"
18+
[[ -f "${OUT_DIR}/${ABI}/${BIN}" ]] && continue
19+
echo "Build ${BIN} ${ABI}"
20+
mkdir -p ${OUT_DIR}/${ABI} \
21+
&& env \
22+
CGO_ENABLED=1 CC="${TOOLCHAIN}/${CLANG_ARCHS[$i]}${MIN_API}-clang" \
23+
GOOS=android GOARCH=${GO_ARCHS[$i]} \
24+
go build -v -ldflags='-s -w' -o "${OUT_DIR}/unstripped" \
25+
&& "${TOOLCHAIN}/${STRIP_ARCHS[$i]}-strip" "${OUT_DIR}/unstripped" -o "${OUT_DIR}/${ABI}/${BIN}" \
26+
|| exit -1
27+
rm "${OUT_DIR}/unstripped"
28+
done
29+
30+
cd "$ROOT"

app/src/clean.bash

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/src/main/go/v2ray-plugin

Submodule v2ray-plugin added at d3c1201

app/src/make.bash

Lines changed: 0 additions & 62 deletions
This file was deleted.

app/src/v2ray-plugin

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)