forked from deltachat/deltachat-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ndk-make-fast.sh
executable file
·110 lines (92 loc) · 3.32 KB
/
ndk-make-fast.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
# If you want to, you can run this script with instead of ndk-make.sh your architecture as an argument
# to speed up compilation by factor 4 (will not work on macOS and might not work for other reasons):
#
# ./ndk-make.sh arm64-v8a
#
# Possible values are armeabi-v7a, arm64-v8a, x86 and x86_64.
# You should be able to find out your architecture by running:
#
# adb shell uname -m
#
# or:
#
# adb shell cat /proc/cpuinfo
#
# The values in the following lines mean the same:
#
# armeabi-v7a, armv7 and arm
# arm64-v8a, aarch64 and arm64
# x86 and i686
# (there are no synonyms for x86_64)
#
#
# If you put this in your .bashrc, then you can directly build and deploy DeltaChat from the jni/deltachat-core-rust directory by typing nmake():
# nmake() {sh -c 'cd ../..; ./ndk-make-fast.sh arm64-v8a && ./gradlew installFatDebug; notify-send "install finished" }
set -e
echo "starting time: `date`"
# Check if the argument is a correct architecture:
if test $1 && echo "armeabi-v7a arm64-v8a x86 x86_64 all" | grep -vwq $1; then
echo "Architecture '$1' not known, possible values are armeabi-v7a, arm64-v8a, x86, x86_64 and all."
exit
fi
if test -z $1; then
echo "**stop ** ==> please enter at least one argument: [armeabi-v7a|arm64-v8a|x86|x86_64|all]"
exit
fi
cd jni
rm -f armeabi-v7a/*
rm -f arm64-v8a/*
rm -f x86/*
rm -f x86_64/*
mkdir -p armeabi-v7a
mkdir -p arm64-v8a
mkdir -p x86
mkdir -p x86_64
cd deltachat-core-rust
# fix build on MacOS Catalina
unset CPATH
if test $1 = all || test $1 = armeabi-v7a; then
echo "-- cross compiling to armv7-linux-androideabi (arm) --"
export CFLAGS=-D__ANDROID_API__=16
TARGET_CC=armv7a-linux-androideabi16-clang \
cargo +`cat rust-toolchain` build --release --target armv7-linux-androideabi -p deltachat_ffi
cp target/armv7-linux-androideabi/release/libdeltachat.a ../armeabi-v7a
fi
if test $1 = all || test $1 = arm64-v8a; then
echo "-- cross compiling to aarch64-linux-android (arm64) --"
export CFLAGS=-D__ANDROID_API__=21
TARGET_CC=aarch64-linux-android21-clang \
cargo +`cat rust-toolchain` build --release --target aarch64-linux-android -p deltachat_ffi
cp target/aarch64-linux-android/release/libdeltachat.a ../arm64-v8a
fi
if test $1 = all || test $1 = x86; then
echo "-- cross compiling to i686-linux-android (x86) --"
export CFLAGS=-D__ANDROID_API__=16
TARGET_CC=i686-linux-android16-clang \
cargo +`cat rust-toolchain` build --release--target i686-linux-android -p deltachat_ffi
cp target/i686-linux-android/release/libdeltachat.a ../x86
fi
if test $1 = all || test $1 = x86_64; then
echo "-- cross compiling to x86_64-linux-android (x86_64) --"
export CFLAGS=-D__ANDROID_API__=21
TARGET_CC=x86_64-linux-android21-clang \
cargo +`cat rust-toolchain` build --release --target x86_64-linux-android -p deltachat_ffi
cp target/x86_64-linux-android/release/libdeltachat.a ../x86_64
fi
echo -- ndk-build --
cd ..
# Set the right arch in Application.mk:
oldDotMk="$(cat Application.mk)"
if test $1 = all; then
# We are compiling for all architectures:
sed -i "s/APP_ABI.*/APP_ABI := armeabi-v7a arm64-v8a x86 x86_64/g" Application.mk
else
sed -i "s/APP_ABI.*/APP_ABI := $1/g" Application.mk
fi
cd ..
ndk-build
cd jni
# Restore old Application.mk:
echo "$oldDotMk" > Application.mk
echo "ending time: `date`"