tools/bazel: add wrapper script
This causes recent versions of Bazelisk (and native Bazel) to use
our wrapper script automatically.
Ie74b9ecd removes the internal wrapper, which used to the same
job but much less elegantly.
Change-Id: Iabf0988c8d9ce2fa759ea81e6853380b56ffed2e
Reviewed-on: https://review.monogon.dev/c/monogon/+/1024
Tested-by: Jenkins CI
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/tools/bazel b/tools/bazel
new file mode 100755
index 0000000..afca095
--- /dev/null
+++ b/tools/bazel
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# Both bazelisk and bazel's native wrapper scripts will attempt to use the well-known executable
+# named "tools/bazel" to run Bazel. The path of the original executable is stored in BAZEL_REAL.
+set -euo pipefail
+
+if [[ -z "${BAZEL_REAL:-}" ]]; then
+ echo "BAZEL_REAL is not set - do not run directly, instead, use bazelisk" >&2
+ exit 1
+fi
+
+if [[ -z "${BAZELISK_SKIP_WRAPPER:-}" ]]; then
+ echo "#########################################################" >&2
+ echo " You are not using Bazelisk. This is not recommended." >&2
+ echo " Make sure you are using the correct version of Bazel." >&2
+ echo "#########################################################" >&2
+fi
+
+exec scripts/bin/bazel "$@"