Commit e005c81e authored by Mygod's avatar Mygod

Update to NDK r19

Standalone toolchains are no longer required. This should speed up builds and decrease space required for building this app.

Fix #2022.
parent 41990078
ARG ndk_version=android-ndk-r19-beta2
FROM circleci/android:api-28-ndk FROM circleci/android:api-28-ndk
RUN \ RUN \
......
...@@ -15,7 +15,7 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Kotlin. ...@@ -15,7 +15,7 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Kotlin.
* JDK 1.8 * JDK 1.8
* Go 1.11+ * Go 1.11+
* Android SDK * Android SDK
- Android NDK r16+ - Android NDK r19+
### BUILD ### BUILD
......
...@@ -18,7 +18,7 @@ android { ...@@ -18,7 +18,7 @@ android {
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
arguments "-j${Runtime.runtime.availableProcessors()}" arguments "-j${Runtime.runtime.availableProcessors()}"
} }
} }
......
#!/bin/bash #!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DEPS=$DIR/.deps
rm -rf $DEPS rm -rf $DIR/.deps
rm -rf $DIR/go/bin
rm -rf $DIR/bin rm -rf $DIR/bin
echo "Successfully clean overture" echo "Successfully clean overture"
...@@ -5,49 +5,18 @@ function try () { ...@@ -5,49 +5,18 @@ function try () {
} }
[ -z "$ANDROID_NDK_HOME" ] && ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle [ -z "$ANDROID_NDK_HOME" ] && ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MIN_API=$1 MIN_API=$1
TARGET=$DIR/bin TARGET=$DIR/bin
DEPS=$DIR/.deps
ANDROID_ARM_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-arm try mkdir -p $TARGET/armeabi-v7a $TARGET/x86 $TARGET/arm64-v8a $TARGET/x86_64
ANDROID_ARM64_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-arm64
ANDROID_X86_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-x86
ANDROID_ARM_CC=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-clang
ANDROID_ARM_STRIP=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-strip
ANDROID_ARM64_CC=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-clang
ANDROID_ARM64_STRIP=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-strip
ANDROID_X86_CC=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-clang
ANDROID_X86_STRIP=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-strip
try mkdir -p $DEPS $TARGET/armeabi-v7a $TARGET/x86 $TARGET/arm64-v8a
if [ ! -f "$ANDROID_ARM_CC" ]; 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 [ ! -f "$ANDROID_ARM64_CC" ]; then
echo "Make standalone toolchain for ARM64 arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm64 \
--api $MIN_API --install-dir $ANDROID_ARM64_TOOLCHAIN
fi
if [ ! -f "$ANDROID_X86_CC" ]; 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
export GOPATH=$DIR export GOPATH=$DIR
if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ] || [ ! -f "$TARGET/arm64-v8a/liboverture.so" ] || if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ] || [ ! -f "$TARGET/arm64-v8a/liboverture.so" ] ||
[ ! -f "$TARGET/x86/liboverture.so" ]; then [ ! -f "$TARGET/x86/liboverture.so" ] || [ ! -f "$TARGET/x86_64/liboverture.so" ]; then
pushd $GOPATH/src/github.com/shadowsocks/overture/main pushd $GOPATH/src/github.com/shadowsocks/overture/main
...@@ -56,25 +25,32 @@ if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ] || [ ! -f "$TARGET/arm64-v8a/li ...@@ -56,25 +25,32 @@ if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ] || [ ! -f "$TARGET/arm64-v8a/li
echo "Cross compile overture for arm" echo "Cross compile overture for arm"
if [ ! -f "$TARGET/armeabi-v7a/liboverture.so" ]; then 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 env CGO_ENABLED=1 CC=$TOOLCHAIN/armv7a-linux-androideabi${MIN_API}-clang GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-s -w"
try $ANDROID_ARM_STRIP main try $TOOLCHAIN/arm-linux-androideabi-strip main
try mv main $TARGET/armeabi-v7a/liboverture.so try mv main $TARGET/armeabi-v7a/liboverture.so
fi fi
echo "Cross compile overture for arm64" echo "Cross compile overture for arm64"
if [ ! -f "$TARGET/arm64-v8a/liboverture.so" ]; then 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 env CGO_ENABLED=1 CC=$TOOLCHAIN/aarch64-linux-android${MIN_API}-clang GOOS=android GOARCH=arm64 go build -ldflags="-s -w"
try $ANDROID_ARM64_STRIP main try $TOOLCHAIN/aarch64-linux-android-strip main
try mv main $TARGET/arm64-v8a/liboverture.so try mv main $TARGET/arm64-v8a/liboverture.so
fi fi
echo "Cross compile overture for x86" echo "Cross compile overture for 386"
if [ ! -f "$TARGET/x86/liboverture.so" ]; then 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 env CGO_ENABLED=1 CC=$TOOLCHAIN/i686-linux-android${MIN_API}-clang GOOS=android GOARCH=386 go build -ldflags="-s -w"
try $ANDROID_X86_STRIP main try $TOOLCHAIN/i686-linux-android-strip main
try mv main $TARGET/x86/liboverture.so try mv main $TARGET/x86/liboverture.so
fi fi
echo "Cross compile overture for amd64"
if [ ! -f "$TARGET/x86_64/liboverture.so" ]; then
try env CGO_ENABLED=1 CC=$TOOLCHAIN/x86_64-linux-android${MIN_API}-clang GOOS=android GOARCH=amd64 go build -ldflags="-s -w"
try $TOOLCHAIN/x86_64-linux-android-strip main
try mv main $TARGET/x86_64/liboverture.so
fi
popd popd
fi fi
......
...@@ -43,8 +43,6 @@ android { ...@@ -43,8 +43,6 @@ android {
splits { splits {
abi { abi {
enable true enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86'
universalApk true universalApk true
} }
} }
...@@ -72,7 +70,7 @@ repositories { ...@@ -72,7 +70,7 @@ repositories {
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3] ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant -> if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
......
...@@ -4,8 +4,10 @@ release=$1 ...@@ -4,8 +4,10 @@ release=$1
cp mobile/build/outputs/apk/release/mobile-armeabi-v7a-release.apk shadowsocks-armeabi-v7a-${release}.apk cp mobile/build/outputs/apk/release/mobile-armeabi-v7a-release.apk shadowsocks-armeabi-v7a-${release}.apk
cp mobile/build/outputs/apk/release/mobile-arm64-v8a-release.apk shadowsocks-arm64-v8a-${release}.apk cp mobile/build/outputs/apk/release/mobile-arm64-v8a-release.apk shadowsocks-arm64-v8a-${release}.apk
cp mobile/build/outputs/apk/release/mobile-x86-release.apk shadowsocks-x86-${release}.apk cp mobile/build/outputs/apk/release/mobile-x86-release.apk shadowsocks-x86-${release}.apk
cp mobile/build/outputs/apk/release/mobile-x86_64-release.apk shadowsocks-x86_64-${release}.apk
cp mobile/build/outputs/apk/release/mobile-universal-release.apk shadowsocks--universal-${release}.apk cp mobile/build/outputs/apk/release/mobile-universal-release.apk shadowsocks--universal-${release}.apk
cp tv/build/outputs/apk/release/tv-armeabi-v7a-release.apk shadowsocks-tv-armeabi-v7a-${release}.apk cp tv/build/outputs/apk/release/tv-armeabi-v7a-release.apk shadowsocks-tv-armeabi-v7a-${release}.apk
cp tv/build/outputs/apk/release/tv-arm64-v8a-release.apk shadowsocks-tv-arm64-v8a-${release}.apk cp tv/build/outputs/apk/release/tv-arm64-v8a-release.apk shadowsocks-tv-arm64-v8a-${release}.apk
cp tv/build/outputs/apk/release/tv-x86-release.apk shadowsocks-tv-x86-${release}.apk cp tv/build/outputs/apk/release/tv-x86-release.apk shadowsocks-tv-x86-${release}.apk
cp tv/build/outputs/apk/release/tv-x86_64-release.apk shadowsocks-tv-x86_64-${release}.apk
cp tv/build/outputs/apk/release/tv-universal-release.apk shadowsocks-tv--universal-${release}.apk cp tv/build/outputs/apk/release/tv-universal-release.apk shadowsocks-tv--universal-${release}.apk
...@@ -43,8 +43,6 @@ android { ...@@ -43,8 +43,6 @@ android {
splits { splits {
abi { abi {
enable true enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86'
universalApk true universalApk true
} }
} }
...@@ -61,7 +59,7 @@ dependencies { ...@@ -61,7 +59,7 @@ dependencies {
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3] ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant -> if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment