2019-04-13 18:33:38 +02:00
|
|
|
# shellcheck shell=bash
|
2006-05-31 22:43:41 +02:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2012-04-21 23:22:28 +02:00
|
|
|
# Be sure that we know the target name
|
2006-06-01 23:08:49 +02:00
|
|
|
[[ -z $1 ]] && exit
|
2006-06-08 23:05:03 +02:00
|
|
|
TARGET=$1 # Remember the target build we are looking for
|
2006-09-13 22:30:00 +02:00
|
|
|
MAKE_PPID=$2
|
2006-06-01 23:08:49 +02:00
|
|
|
|
2006-06-08 23:05:03 +02:00
|
|
|
declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer
|
|
|
|
declare -r CURSOR_OFF=${CSI}$'?25l'
|
|
|
|
declare -r CURSOR_ON=${CSI}$'?25h'
|
|
|
|
declare -r ERASE_LINE=${CSI}$'2K'
|
|
|
|
declare -r FRAME_OPEN=${CSI}$'2G['
|
|
|
|
declare -r FRAME_CLOSE=${CSI}$'63G]'
|
|
|
|
declare -r TS_POSITION=${CSI}$'65G'
|
2019-04-13 18:33:38 +02:00
|
|
|
declare -r RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
|
2006-06-08 23:05:03 +02:00
|
|
|
|
2019-04-13 18:33:38 +02:00
|
|
|
declare -r GRAPHIC_STR="| / - \\ + "
|
2006-06-08 23:05:03 +02:00
|
|
|
declare -i SEC=0 # Seconds accumulator
|
2006-06-10 17:41:52 +02:00
|
|
|
declare -i PREV_SEC=0
|
|
|
|
|
2007-03-18 10:46:24 +01:00
|
|
|
# Prevent segfault on stripping phases
|
2007-03-19 19:27:00 +01:00
|
|
|
if [[ "$BASHBIN" = "/tools/bin/bash" ]] ; then
|
2007-03-18 10:46:24 +01:00
|
|
|
SLEEP=/tools/bin/sleep
|
2012-04-21 23:22:28 +02:00
|
|
|
elif [ -x /bin/sleep ] ; then
|
2007-03-19 19:27:00 +01:00
|
|
|
SLEEP=/bin/sleep
|
2012-04-21 23:22:28 +02:00
|
|
|
else
|
|
|
|
SLEEP=/usr/bin/sleep
|
2007-03-18 10:46:24 +01:00
|
|
|
fi
|
|
|
|
|
2006-06-08 23:05:03 +02:00
|
|
|
write_or_exit() {
|
2006-06-09 02:15:21 +02:00
|
|
|
# make has been killed or failed or run to completion, leave
|
2006-09-13 22:30:00 +02:00
|
|
|
[[ ! -e /proc/${MAKE_PPID} ]] && echo -n "${CURSOR_ON}" && exit
|
2006-06-29 02:36:22 +02:00
|
|
|
|
2006-06-10 01:05:39 +02:00
|
|
|
# Target build complete, leave.
|
|
|
|
[[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit
|
2006-06-29 02:36:22 +02:00
|
|
|
|
2006-06-08 23:05:03 +02:00
|
|
|
# It is safe to write to the screen
|
|
|
|
echo -n "$1"
|
|
|
|
}
|
|
|
|
|
2006-06-10 17:41:52 +02:00
|
|
|
# initialize screen
|
2006-10-02 21:32:06 +02:00
|
|
|
write_or_exit "${RESET_LINE}${TS_POSITION}0 min. 0 sec"
|
2006-06-10 17:41:52 +02:00
|
|
|
|
|
|
|
# loop forever..
|
|
|
|
while true ; do
|
|
|
|
|
2019-04-13 18:33:38 +02:00
|
|
|
# Loop through the animation string
|
|
|
|
for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
|
|
|
|
write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}"
|
|
|
|
$SLEEP .12 # This value MUST be less than .2 seconds.
|
|
|
|
done
|
2006-06-10 17:41:52 +02:00
|
|
|
|
2019-04-13 18:33:38 +02:00
|
|
|
# A BASH internal variable, the number of seconds the script
|
|
|
|
# has been running. modulo convert to 0-59
|
|
|
|
SEC=$((SECONDS % 60))
|
2006-06-10 17:41:52 +02:00
|
|
|
|
2019-04-13 18:33:38 +02:00
|
|
|
# Detect rollover of the seconds.
|
|
|
|
(( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}"
|
|
|
|
PREV_SEC=$SEC
|
2006-06-10 17:41:52 +02:00
|
|
|
|
2019-04-13 18:33:38 +02:00
|
|
|
# Display the accumulated time. div minutes.. modulo seconds.
|
|
|
|
write_or_exit "${TS_POSITION}$((SECONDS / 60)) min. $SEC sec"
|
2006-06-08 23:05:03 +02:00
|
|
|
done
|
|
|
|
|
2006-06-10 17:41:52 +02:00
|
|
|
exit
|