Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / build / android / envsetup.sh
1 #!/bin/bash
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Sets up environment for building Chromium on Android.
7
8 # Make sure we're being sourced (possibly by another script). Check for bash
9 # since zsh sets $0 when sourcing.
10 if [[ -n "$BASH_VERSION" && "${BASH_SOURCE:-$0}" == "$0" ]]; then
11   echo "ERROR: envsetup must be sourced."
12   exit 1
13 fi
14
15 # This only exists to set local variables. Don't call this manually.
16 android_envsetup_main() {
17   local SCRIPT_DIR="$(dirname "${BASH_SOURCE:-$0}")"
18
19   local CURRENT_DIR="$(readlink -f "${SCRIPT_DIR}/../../")"
20   if [[ -z "${CHROME_SRC}" ]]; then
21     # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
22     local CHROME_SRC="${CURRENT_DIR}"
23   fi
24
25   if [[ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]]; then
26     # If current directory is not in $CHROME_SRC, it might be set for other
27     # source tree. If $CHROME_SRC was set correctly and we are in the correct
28     # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "".
29     # Otherwise, it will equal to "${CURRENT_DIR}"
30     echo "Warning: Current directory is out of CHROME_SRC, it may not be \
31   the one you want."
32     echo "${CHROME_SRC}"
33   fi
34
35   # Allow the caller to override a few environment variables. If any of them is
36   # unset, we default to a sane value that's known to work. This allows for
37   # experimentation with a custom SDK.
38   if [[ -z "${ANDROID_SDK_ROOT}" || ! -d "${ANDROID_SDK_ROOT}" ]]; then
39     local ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/"
40   fi
41
42   # Add Android SDK tools to system path.
43   export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
44
45   # Add Chromium Android development scripts to system path.
46   # Must be after CHROME_SRC is set.
47   export PATH=$PATH:${CHROME_SRC}/build/android
48
49   export ENVSETUP_GYP_CHROME_SRC=${CHROME_SRC}  # TODO(thakis): Remove.
50 }
51 android_envsetup_main
52
53 android_gyp() {
54   echo "Please call build/gyp_chromium instead. android_gyp is going away."
55   "${ENVSETUP_GYP_CHROME_SRC}/build/gyp_chromium" --depth="${ENVSETUP_GYP_CHROME_SRC}" --check "$@"
56 }