forked from huawei-noah/bolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarget.sh
62 lines (55 loc) · 1.76 KB
/
target.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
#!/bin/bash
targets=("android-aarch64" "android-armv7" "android-x86_64" \
"ios-aarch64" "ios-armv7" \
"linux-x86_64" "linux-x86_64_avx2" "linux-x86_64_avx512" "linux-x86_64_avx512_vnni" \
"linux-aarch64" "linux-aarch64_blank" "linux-arm_himix100" "linux-armv7_blank" "linux-arm_musleabi" \
"windows-x86_64" "windows-x86_64_avx2" "windows-x86_64_avx512" "windows-x86_64_avx512_vnni" \
"macos-x86_64" "macos-x86_64_avx2" "macos-aarch64")
print_targets() {
for((i=0; i<${#targets[@]}; i++)) do
element=${targets[i]};
cat <<EOF
${i} = ${element}
EOF
done
}
map_target() {
target=$1
for((i=0; i<${#targets[@]}; i++)) do
if [[ "${target}" == "$i" ]]; then
target=${targets[i]}
break;
fi
done
echo ${target}
}
check_target() {
if [[ ${1} == "" ]]; then
return 0;
fi
find_target=false
for element in ${targets[@]}; do
if [[ ${element} == ${1} ]]; then
find_target=true
fi
done
if [[ ${find_target} == false ]]; then
echo "[ERROR] not support to build on target ${1}, currently only support theses targets:"
print_targets
exit 1;
fi
}
check_getopt() {
getopt --test
if [[ "$?" != "4" ]]; then
echo -e "[ERROR] you are using BSD getopt, not GNU getopt. If you are runing on Mac, please use this command to install gnu-opt.\n brew install gnu-getopt && brew link --force gnu-getopt"
exit 1
fi
}
check_sed() {
out=`sed --version | head -1`
if [[ ! ${out} =~ "GNU" ]]; then
echo -e "[ERROR] you are using Mac sed, not GNU sed. If you are runing on Mac, please use this command to install gnu-sed.\n brew install gnu-sed && alias sed=gsed"
exit 1
fi
}