-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-android
executable file
·84 lines (73 loc) · 2.35 KB
/
build-android
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
#!/bin/bash
# tdiff - tree diffs
# build-android
# Copyright (C) 2019, 2024 Philippe Troin <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Use this script to build tdiff for all support Android targets.
# Requires Android NDK r19 or later (tested with r19c).
progname="${0##*/}"
buildarch="$("$(dirname "$0")"/config.aux/config.guess)"
case "$buildarch" in
x86_64-*linux*) ;;
*)
echo 1>&2 "$progname: unsupported architecture: $buildarch"
exit 1
;;
esac
build() {
local arch="$1" ndkdir="$2" sdk="$3" suffix="$4"
case "$arch" in
armv7a-linux-androideabi) tarch=arm-linux-androideabi;;
*) tarch="$arch";;
esac
export TOOLCHAIN="$ndkdir/toolchains/llvm/prebuilt/linux-x86_64"
export AR="$TOOLCHAIN/bin/$tarch-ar"
export AS="$TOOLCHAIN/bin/$tarch-as"
export CC="$TOOLCHAIN/bin/$arch$sdk-clang"
export CXX="$TOOLCHAIN/bin/$arch$sdk-clang++"
export LD="$TOOLCHAIN/bin/$tarch-ld"
export RANLIB="$TOOLCHAIN/bin/$tarch-ranlib"
export STRIP="$TOOLCHAIN/bin/$tarch-strip"
./configure --host "$arch" --enable-compiler-warnings --prefix="$PWD/build-$arch" CFLAGS="-static"
make install-strip
mv "build-$arch/bin/tdiff" tdiff"$suffix"
make distclean
rm -fr "build-$arch"
}
sdk=30
if [[ $# -eq 0 || $# -gt 2 ]]
then
echo 1>&2 "usage: $progname <ndk-base-dir> [<android-sdk>]"
echo 1>&2 " <android-sdk> defaults to $sdk"
exit 1
fi
ndkdir="$1"
if [[ $# -ge 2 ]]
then
sdk="$2"
fi
make distclean || :
for arch in aarch64-linux-android \
armv7a-linux-androideabi \
i686-linux-android \
x86_64-linux-android
do
sarch="${arch%-linux-*}"
case "$sarch" in
armv7*) sarch=armv7;;
armv8*|aarch64) sarch=armv8;;
esac
build "$arch" "$ndkdir" "$sdk" "-$sarch"
done