commit:     683d8b60b0038619e9d57012939330e63fea1614
Author:     George Burgess IV <gbiv <AT> google <DOT> com>
AuthorDate: Mon Apr 10 19:59:43 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Sep 18 09:48:23 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=683d8b60

bazel.eclass: add support for a custom bazel

Multiple bazel packages can be installed side-by-side through version
suffixes, e.g., `/usr/bin/bazel-5`, `/usr/bin/bazel-6`, etc. These can
be easily simultaneously supported with an eclass param.

Signed-off-by: George Burgess IV <gbiv <AT> google.com>
Closes: https://github.com/gentoo/gentoo/pull/30544
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/bazel.eclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/eclass/bazel.eclass b/eclass/bazel.eclass
index 8897ea175a84..1cba19485442 100644
--- a/eclass/bazel.eclass
+++ b/eclass/bazel.eclass
@@ -27,6 +27,13 @@ if [[ ${CATEGORY}/${PN} != "dev-util/bazel" ]]; then
        BDEPEND=">=dev-util/bazel-0.20"
 fi
 
+# @ECLASS_VARIABLE: BAZEL_BINARY
+# @DESCRIPTION:
+# The program to invoke for bazel. Defaults to `bazel`. Useful if you have
+# multiple bazel installations on your machine that differ in verson suffix,
+# e.g., `bazel-5`, `bazel-6`.
+BAZEL_BINARY="${BAZEL_BINARY:-bazel}"
+
 # @FUNCTION: bazel_get_flags
 # @DESCRIPTION:
 # Obtain and print the bazel flags for target and host *FLAGS.
@@ -138,7 +145,7 @@ ebazel() {
        output_base="${output_base%/}-bazel-base"
        mkdir -p "${output_base}" || die
 
-       set -- bazel --bazelrc="${T}/bazelrc" --output_base="${output_base}" 
${@}
+       set -- "${BAZEL_BINARY}" --bazelrc="${T}/bazelrc" 
--output_base="${output_base}" ${@}
        echo "${*}" >&2
        "${@}" || die "ebazel failed"
 }

Reply via email to