From 17d569940f0a2aa61a5a25655f02c1e295e36f01 Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Thu, 10 Jun 2021 08:17:54 +0000 Subject: [PATCH] Improve bazel() warning in envsetup.sh. Fixes: 190688038 Test: source ~/aosp/build/envsetup.sh && cd / && bazel Change-Id: I309a77e109d8b3a65c4b28aeb5fbf2a059006ee0 --- envsetup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 6cb2cc4c7e..120f6e069c 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -331,15 +331,15 @@ function setpaths() function bazel() { - local T="$(gettop)" - if [ ! "$T" ]; then - echo "Couldn't locate the top of the tree. Try setting TOP." - return + if which bazel &>/dev/null; then + >&2 echo "NOTE: bazel() function sourced from Android's envsetup.sh is being used instead of $(which bazel)" + >&2 echo fi - if which bazel &>/dev/null; then - >&2 echo "NOTE: bazel() function sourced from envsetup.sh is being used instead of $(which bazel)" - >&2 echo + local T="$(gettop)" + if [ ! "$T" ]; then + >&2 echo "Couldn't locate the top of the Android tree. Try setting TOP. This bazel() function cannot be used outside of the AOSP directory." + return fi "$T/tools/bazel" "$@"