vendor: build: Add mk_timer
Change-Id: Ib7ce1e7c662fe0555d296e125241c222f89f671d
diff --git a/build/envsetup.sh b/build/envsetup.sh
index 7e9c6f0..f236cab 100644
--- a/build/envsetup.sh
+++ b/build/envsetup.sh
@@ -22,6 +22,35 @@
EOF
}
+function mk_timer()
+{
+ local start_time=$(date +"%s")
+ $@
+ local ret=$?
+ local end_time=$(date +"%s")
+ local tdiff=$(($end_time-$start_time))
+ local hours=$(($tdiff / 3600 ))
+ local mins=$((($tdiff % 3600) / 60))
+ local secs=$(($tdiff % 60))
+ local ncolors=$(tput colors 2>/dev/null)
+ echo
+ if [ $ret -eq 0 ] ; then
+ echo -n "#### make completed successfully "
+ else
+ echo -n "#### make failed to build some targets "
+ fi
+ if [ $hours -gt 0 ] ; then
+ printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
+ elif [ $mins -gt 0 ] ; then
+ printf "(%02g:%02g (mm:ss))" $mins $secs
+ elif [ $secs -gt 0 ] ; then
+ printf "(%s seconds)" $secs
+ fi
+ echo " ####"
+ echo
+ return $ret
+}
+
function brunch()
{
breakfast $*