Skip to content

Commit 760118d

Browse files
author
Matthias Koeppe
committed
build/bin/sage-logger: Show build time if >= 10 seconds
1 parent 6ea3618 commit 760118d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

build/bin/sage-logger

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ else
6161
SED=cat
6262
fi
6363

64+
timefile="$logdir/$logname.time"
65+
rm -f "$timefile"
66+
if /usr/bin/time -p -o /dev/null true; then
67+
TIME="/usr/bin/time -p -o $timefile"
68+
else
69+
TIME=""
70+
fi
71+
6472
mkdir -p "$logdir"
6573

6674
# Do all logging of child processes with V=1 to ensure that no
@@ -75,12 +83,15 @@ if [ -n "$SAGE_SILENT_BUILD" -a ${use_prefix} = true ]; then
7583
# Silent build.
7684
# Similar to https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html#Automake-Silent-Rules
7785
echo "[$logname] installing. Log file: $logfile"
78-
( exec>> $logfile 2>&1 ; eval "$cmd" )
86+
( exec>> $logfile 2>&1 ; $TIME sh -c "$cmd"; status=$?;
87+
[ -r $timefile ] && cat $timefile; exit $status )
7988
status=$?
8089
if [[ $status != 0 ]]; then
8190
echo " [$logname] error installing, exit status $status. End of log file:"
8291
tail -n 120 "$logfile" | sed "/Please email sage-devel/,$ d;s;^; [$logname] ;" >&2
8392
echo " [$logname] Full log file: $logfile"
93+
elif grep -q 'real [1-9][0-9]' $timefile 2>/dev/null; then # at least 10 seconds
94+
echo " [$logname] successfully installed ($(echo $(cat $timefile)))."
8495
else
8596
echo " [$logname] successfully installed."
8697
fi
@@ -90,7 +101,10 @@ else
90101
# We trap SIGINT such that SIGINT interrupts the main process being
91102
# run, not the logging.
92103

93-
( exec 2>&1; eval "$cmd" ) | \
104+
( exec 2>&1;
105+
$TIME sh -c "$cmd"; status=$?;
106+
if grep -q 'real [1-9][0-9]' $timefile 2>/dev/null; then echo $(echo $(cat $timefile)); fi;
107+
exit $status ) | \
94108
( trap '' SIGINT; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::group::${logname}"; fi; tee -a "$logfile" | $SED; if [ -n "$GITHUB_ACTIONS" -a -n "$prefix" ]; then echo "::endgroup::"; fi )
95109

96110
pipestatus=(${PIPESTATUS[*]})

build/make/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ EOF
103103
###############################################################################
104104
# NOW do the actual build:
105105
###############################################################################
106-
time $MAKE "$@"
106+
$MAKE "$@"
107107
if [ $? -ne 0 ]; then
108108
cat >&2 <<EOF
109109
***************************************************************

0 commit comments

Comments
 (0)