Allow customizing bazel wrapper location checked into repository

Allow customizing location of Bazel wrapper checked into the repository using an env var $BAZEL_WRAPPER. There is no strong reason this needs to be hardcoded to `tools/bazel`. For eg: we keep most of our tools in the top-level `tooling` directory and would like to organize the wrapper location better and avoid confusion caused by two tool-related directories at the top `tools` and `tooling`.

Closes #15173.

PiperOrigin-RevId: 441488733
diff --git a/scripts/packages/bazel.sh b/scripts/packages/bazel.sh
index 98b15fe..58a53b3 100755
--- a/scripts/packages/bazel.sh
+++ b/scripts/packages/bazel.sh
@@ -34,7 +34,9 @@
 # In addition, if an executable called "tools/bazel" is found in the current
 # workspace, this script will not directly execute Bazel, but instead store
 # the path to the real Bazel executable in the environment variable BAZEL_REAL
-# and then execute the "tools/bazel" wrapper script.
+# and then execute the "tools/bazel" wrapper script. The location of the wrapper
+# script relative to the workspace can be changed with the $BAZEL_WRAPPER
+# environment variable.
 #
 # In contrast to Bazelisk, this script does not download anything from the
 # internet and instead relies on the local system to provide Bazel binaries.
@@ -166,11 +168,12 @@
   fi
 fi
 
-# If the repository contains a checked-in executable called tools/bazel, we
-# assume that they know what they're doing and have their own way of versioning
-# Bazel. Thus, we don't have to print our helpful messages or error out in case
-# we couldn't find a binary.
-readonly wrapper="${workspace_dir}/tools/bazel"
+# If the repository contains a checked-in executable set by $BAZEL_WRAPPER
+# (defaults to tools/bazel), we assume that they know what they're doing and
+# have their own way of versioning Bazel. Thus, we don't have to print our
+# helpful messages or error out in case we couldn't find a binary.
+BAZEL_WRAPPER=${BAZEL_WRAPPER:-"tools/bazel"}
+readonly wrapper="${workspace_dir}/${BAZEL_WRAPPER}"
 if [[ -x "$wrapper" && -f "$wrapper" ]]; then
   export BAZEL_REAL
   exec -a "$0" "${wrapper}" "$@"