diff --git a/core/build.gradle b/core/build.gradle index 14541e0e..1317d12e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -37,6 +37,18 @@ task goBuild(type: Exec) { args "-c", "src/overture/make.bash " + minSdkVersion } +task goClean(type: Exec) { + executable "sh" + args "-c", "src/overture/clean.bash" +} + +tasks.whenTaskAdded { task -> + if (task.name == 'externalNativeBuildDebug' || + task.name == 'externalNativeBuildRelease') { + task.dependsOn(goBuild) + } +} + dependencies { api project(':plugin') testImplementation "junit:junit:$junitVersion" diff --git a/core/src/overture/clean.bash b/core/src/overture/clean.bash new file mode 100755 index 00000000..b75dc943 --- /dev/null +++ b/core/src/overture/clean.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +TARGET=$DIR/../main/jni/overture +DEPS=$DIR/.deps + +rm -rf $DEPS +rm -rf $DIR/go/bin +rm -rf $DIR/bin +rm -rf $TARGET + +echo "Successfully clean overture" diff --git a/core/src/overture/make.bash b/core/src/overture/make.bash index 6c812f81..7310a61a 100755 --- a/core/src/overture/make.bash +++ b/core/src/overture/make.bash @@ -63,19 +63,25 @@ pushd $GOPATH/src/github.com/shadowsocks/overture/main godep restore echo "Cross compile overture for arm" -try env CGO_ENABLED=1 CC=$ANDROID_ARM_CC GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-s -w" -try $ANDROID_ARM_STRIP main -try mv main $TARGET/armeabi-v7a/liboverture.so +if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ]; then + try env CGO_ENABLED=1 CC=$ANDROID_ARM_CC GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-s -w" + try $ANDROID_ARM_STRIP main + try mv main $TARGET/armeabi-v7a/liboverture.so +fi echo "Cross compile overture for arm64" -try env CGO_ENABLED=1 CC=$ANDROID_ARM64_CC GOOS=android GOARCH=arm64 go build -ldflags="-s -w" -try $ANDROID_ARM64_STRIP main -try mv main $TARGET/arm64-v8a/liboverture.so +if [ ! -f "$TARGET/arm64-v8a/liboverture.so" ]; then + try env CGO_ENABLED=1 CC=$ANDROID_ARM64_CC GOOS=android GOARCH=arm64 go build -ldflags="-s -w" + try $ANDROID_ARM64_STRIP main + try mv main $TARGET/arm64-v8a/liboverture.so +fi echo "Cross compile overture for x86" -try env CGO_ENABLED=1 CC=$ANDROID_X86_CC GOOS=android GOARCH=386 go build -ldflags="-s -w" -try $ANDROID_X86_STRIP main -try mv main $TARGET/x86/liboverture.so +if [ ! -f "$TARGET/x86/liboverture.so" ]; then + try env CGO_ENABLED=1 CC=$ANDROID_X86_CC GOOS=android GOARCH=386 go build -ldflags="-s -w" + try $ANDROID_X86_STRIP main + try mv main $TARGET/x86/liboverture.so +fi popd