1#!/bin/bash 2# Copyright 2012 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Adds Android SDK tools and related helpers to PATH, useful for development. 7# Not used on bots, nor required for any commands to succeed. 8# Use like: source build/android/envsetup.sh 9 10# Make sure we're being sourced. 11if [[ -n "$BASH_VERSION" && "${BASH_SOURCE:-$0}" == "$0" ]]; then 12 echo "ERROR: envsetup must be sourced." 13 exit 1 14fi 15 16# This only exists to set local variables. Don't call this manually. 17android_envsetup_main() { 18 local SCRIPT_PATH="$1" 19 local SCRIPT_DIR="$(dirname "$SCRIPT_PATH")" 20 local CHROME_SRC="$(readlink -f "${SCRIPT_DIR}/../../")" 21 22 # Some tools expect these environmental variables. 23 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_sdk/public" 24 # ANDROID_HOME is deprecated, but generally means the same thing as 25 # ANDROID_SDK_ROOT and shouldn't hurt to set it. 26 export ANDROID_HOME="$ANDROID_SDK_ROOT" 27 28 # Set up PATH to point to SDK-provided (and other) tools, such as 'adb'. 29 export PATH=${CHROME_SRC}/build/android:$PATH 30 export PATH=${ANDROID_SDK_ROOT}/tools/:$PATH 31 export PATH=${ANDROID_SDK_ROOT}/platform-tools:$PATH 32} 33# In zsh, $0 is the name of the file being sourced. 34android_envsetup_main "${BASH_SOURCE:-$0}" 35unset -f android_envsetup_main 36