diff options
author | 2024-05-17 12:16:43 -0700 | |
---|---|---|
committer | 2024-05-20 14:22:20 -0700 | |
commit | 1b9ab2903c8f6cddeb629f20de34685df97331a3 (patch) | |
tree | d97ba8dc10025779d8c466357484420a8ef4ceca /shell_utils.sh | |
parent | 159cc8c594de8520f928552507eabce9b05e0446 (diff) |
Clean cruft out of envsetup.sh
Most if it moved to build/soong/bin as standalone scripts
Bug: 340648588
Test: ran the scripts
Change-Id: I69bff94a2293e2563d58d29b12f7926a9229f9d4
Diffstat (limited to 'shell_utils.sh')
-rw-r--r-- | shell_utils.sh | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/shell_utils.sh b/shell_utils.sh index 15051e9585..450bb836a6 100644 --- a/shell_utils.sh +++ b/shell_utils.sh @@ -46,7 +46,7 @@ function require_top { TOP=$(gettop) if [[ ! $TOP ]] ; then - echo "Can not locate root of source tree. $(basename $0) must be run from within the Android source tree." >&2 + echo "Can not locate root of source tree. $(basename $0) must be run from within the Android source tree or TOP must be set." >&2 exit 1 fi } @@ -80,4 +80,50 @@ function getoutdir echo "${out_dir}" } +# Pretty print the build status and duration +function _wrap_build() +{ + if [[ "${ANDROID_QUIET_BUILD:-}" == true ]]; then + "$@" + return $? + fi + 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) + if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then + color_failed=$'\E'"[0;31m" + color_success=$'\E'"[0;32m" + color_warning=$'\E'"[0;33m" + color_reset=$'\E'"[00m" + else + color_failed="" + color_success="" + color_reset="" + fi + + echo + if [ $ret -eq 0 ] ; then + echo -n "${color_success}#### build completed successfully " + else + echo -n "${color_failed}#### 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 " ####${color_reset}" + echo + return $ret +} + + |