diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2007-05-20 13:48:26 +0000 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2007-05-20 13:48:26 +0000 |
commit | 4fb8055bf7165d681dbe7ba5d10d8f98a5043d92 (patch) | |
tree | f240fc986f75cb724a2e7d416ea92b89c172c317 /scripts/functions | |
parent | 5d2b862edcc5c39e7a336c7a4868701495b5be57 (diff) | |
download | crosstool-ng-4fb8055bf7165d681dbe7ba5d10d8f98a5043d92.tar.gz crosstool-ng-4fb8055bf7165d681dbe7ba5d10d8f98a5043d92.tar.bz2 crosstool-ng-4fb8055bf7165d681dbe7ba5d10d8f98a5043d92.zip |
Ah! I finally have a progress bar that doesn't stall the build!
- pipe size in Linux is only 8*512=4096 bytes
- pipe size is not setable
- when the feeding process spits out data faster than the eating
process can read it, then the feeding process stalls after 4KiB
of data sent to the pipe
- for us, the progress bar would spawn a sub-shell every line,
and the sub-shell would in turn spawn a 'date' command.
Which was sloooww as hell, and would cause some kind of a
starvation: the pipe was full most of the time, and the
feeding process was stalled all this time.
Now, we use internal variables and a little hack based onan offset
to determine the elapsed time. Much faster this way, but still
CPU-intensive.
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/scripts/functions b/scripts/functions index 41942a45..e5351740 100644 --- a/scripts/functions +++ b/scripts/functions @@ -12,7 +12,7 @@ CT_OnError() { for((depth=2; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do CT_DoLog ERROR " called from \"${BASH_SOURCE[${depth}]}\" at line # ${BASH_LINENO[${depth}-1]} in function \"${FUNCNAME[${depth}]}\"" done - CT_DoLog ERROR "Look at \"${CT_ACTUAL_LOG_FILE}\" for more info on this error." + [ "${CT_LOG_TO_FILE}" = "y" ] && CT_DoLog ERROR "Look at \"${CT_LOG_FILE}\" for more info on this error." CT_STEP_COUNT=1 CT_DoEnd ERROR exit $ret @@ -54,30 +54,31 @@ CT_DoLog() { cat - else echo "${1}" - fi |( IFS="\n" # We want the full lines, even leading spaces + fi |( offset=$((`CT_DoDate +%s`+(CT_STAR_DATE/(1000*1000*1000)))) + IFS="\n" # We want the full lines, even leading spaces CT_PROG_BAR_CPT=0 indent=$((2*CT_STEP_COUNT)) while read line; do case "${CT_LOG_SEE_TOOLS_WARN},${line}" in y,*"warning:"*) cur_L=WARN; cur_l=${CT_LOG_LEVEL_WARN};; + y,*"WARNING:"*) cur_L=WARN; cur_l=${CT_LOG_LEVEL_WARN};; *"error:"*) cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; *"make["?*"]:"*"Stop.") cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; *) cur_L="${LEVEL}"; cur_l="${level}";; esac l="`printf \"[%-5s]%*s%s%s\" \"${cur_L}\" \"${indent}\" \" \" \"${line}\"`" # There will always be a log file, be it /dev/null - echo -e "${l}" >>"${CT_ACTUAL_LOG_FILE}" + echo -e "${l}" if [ ${cur_l} -le ${max_level} ]; then - echo -e "\r${l}" + echo -e "\r${l}" >&6 fi if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then - str=`CT_DoDate +%s` - elapsed=$((str-(CT_STAR_DATE/(1000*1000*1000)))) + elapsed=$((SECONDS+OFFSET)) [ ${CT_PROG_BAR_CPT} -eq 0 ] && bar="/" [ ${CT_PROG_BAR_CPT} -eq 10 ] && bar="-" [ ${CT_PROG_BAR_CPT} -eq 20 ] && bar="\\" [ ${CT_PROG_BAR_CPT} -eq 30 ] && bar="|" - printf "\r[%02d:%02d] %s " $((elapsed/60)) $((elapsed%60)) "${bar}" + printf "\r[%02d:%02d] %s " $((elapsed/60)) $((elapsed%60)) "${bar}" >&6 CT_PROG_BAR_CPT=$(((CT_PROG_BAR_CPT+1)%40)) fi done |