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