Skip to content

Commit

Permalink
Add build files for overture
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Apr 9, 2017
1 parent adb7285 commit 80411c6
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions mobile/src/overture/go
Submodule go added at 86036d
82 changes: 82 additions & 0 deletions mobile/src/overture/make.bash
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions mobile/src/overture/src/github.com/shadowsocks/overture
Submodule overture added at 7263b8

0 comments on commit 80411c6

Please sign in to comment.