diff --git a/.gitignore b/.gitignore index 87b1bdf9..5edaaac3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,15 @@ local.sbt mobile/src/main/libs mobile/src/main/obj mobile/src/main/jni/overture + +mobile/src/overture/.deps +mobile/src/overture/bin +mobile/src/overture/pkg + +mobile/src/overture/src/github.com/Sirupsen +mobile/src/overture/src/github.com/mattn +mobile/src/overture/src/github.com/miekg +mobile/src/overture/src/github.com/shawn1m +mobile/src/overture/src/github.com/tools +mobile/src/overture/src/golang.org +mobile/src/overture/src/gopkg.in diff --git a/.gitmodules b/.gitmodules index d74fc99e..092ed998 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,3 +33,9 @@ [submodule "mobile/src/main/jni/libudns"] path = mobile/src/main/jni/libudns url = https://github.com/shadowsocks/libudns.git +[submodule "mobile/src/overture/go"] + path = mobile/src/overture/go + url = https://github.com/shadowsocks/go.git +[submodule "mobile/src/overture/src/github.com/shadowsocks/overture"] + path = mobile/src/overture/src/github.com/shadowsocks/overture + url = https://github.com/shadowsocks/overture.git diff --git a/mobile/src/overture/go b/mobile/src/overture/go new file mode 160000 index 00000000..86036dcc --- /dev/null +++ b/mobile/src/overture/go @@ -0,0 +1 @@ +Subproject commit 86036dcce8fc7e2bd772969e6af56776cc9d8d53 diff --git a/mobile/src/overture/make.bash b/mobile/src/overture/make.bash new file mode 100755 index 00000000..bf008d15 --- /dev/null +++ b/mobile/src/overture/make.bash @@ -0,0 +1,82 @@ +#!/bin/bash + +function try () { +"$@" || exit -1 +} + +[ -z "$ANDROID_NDK_HOME" ] && ANDROID_NDK_HOME=~/android-ndk-r12b + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +MIN_API=$1 +TARGET=$DIR/../main/jni/overture +DEPS=$DIR/.deps + +ANDROID_ARM_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-arm +ANDROID_ARM64_TOOLCHAIN=$DEPS/android-toolchain-21-arm64 +ANDROID_X86_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-x86 + +ANDROID_ARM_CC=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-gcc +ANDROID_ARM_STRIP=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-strip + +ANDROID_ARM64_CC=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-gcc +ANDROID_ARM64_STRIP=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-strip + +ANDROID_X86_CC=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-gcc +ANDROID_X86_STRIP=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-strip + +try mkdir -p $DEPS $TARGET/armeabi-v7a $TARGET/x86 $TARGET/arm64-v8a + +if [ ! -d "$ANDROID_ARM_TOOLCHAIN" ]; then + echo "Make standalone toolchain for ARM arch" + $ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm \ + --api $MIN_API --install-dir $ANDROID_ARM_TOOLCHAIN +fi + +if [ ! -d "$ANDROID_ARM64_TOOLCHAIN" ]; then + echo "Make standalone toolchain for ARM64 arch" + $ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm64 \ + --api 21 --install-dir $ANDROID_ARM64_TOOLCHAIN +fi + +if [ ! -d "$ANDROID_X86_TOOLCHAIN" ]; then + echo "Make standalone toolchain for X86 arch" + $ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch x86 \ + --api $MIN_API --install-dir $ANDROID_X86_TOOLCHAIN +fi + +if [ ! -d "$DIR/go/bin" ]; then + echo "Build the custom go" + + pushd $DIR/go/src + try ./make.bash + popd +fi + +export GOROOT=$DIR/go +export GOPATH=$DIR +export PATH=$GOROOT/bin:$GOPATH/bin:$PATH + +echo "Get dependences for overture" +go get -u github.com/tools/godep + +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 + +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 + +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 + +popd + +echo "Successfully build overture" diff --git a/mobile/src/overture/src/github.com/shadowsocks/overture b/mobile/src/overture/src/github.com/shadowsocks/overture new file mode 160000 index 00000000..7263b82d --- /dev/null +++ b/mobile/src/overture/src/github.com/shadowsocks/overture @@ -0,0 +1 @@ +Subproject commit 7263b82d2eba2e28d70766aed36ffbc7cf0e1451