envsetup.sh: Use prebuilt emulator binaries if available.
This patch changes the setpaths() function in envsetup.sh to probe
for prebuilts/android-emulator/<host>/, and prepend it to PATH if
it exists.
See https://googleplex-android-review.googlesource.com/#/c/459741/
for a related patch that adds the binaries.
BUG=13747402
Change-Id: I30794ea52f6dfc58908e6271f2c0da8e2f0b68e8
diff --git a/envsetup.sh b/envsetup.sh
index 6891747..e5bd72e 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -189,6 +189,24 @@
unset ANDROID_HOST_OUT
export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
+ # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH
+ # to ensure that the corresponding 'emulator' binaries are used.
+ case $(uname -s) in
+ Darwin)
+ ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
+ ;;
+ Linux)
+ ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
+ ;;
+ *)
+ ANDROID_EMULATOR_PREBUILTS=
+ ;;
+ esac
+ if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
+ PATH=$ANDROID_EMULATOR_PREBUILTS:$PATH
+ export ANDROID_EMULATOR_PREBUILTS
+ fi
+
# needed for building linux on MacOS
# TODO: fix the path
#export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include