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.
6 # Sets up environment for building Chromium on Android.
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."
15 # Source functions script. The file is in the same directory as this script.
16 SCRIPT_DIR="$(dirname "${BASH_SOURCE:-$0}")"
18 # Get host architecture, and abort if it is 32-bit.
20 case "${host_arch}" in
24 echo "ERROR: Android build requires a 64-bit host build machine."
28 echo "ERROR: Unsupported host architecture (${host_arch})."
29 echo "Try running this script on a Linux/x86_64 machine instead."
33 CURRENT_DIR="$(readlink -f "${SCRIPT_DIR}/../../")"
34 if [[ -z "${CHROME_SRC}" ]]; then
35 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
36 export CHROME_SRC="${CURRENT_DIR}"
39 if [[ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]]; then
40 # If current directory is not in $CHROME_SRC, it might be set for other
41 # source tree. If $CHROME_SRC was set correctly and we are in the correct
42 # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "".
43 # Otherwise, it will equal to "${CURRENT_DIR}"
44 echo "Warning: Current directory is out of CHROME_SRC, it may not be \
49 # Allow the caller to override a few environment variables. If any of them is
50 # unset, we default to a sane value that's known to work. This allows for
51 # experimentation with a custom SDK.
52 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then
53 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/"
55 if [[ -z "${ANDROID_SDK_ROOT}" || ! -d "${ANDROID_SDK_ROOT}" ]]; then
56 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/"
59 # Add Android SDK tools to system path.
60 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
61 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
63 # Add Chromium Android development scripts to system path.
64 # Must be after CHROME_SRC is set.
65 export PATH=$PATH:${CHROME_SRC}/build/android
67 # The set of GYP_DEFINES to pass to gyp.
70 if [[ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]]; then
71 # These defines are used by various chrome build scripts to tag the binary's
72 # version string as 'official' in linux builds (e.g. in
73 # chrome/trunk/src/chrome/tools/build/version.py).
74 export OFFICIAL_BUILD=1
75 export CHROMIUM_BUILD="_google_chrome"
76 export CHROME_BUILD_TYPE="_official"
79 # TODO(thakis), Jan 18 2014: Remove this after two weeks or so, after telling
80 # everyone to set use_goma in GYP_DEFINES instead of a GOMA_DIR env var.
81 if [[ -d $GOMA_DIR ]]; then
82 DEFINES+=" use_goma=1 gomadir=$GOMA_DIR"
85 export GYP_DEFINES="${DEFINES}"
87 # Source a bunch of helper functions
88 . ${CHROME_SRC}/build/android/adb_device_functions.sh
90 # Performs a gyp_chromium run to convert gyp->Makefile for android code.
92 # This is just a simple wrapper of gyp_chromium, please don't add anything
94 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" --check "$@"