Make touch-action apply to double-tap zoom
[chromium-blink-merge.git] / build / android / envsetup_functions.sh
blob083cdef22da7c625f0dda16ac653a6e976c06a0c
1 #!/bin/bash
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Defines functions for envsetup.sh which sets up environment for building
8 # Chromium on Android. The build can be either use the Android NDK/SDK or
9 # android source tree. Each has a unique init function which calls functions
10 # prefixed with "common_" that is common for both environment setups.
12 ################################################################################
13 # Exports environment variables common to both sdk and non-sdk build (e.g. PATH)
14 # based on CHROME_SRC, along with DEFINES for GYP_DEFINES.
15 ################################################################################
16 common_vars_defines() {
17 # Add Android SDK tools to system path.
18 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
19 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
21 # Add Chromium Android development scripts to system path.
22 # Must be after CHROME_SRC is set.
23 export PATH=$PATH:${CHROME_SRC}/build/android
25 # The set of GYP_DEFINES to pass to gyp.
26 DEFINES="OS=android"
28 if [[ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]]; then
29 # These defines are used by various chrome build scripts to tag the binary's
30 # version string as 'official' in linux builds (e.g. in
31 # chrome/trunk/src/chrome/tools/build/version.py).
32 export OFFICIAL_BUILD=1
33 export CHROMIUM_BUILD="_google_chrome"
34 export CHROME_BUILD_TYPE="_official"
37 # TODO(thakis), Jan 18 2014: Remove this after two weeks or so, after telling
38 # everyone to set use_goma in GYP_DEFINES instead of a GOMA_DIR env var.
39 if [[ -d $GOMA_DIR ]]; then
40 DEFINES+=" use_goma=1 gomadir=$GOMA_DIR"
45 ################################################################################
46 # Prints out help message on usage.
47 ################################################################################
48 print_usage() {
49 echo "usage: ${0##*/} [--help]" >& 2
50 echo "--help this help" >& 2
53 ################################################################################
54 # Process command line options.
55 ################################################################################
56 process_options() {
57 while [[ -n $1 ]]; do
58 case "$1" in
59 --target-arch=*)
60 echo "WARNING: --target-arch is ignored and will be an error soon."
61 echo "Pass -Dtarget_arch=foo to gyp instead."
62 echo "(x86 is spelled ia32 in gyp, mips becomes mipsel, arm stays arm)"
65 # Ignore other command line options
66 echo "Unknown option: $1"
68 esac
69 shift
70 done
73 ################################################################################
74 # Initializes environment variables for NDK/SDK build.
75 ################################################################################
76 sdk_build_init() {
77 # Allow the caller to override a few environment variables. If any of them is
78 # unset, we default to a sane value that's known to work. This allows for
79 # experimentation with a custom SDK.
80 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then
81 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/"
83 if [[ -z "${ANDROID_SDK_ROOT}" || ! -d "${ANDROID_SDK_ROOT}" ]]; then
84 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/"
87 common_vars_defines
89 export GYP_DEFINES="${DEFINES}"
91 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then
92 # Can not build WebView with NDK/SDK because it needs the Android build
93 # system and build inside an Android source tree.
94 echo "Can not build WebView with NDK/SDK. Requires android source tree." \
95 >& 2
96 echo "Try . build/android/envsetup.sh instead." >& 2
97 return 1
101 ################################################################################
102 # To build WebView, we use the Android build system and build inside an Android
103 # source tree.
104 #############################################################################
105 webview_build_init() {
106 # Use the latest API in the AOSP prebuilts directory (change with AOSP roll).
107 android_sdk_version=18
109 # For the WebView build we always use the SDK in the Android tree.
110 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\
111 ${android_sdk_version}
113 common_vars_defines
115 # We need to supply SDK paths relative to the top of the Android tree to make
116 # sure the generated Android makefiles are portable, as they will be checked
117 # into the Android tree.
118 ANDROID_SDK=$(python -c \
119 "import os.path; print os.path.relpath('${ANDROID_SDK_ROOT}', \
120 '${ANDROID_BUILD_TOP}')")
121 ANDROID_SDK_TOOLS=$(python -c \
122 "import os.path, sys; \
123 print os.path.relpath( \
124 '${ANDROID_SDK_ROOT}/../tools/' + sys.platform.rstrip('23'), \
125 '${ANDROID_BUILD_TOP}')")
126 DEFINES+=" android_webview_build=1"
127 DEFINES+=" android_src=\$(PWD)"
128 DEFINES+=" android_ndk_root=ndk_root_unused_in_webview_build"
129 DEFINES+=" android_sdk=\$(PWD)/${ANDROID_SDK}"
130 DEFINES+=" android_sdk_root=\$(PWD)/${ANDROID_SDK}"
131 DEFINES+=" android_sdk_tools=\$(PWD)/${ANDROID_SDK_TOOLS}"
132 DEFINES+=" android_sdk_version=sdk_version_unused_in_webview_build"
133 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}"
134 if [[ -n "$CHROME_ANDROID_WEBVIEW_OFFICIAL_BUILD" ]]; then
135 DEFINES+=" logging_like_official_build=1"
136 DEFINES+=" tracing_like_official_build=1"
138 export GYP_DEFINES="${DEFINES}"