Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit ff8d43f

Browse files
committed
fix(scripts): pretty output
1 parent 4000b0b commit ff8d43f

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

scripts/wrap-ndk.sh

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,67 @@ TARGET_LLVM_HOME="${TARGET_LLVM_HOME:-"${ANDROID_NDK}/toolchains/llvm/prebuilt/l
88
TARGET_CC="${TARGET_CC:-"${TARGET_LLVM_HOME}/bin/clang.bak"}"
99
TARGET_CXX="${TARGET_CXX:-"${TARGET_LLVM_HOME}/bin/clang++.bak"}"
1010

11-
reset=$'\x1b[0m'
12-
bold=$'\x1b[1m'
13-
underline=$'\x1b[4m'
14-
red=$'\x1b[31m'
11+
function underline() {
12+
echo -n $'\x1b[4m'
13+
echo -n "${@}"
14+
echo $'\x1b[24m'
15+
}
16+
17+
function error() {
18+
echo -n $'\x1b[1;91m'
19+
echo -n "${@}"
20+
echo $'\x1b[0m'
21+
}
22+
23+
function info() {
24+
echo -n $'\x1b[94m'
25+
echo -n "${@}"
26+
echo $'\x1b[0m'
27+
}
28+
29+
function copy() {
30+
info "$(underline "${1}") => $(underline "${2}")"
31+
cp "${1}" "${2}"
32+
}
1533

1634
function backup-clang() {
1735
if [[ ! -e "${TARGET_CC}" ]]; then
18-
echo "${underline}${TARGET_LLVM_HOME}/bin/clang${reset} => ${underline}${TARGET_CC}${reset}"
19-
cp "${TARGET_LLVM_HOME}/bin/clang" "${TARGET_CC}"
36+
copy "${TARGET_LLVM_HOME}/bin/clang" "${TARGET_CC}"
2037
else
21-
echo "${underline}${TARGET_CC}${reset} alreadly backed up"
38+
info "$(underline "${TARGET_CC}") alreadly backed up"
2239
fi
2340
if [[ ! -e "${TARGET_CXX}" ]]; then
24-
echo "${underline}${TARGET_LLVM_HOME}/bin/clang++${reset} => ${underline}${TARGET_CXX}${reset}"
25-
cp "${TARGET_LLVM_HOME}/bin/clang++" "${TARGET_CXX}"
41+
copy "${TARGET_LLVM_HOME}/bin/clang++" "${TARGET_CXX}"
2642
else
27-
echo "${underline}${TARGET_CXX}${reset} alreadly backed up"
43+
info "$(underline "${TARGET_CXX}") alreadly backed up"
2844
fi
2945
}
3046

3147
function recover-clang() {
3248
if [[ -e "${TARGET_CC}" ]]; then
33-
echo "${underline}${TARGET_CC}${reset} => ${underline}${TARGET_LLVM_HOME}/bin/clang${reset}"
34-
cp "${TARGET_CC}" "${TARGET_LLVM_HOME}/bin/clang"
49+
copy "${TARGET_CC}" "${TARGET_LLVM_HOME}/bin/clang"
3550
else
36-
echo "${bold}${red}${TARGET_CC} not found${reset}"
51+
error "${TARGET_CC} not found"
3752
fi
3853
if [[ -e "${TARGET_CXX}" ]]; then
39-
echo "${underline}${TARGET_CXX}${reset} => ${underline}${TARGET_LLVM_HOME}/bin/clang++${reset}"
40-
cp "${TARGET_CXX}" "${TARGET_LLVM_HOME}/bin/clang"
54+
copy "${TARGET_CXX}" "${TARGET_LLVM_HOME}/bin/clang"
4155
else
42-
echo "${bold}${red}${TARGET_CXX} not found${reset}"
56+
error "${TARGET_CXX} not found"
4357
fi
4458
}
4559

4660
function build() {
4761
backup-clang
48-
cmake -S "${WRAPPER_HOME}" -B "${WRAPPER_HOME}/build" --fresh \
49-
-DCMAKE_BUILD_TYPE=release \
62+
cmake -S "${WRAPPER_HOME}" -B "${WRAPPER_HOME}/build" \
5063
-DASAN=OFF \
51-
-DNDK=ON \
64+
-DCMAKE_BUILD_TYPE=release \
5265
-DLOG_LEVEL=OFF \
66+
-DNDK=ON \
5367
-DTARGET_CC="${TARGET_CC}" \
5468
-DTARGET_CXX="${TARGET_CXX}"
5569
make --directory "${WRAPPER_HOME}/build" --jobs
56-
cp "${WRAPPER_HOME}/build/base" "${TARGET_LLVM_HOME}/bin/clang"
57-
cp "${WRAPPER_HOME}/build/base++" "${TARGET_LLVM_HOME}/bin/clang++"
70+
copy "${WRAPPER_HOME}/build/base" "${TARGET_LLVM_HOME}/bin/clang"
71+
copy "${WRAPPER_HOME}/build/base++" "${TARGET_LLVM_HOME}/bin/clang++"
5872
}
5973

6074
case "${1:-"build"}" in

0 commit comments

Comments
 (0)