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
diff --git a/shell_utils.sh b/shell_utils.sh
index 15051e9..450bb83 100644
--- a/shell_utils.sh
+++ b/shell_utils.sh
@@ -46,7 +46,7 @@
{
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 @@
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
+}
+
+