-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·122 lines (102 loc) · 2.86 KB
/
build.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
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
while getopts "a:c:" opt; do
case $opt in
a)
ARCH=$OPTARG ;;
c)
FLAVOR=$OPTARG ;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [[ -z "${ARCH}" ]] ; then
echo 'You need to input arch with -a ARCH.'
echo 'Supported archs are:'
echo -e '\tarm arm64 x86 x86_64'
exit 1
fi
source ../../AVP/android-setup-light.sh
LOCAL_PATH=$($READLINK -f .)
ANDROID_API=21
ARCH_CONFIG_OPT=
case "${ARCH}" in
'arm')
ARCH_TRIPLET='arm-linux-androideabi'
ARCH_TRIPLET_VARIANT='armv7a-linux-androideabi'
ABI='armeabi-v7a'
CPU_FAMILY='arm'
ARCH_CFLAGS='-march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb'
ARCH_LDFLAGS='-march=armv7-a -Wl,--fix-cortex-a8'
B_ARCH='arm'
B_ADDRESS_MODEL=32 ;;
'arm64')
ARCH_TRIPLET='aarch64-linux-android'
ARCH_TRIPLET_VARIANT=$ARCH_TRIPLET
ABI='arm64-v8a'
CPU_FAMILY='aarch64'
B_ARCH='arm'
B_ADDRESS_MODEL=64 ;;
'x86')
ARCH_TRIPLET='i686-linux-android'
ARCH_TRIPLET_VARIANT=$ARCH_TRIPLET
ARCH_CONFIG_OPT='--disable-asm'
ARCH_CFLAGS='-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32'
ABI='x86'
CPU_FAMILY='x86'
B_ARCH='x86'
B_ADDRESS_MODEL=32 ;;
'x86_64')
ARCH_TRIPLET='x86_64-linux-android'
ARCH_TRIPLET_VARIANT=$ARCH_TRIPLET
ABI='x86_64'
CPU_FAMILY='x86_64'
ARCH_CFLAGS='-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel'
B_ARCH='x86'
B_ADDRESS_MODEL=64 ;;
*)
echo "Arch ${ARCH} is not supported."
exit 1 ;;
esac
os=$(uname -s | tr '[:upper:]' '[:lower:]')
CROSS_PREFIX="${NDK_PATH}"/toolchains/llvm/prebuilt/${os}-x86_64/bin
set -eu
dir_name=build
echo "Generating toolchain description..."
user_config=android_cross_${ABI}.txt
rm -f $user_config
cat <<EOF > $user_config
[binaries]
name = 'android'
c = '${CROSS_PREFIX}/${ARCH_TRIPLET_VARIANT}${ANDROID_API}-clang'
cpp = '${CROSS_PREFIX}/${ARCH_TRIPLET_VARIANT}${ANDROID_API}-clang++'
ar = '${CROSS_PREFIX}/llvm-ar'
ld = '${CROSS_PREFIX}/${ARCH_TRIPLET}-ld'
strip = '${CROSS_PREFIX}/${ARCH_TRIPLET}-strip'
[properties]
needs_exe_wrapper = true
[host_machine]
system = 'linux'
cpu_family = '${CPU_FAMILY}'
cpu = '${CPU_FAMILY}'
endian = 'little'
EOF
if [ ! -d "${dir_name}-${ABI}" ]; then
mkdir ${dir_name}-${ABI}
else
echo "Already built for ${ABI}"
exit 0
fi
if [ ! -d dav1d ]; then
git -c http.sslVerify=false clone https://code.videolan.org/videolan/dav1d -b 1.3.0
fi
cd dav1d
#git checkout 191f79d5a914c647fa941ee8c72f807ca2bd1fcb
echo "Build: calling meson..."
meson --buildtype release --cross-file ../android_cross_${ABI}.txt -Denable_tools=false -Denable_tests=false ../${dir_name}-${ABI}
echo "Building with Ninja"
#cd ${dir_name}-${ABI}
ninja -C ../${dir_name}-${ABI}
$SED -i 's:libdav1d\.so\.[0-9]:libdav1d\.so\x0\x0:' $($READLINK -f ../${dir_name}-${ABI}/src/libdav1d.so)
echo "Done!"