setup & share path to depot_tools checkout
A lot of scripts like to compute the dirname of $0 to find itself to
load more files. Have some scripts export & resuse this value so we
avoid recalculating when not needed.
Bug: 1469696
Change-Id: I3aac2e6119dbfa3c68715208df2786f67cdce92e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4750430
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
diff --git a/vpython b/vpython
index 45b0d02..08ed05b 100755
--- a/vpython
+++ b/vpython
@@ -35,10 +35,10 @@
exec "python" "${NEWARGS[@]}"
fi
+# Export for other depot_tools scripts to re-use.
+export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "$0")}"
-base_dir=$(dirname "$0")
-
-source "$base_dir/cipd_bin_setup.sh"
+source "${DEPOT_TOOLS_DIR}/cipd_bin_setup.sh"
cipd_bin_setup &> /dev/null
case $(uname -s) in
@@ -46,6 +46,6 @@
cmd.exe //c $0.bat "$@"
;;
*)
- exec "$base_dir/.cipd_bin/vpython" "$@"
+ exec "${DEPOT_TOOLS_DIR}/.cipd_bin/vpython" "$@"
;;
esac