[email protected] | b0be3f1 | 2013-02-16 11:33:11 | [diff] [blame] | 1 | #!/bin/bash |
Avi Drissman | 73a09d1 | 2022-09-08 20:33:38 | [diff] [blame] | 2 | # Copyright 2012 The Chromium Authors |
[email protected] | ec5dcded | 2011-09-26 21:40:38 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
4 | # found in the LICENSE file. | ||||
5 | |||||
Nico Weber | 24dfd30 | 2017-07-20 19:03:08 | [diff] [blame] | 6 | # Adds Android SDK tools and related helpers to PATH, useful for development. |
Andrew Grieve | b747e71 | 2017-11-23 16:58:31 | [diff] [blame] | 7 | # Not used on bots, nor required for any commands to succeed. |
8 | # Use like: source build/android/envsetup.sh | ||||
[email protected] | ec5dcded | 2011-09-26 21:40:38 | [diff] [blame] | 9 | |
Nico Weber | 24dfd30 | 2017-07-20 19:03:08 | [diff] [blame] | 10 | # Make sure we're being sourced. |
[email protected] | 5ae1503 | 2013-10-23 03:43:25 | [diff] [blame] | 11 | if [[ -n "$BASH_VERSION" && "${BASH_SOURCE:-$0}" == "$0" ]]; then |
12 | echo "ERROR: envsetup must be sourced." | ||||
13 | exit 1 | ||||
14 | fi | ||||
[email protected] | b0be3f1 | 2013-02-16 11:33:11 | [diff] [blame] | 15 | |
[email protected] | d958432 | 2014-04-08 03:53:51 | [diff] [blame] | 16 | # This only exists to set local variables. Don't call this manually. |
17 | android_envsetup_main() { | ||||
[email protected] | 94370ac | 2014-06-13 05:15:48 | [diff] [blame] | 18 | local SCRIPT_PATH="$1" |
19 | local SCRIPT_DIR="$(dirname "$SCRIPT_PATH")" | ||||
Nico Weber | 6585ea3 | 2017-07-20 18:00:55 | [diff] [blame] | 20 | local CHROME_SRC="$(readlink -f "${SCRIPT_DIR}/../../")" |
[email protected] | cf32380 | 2014-02-20 18:44:06 | [diff] [blame] | 21 | |
Nate Fischer | 70967204 | 2019-06-26 03:37:47 | [diff] [blame] | 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'. | ||||
Carlos Knippschild | dedee28f | 2020-04-28 22:37:50 | [diff] [blame] | 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 | ||||
[email protected] | d958432 | 2014-04-08 03:53:51 | [diff] [blame] | 32 | } |
[email protected] | 94370ac | 2014-06-13 05:15:48 | [diff] [blame] | 33 | # In zsh, $0 is the name of the file being sourced. |
34 | android_envsetup_main "${BASH_SOURCE:-$0}" | ||||
35 | unset -f android_envsetup_main |