Skip to content

Commit a6f1db1

Browse files
committed
[update] : Use msg.sh to output message (fullbuild.sh)
1 parent 1dbae2d commit a6f1db1

File tree

1 file changed

+29
-119
lines changed

1 file changed

+29
-119
lines changed

tools/fullbuild.sh

Lines changed: 29 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -27,133 +27,43 @@ retry=5
2727

2828
all_channel=false
2929

30-
# Color echo
31-
# usage: echo_color -b <backcolor> -t <textcolor> -d <decoration> [Text]
32-
#
33-
# Text Color
34-
# 30 => Black
35-
# 31 => Red
36-
# 32 => Green
37-
# 33 => Yellow
38-
# 34 => Blue
39-
# 35 => Magenta
40-
# 36 => Cyan
41-
# 37 => White
42-
#
43-
# Background color
44-
# 40 => Black
45-
# 41 => Red
46-
# 42 => Green
47-
# 43 => Yellow
48-
# 44 => Blue
49-
# 45 => Magenta
50-
# 46 => Cyan
51-
# 47 => White
52-
#
53-
# Text decoration
54-
# You can specify multiple decorations with ;.
55-
# 0 => All attributs off (ノーマル)
56-
# 1 => Bold on (太字)
57-
# 4 => Underscore (下線)
58-
# 5 => Blink on (点滅)
59-
# 7 => Reverse video on (色反転)
60-
# 8 => Concealed on
61-
62-
echo_color() {
63-
local backcolor
64-
local textcolor
65-
local decotypes
66-
local echo_opts
67-
local arg
68-
local OPTIND
69-
local OPT
70-
71-
echo_opts="-e"
72-
73-
while getopts 'b:t:d:n' arg; do
74-
case "${arg}" in
75-
b) backcolor="${OPTARG}" ;;
76-
t) textcolor="${OPTARG}" ;;
77-
d) decotypes="${OPTARG}" ;;
78-
n) echo_opts="-n -e" ;;
79-
esac
80-
done
81-
82-
shift $((OPTIND - 1))
83-
84-
echo ${echo_opts} "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${*}\e[m"
85-
}
86-
87-
8830
# Show an INFO message
8931
# $1: message string
90-
_msg_info() {
91-
local echo_opts="-e"
92-
local arg
93-
local OPTIND
94-
local OPT
95-
while getopts 'n' arg; do
96-
case "${arg}" in
97-
n) echo_opts="${echo_opts} -n" ;;
98-
esac
99-
done
100-
shift $((OPTIND - 1))
101-
echo ${echo_opts} "$( echo_color -t '36' '[fullbuild.sh]') $( echo_color -t '32' 'Info') ${*}"
32+
msg_info() {
33+
local _msg_opts="-a fullbuild.sh"
34+
[[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
35+
[[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
36+
"${script_path}/tools/msg.sh" ${_msg_opts} info "${@}"
10237
}
10338

104-
10539
# Show an Warning message
10640
# $1: message string
107-
_msg_warn() {
108-
local echo_opts="-e"
109-
local arg
110-
local OPTIND
111-
local OPT
112-
while getopts 'n' arg; do
113-
case "${arg}" in
114-
n) echo_opts="${echo_opts} -n" ;;
115-
esac
116-
done
117-
shift $((OPTIND - 1))
118-
echo ${echo_opts} "$( echo_color -t '36' '[fullbuild.sh]') $( echo_color -t '33' 'Warning') ${*}" >&2
41+
msg_warn() {
42+
local _msg_opts="-a fullbuild.sh"
43+
[[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
44+
[[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
45+
"${script_path}/tools/msg.sh" ${_msg_opts} warn "${@}"
11946
}
12047

121-
12248
# Show an debug message
12349
# $1: message string
124-
_msg_debug() {
125-
local echo_opts="-e"
126-
local arg
127-
local OPTIND
128-
local OPT
129-
while getopts 'n' arg; do
130-
case "${arg}" in
131-
n) echo_opts="${echo_opts} -n" ;;
132-
esac
133-
done
134-
shift $((OPTIND - 1))
135-
if [[ ${debug} = true ]]; then
136-
echo ${echo_opts} "$( echo_color -t '36' '[fullbuild.sh]') $( echo_color -t '35' 'Debug') ${*}"
50+
msg_debug() {
51+
if [[ "${debug}" = true ]]; then
52+
local _msg_opts="-a fullbuild.sh"
53+
[[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
54+
[[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
55+
"${script_path}/tools/msg.sh" ${_msg_opts} info "${@}"
13756
fi
13857
}
13958

140-
14159
# Show an ERROR message then exit with status
14260
# $1: message string
14361
# $2: exit code number (with 0 does not exit)
144-
_msg_error() {
145-
local echo_opts="-e"
146-
local arg
147-
local OPTIND
148-
local OPT
149-
local OPTARG
150-
while getopts 'n' arg; do
151-
case "${arg}" in
152-
n) echo_opts="${echo_opts} -n" ;;
153-
esac
154-
done
155-
shift $((OPTIND - 1))
156-
echo ${echo_opts} "$( echo_color -t '36' '[fullbuild.sh]') $( echo_color -t '31' 'Error') ${1}" >&2
62+
msg_error() {
63+
local _msg_opts="-a fullbuild.sh"
64+
[[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
65+
[[ "${nocolor}" = true ]] && _msg_opts="${_msg_opts} -n"
66+
"${script_path}/tools/msg.sh" ${_msg_opts} error "${1}"
15767
if [[ -n "${2:-}" ]]; then
15868
exit ${2}
15969
fi
@@ -164,7 +74,7 @@ _msg_error() {
16474
trap_exit() {
16575
local status=${?}
16676
echo
167-
_msg_error "fullbuild.sh has been killed by the user."
77+
msg_error "fullbuild.sh has been killed by the user."
16878
exit ${status}
16979
}
17080

@@ -179,13 +89,13 @@ build() {
17989
echo "build.sh ${share_options} --lang ${lang} --arch ${arch} ${cha}"
18090
_exit_code="${?}"
18191
else
182-
_msg_info "Build the ${lang} version of ${cha} on the ${arch} architecture."
92+
msg_info "Build the ${lang} version of ${cha} on the ${arch} architecture."
18393
sudo bash ${script_path}/build.sh ${options}
18494
_exit_code="${?}"
18595
if [[ "${_exit_code}" = 0 ]]; then
18696
touch "${work_dir}/fullbuild.${cha}_${arch}_${lang}"
18797
else
188-
_msg_error "build.sh finished with exit code ${_exit_code}. Will try again."
98+
msg_error "build.sh finished with exit code ${_exit_code}. Will try again."
18999
fi
190100
fi
191101
fi
@@ -230,7 +140,7 @@ while getopts 'a:dghr:sctm:l:' arg; do
230140
m) architectures=(${OPTARG}) ;;
231141
g)
232142
if [[ ! -d "${script_path}/.git" ]]; then
233-
_msg_error "There is no git directory. You need to use git clone to use this feature."
143+
msg_error "There is no git directory. You need to use git clone to use this feature."
234144
exit 1
235145
else
236146
share_options="${share_options} --gitversion"
@@ -249,7 +159,7 @@ shift $((OPTIND - 1))
249159

250160
if [[ "${all_channel}" = true ]]; then
251161
if [[ -n "${*}" ]]; then
252-
_msg_error "Do not specify the channel." "1"
162+
msg_error "Do not specify the channel." "1"
253163
else
254164
channnels=($("${script_path}/build.sh" --channellist))
255165
fi
@@ -261,8 +171,8 @@ if [[ "${simulation}" = true ]]; then
261171
retry=1
262172
fi
263173

264-
_msg_info "Options: ${share_options}"
265-
_msg_info "Press Enter to continue or Ctrl + C to cancel."
174+
msg_info "Options: ${share_options}"
175+
msg_info "Press Enter to continue or Ctrl + C to cancel."
266176
read
267177

268178

@@ -286,5 +196,5 @@ done
286196

287197

288198
if [[ "${simulation}" = false ]]; then
289-
_msg_info "All editions have been built"
199+
msg_info "All editions have been built"
290200
fi

0 commit comments

Comments
 (0)