From 5d60d0245471905bbf453b6537fb0b2f80310551 Mon Sep 17 00:00:00 2001 From: Rupert Shuttleworth Date: Sun, 25 Oct 2020 05:20:03 +0000 Subject: [PATCH] Rename abazel() to bazel(), give a warning if clobbering an existing Bazel, and have it call tools/bazel (aka build/bazel/bazel.sh) to start Bazel. Test: Manually. Change-Id: I5605571147db33c6b6a008cedbf279bb909ecdee --- envsetup.sh | 47 +++++------------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 82c456562..aa90b4d95 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -318,7 +318,7 @@ function setpaths() #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include } -function abazel() +function bazel() { local T="$(gettop)" if [ ! "$T" ]; then @@ -326,49 +326,12 @@ function abazel() return fi - case $(uname -s) in - Darwin) - ANDROID_BAZEL_PATH="${T}/prebuilts/bazel/darwin-x86_64/bazel" - ANDROID_BAZELRC_PATH="${T}/build/bazel/darwin.bazelrc" - ANDROID_BAZEL_JDK_PATH="${T}/prebuilts/jdk/jdk11/darwin-x86" - ;; - Linux) - ANDROID_BAZEL_PATH="${T}/prebuilts/bazel/linux-x86_64/bazel" - ANDROID_BAZELRC_PATH="${T}/build/bazel/linux.bazelrc" - ANDROID_BAZEL_JDK_PATH="${T}/prebuilts/jdk/jdk11/linux-x86" - ;; - *) - ANDROID_BAZEL_PATH= - ANDROID_BAZELRC_PATH= - ANDROID_BAZEL_JDK_PATH= - ;; - esac - - if [ -n "$ANDROID_BAZEL_PATH" -a -f "$ANDROID_BAZEL_PATH" ]; then - export ANDROID_BAZEL_PATH - else - echo "Couldn't locate Bazel binary" - return + if which bazel &>/dev/null; then + echo "NOTE: bazel() function sourced from envsetup.sh is being used instead of $(which bazel)" + echo fi - if [ -n "$ANDROID_BAZELRC_PATH" -a -f "$ANDROID_BAZELRC_PATH" ]; then - export ANDROID_BAZELRC_PATH - else - echo "Couldn't locate bazelrc file for Bazel" - return - fi - - if [ -n "$ANDROID_BAZEL_JDK_PATH" -a -d "$ANDROID_BAZEL_JDK_PATH" ]; then - export ANDROID_BAZEL_JDK_PATH - else - echo "Couldn't locate JDK to use for Bazel" - return - fi - - echo "WARNING: Bazel support for the Android Platform is experimental and is undergoing development." - echo "WARNING: Currently, build stability is not guaranteed. Thank you." - echo - "${ANDROID_BAZEL_PATH}" --server_javabase="${ANDROID_BAZEL_JDK_PATH}" --bazelrc="${ANDROID_BAZELRC_PATH}" "$@" + "$T/tools/bazel" "$@" } function printconfig()