-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_info.sh
executable file
·122 lines (105 loc) · 2.22 KB
/
gen_info.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
#/usr/bin/env bash
toolchain_to_arch() {
case $1 in
arm-*)
echo arm
;;
x86-*)
echo x86
;;
mipsel-*)
echo mips
;;
aarch64-*)
echo arm64
;;
x86_64-linux-android-*)
echo x86_64 | sed -e 's/-linux-android//'
;;
x86_64-*)
echo x86_64
;;
mips64el-*)
echo mips64
;;
*)
echo "Invalid toolchain $1"
exit 1
;;
esac
}
base="https://dl.google.com/android/repository"
output="ndk_info.yml"
list="ndks.sha"
for file in $(awk '{print $2}' < $list); do
wget -N "$base/$file"
done
shasum -c $list
echo "# This configuration was autogenerated by gen_info.sh" > $output
while read line; do
sha=$(awk '{print $1}' <<< $line)
file=$(awk '{print $2}' <<< $line)
folder=${file%-linux-x86_64.zip}
ndk_name=${folder#android-ndk-}
echo "$ndk_name:" >> $output
echo " url: $base/$file" >> $output
echo " sha: $sha" >> $output
platforms=$(tar -tf $file | grep "$folder/platforms/android-" | \
awk -F/ '{print $3}' | uniq | gsort -V)
toolchains=$(tar -tf $file | grep -E "$folder/toolchains.*bin" | \
awk -F/ '{print $3}' | uniq | gsort -V)
declare min0
declare min1
check_min=0
# TODO: Replace these repetitions with a fallthrough when on bash > 4
case "$ndk_name" in
*r12b*)
min0=9
min1=21
check_min=1
;;
*r13b*)
min0=9
min1=21
check_min=1
;;
*r14b*)
min0=9
min1=21
check_min=1
;;
*r15c*)
min0=14
min1=21
check_min=1
;;
*r16*)
min0=14
min1=21
check_min=1
;;
esac
echo " toolchains:" >> $output
for t in $toolchains; do
echo " - $t" >> $output
done
echo " platforms:" >> $output
for p in $platforms; do
echo " $p:" >> $output
for t in $toolchains; do
if [[ $check_min != 0 ]]; then
version=${p#"android-"}
arch=$(toolchain_to_arch "$t")
min=$min1
if [[ "$arch" =~ ^(arm|mips|x86)$ ]]; then
min=9
fi
if (( $version >= $min )); then
echo " - $t" >> $output
fi
else
echo " - $t" >> $output
fi
done
done
done < $list