OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Defines functions for envsetup.sh which sets up environment for building | 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 | 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 | 9 # android source tree. Each has a unique init function which calls functions |
10 # prefixed with "common_" that is common for both environment setups. | 10 # prefixed with "common_" that is common for both environment setups. |
11 | 11 |
12 ################################################################################ | 12 ################################################################################ |
13 # Check to make sure the toolchain exists for the NDK version. | |
14 ################################################################################ | |
15 common_check_toolchain() { | |
16 if [[ ! -d "${ANDROID_TOOLCHAIN}" ]]; then | |
17 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 | |
18 echo "The NDK version might be wrong." >& 2 | |
19 return 1 | |
20 fi | |
21 } | |
22 | |
23 ################################################################################ | |
24 # Exports environment variables common to both sdk and non-sdk build (e.g. PATH) | 13 # Exports environment variables common to both sdk and non-sdk build (e.g. PATH) |
25 # based on CHROME_SRC and ANDROID_TOOLCHAIN, along with DEFINES for GYP_DEFINES. | 14 # based on CHROME_SRC, along with DEFINES for GYP_DEFINES. |
26 ################################################################################ | 15 ################################################################################ |
27 common_vars_defines() { | 16 common_vars_defines() { |
28 # Set toolchain path according to product architecture. | |
29 case "${TARGET_ARCH}" in | |
30 "arm") | |
31 toolchain_arch="arm-linux-androideabi" | |
32 ;; | |
33 "x86") | |
34 toolchain_arch="x86" | |
35 ;; | |
36 "mips") | |
37 toolchain_arch="mipsel-linux-android" | |
38 ;; | |
39 *) | |
40 echo "TARGET_ARCH: ${TARGET_ARCH} is not supported." >& 2 | |
41 print_usage | |
42 return 1 | |
43 ;; | |
44 esac | |
45 | |
46 toolchain_version="4.6" | |
47 toolchain_target=$(basename \ | |
48 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-${toolchain_version}) | |
49 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ | |
50 "/prebuilt/${toolchain_dir}/bin/" | |
51 | |
52 # Set only if not already set. | |
53 # Don't override ANDROID_TOOLCHAIN if set by Android configuration env. | |
54 export ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${toolchain_path}} | |
55 | |
56 common_check_toolchain | |
57 | |
58 # Add Android SDK tools to system path. | 17 # Add Android SDK tools to system path. |
59 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools | 18 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools |
60 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools | 19 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools |
61 export PATH=$PATH:${ANDROID_SDK_ROOT}/build-tools/\ | 20 export PATH=$PATH:${ANDROID_SDK_ROOT}/build-tools/\ |
62 ${ANDROID_SDK_BUILD_TOOLS_VERSION} | 21 ${ANDROID_SDK_BUILD_TOOLS_VERSION} |
63 | 22 |
64 # Add Chromium Android development scripts to system path. | 23 # Add Chromium Android development scripts to system path. |
65 # Must be after CHROME_SRC is set. | 24 # Must be after CHROME_SRC is set. |
66 export PATH=$PATH:${CHROME_SRC}/build/android | 25 export PATH=$PATH:${CHROME_SRC}/build/android |
67 | 26 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 fi | 124 fi |
166 if [[ -z "${ANDROID_SDK_ROOT}" || ! -d "${ANDROID_SDK_ROOT}" ]]; then | 125 if [[ -z "${ANDROID_SDK_ROOT}" || ! -d "${ANDROID_SDK_ROOT}" ]]; then |
167 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" | 126 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" |
168 else | 127 else |
169 sdk_defines+=" android_sdk_root=${ANDROID_SDK_ROOT}" | 128 sdk_defines+=" android_sdk_root=${ANDROID_SDK_ROOT}" |
170 fi | 129 fi |
171 if [[ -z "${ANDROID_SDK_BUILD_TOOLS_VERSION}" ]]; then | 130 if [[ -z "${ANDROID_SDK_BUILD_TOOLS_VERSION}" ]]; then |
172 export ANDROID_SDK_BUILD_TOOLS_VERSION=19.0.0 | 131 export ANDROID_SDK_BUILD_TOOLS_VERSION=19.0.0 |
173 fi | 132 fi |
174 | 133 |
175 # Unset toolchain. This makes it easy to switch between architectures. | |
176 unset ANDROID_TOOLCHAIN | |
177 | |
178 common_vars_defines | 134 common_vars_defines |
179 | 135 |
180 DEFINES+="${sdk_defines}" | 136 DEFINES+="${sdk_defines}" |
181 | 137 |
182 export GYP_DEFINES="${DEFINES}" | 138 export GYP_DEFINES="${DEFINES}" |
183 | 139 |
184 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then | 140 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then |
185 # Can not build WebView with NDK/SDK because it needs the Android build | 141 # Can not build WebView with NDK/SDK because it needs the Android build |
186 # system and build inside an Android source tree. | 142 # system and build inside an Android source tree. |
187 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ | 143 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ |
188 >& 2 | 144 >& 2 |
189 echo "Try . build/android/envsetup.sh instead." >& 2 | 145 echo "Try . build/android/envsetup.sh instead." >& 2 |
190 return 1 | 146 return 1 |
191 fi | 147 fi |
192 | 148 |
193 # Directory containing build-tools: aapt, aidl, dx | 149 # Directory containing build-tools: aapt, aidl, dx |
194 export ANDROID_SDK_TOOLS="${ANDROID_SDK_ROOT}/build-tools/\ | 150 export ANDROID_SDK_TOOLS="${ANDROID_SDK_ROOT}/build-tools/\ |
195 ${ANDROID_SDK_BUILD_TOOLS_VERSION}" | 151 ${ANDROID_SDK_BUILD_TOOLS_VERSION}" |
196 } | 152 } |
197 | 153 |
198 ################################################################################ | 154 ################################################################################ |
199 # To build WebView, we use the Android build system and build inside an Android | 155 # To build WebView, we use the Android build system and build inside an Android |
200 # source tree. | 156 # source tree. |
201 ############################################################################# | 157 ############################################################################# |
202 webview_build_init() { | 158 webview_build_init() { |
203 # Use the latest API in the AOSP prebuilts directory (change with AOSP roll). | 159 # Use the latest API in the AOSP prebuilts directory (change with AOSP roll). |
204 export ANDROID_SDK_VERSION=18 | 160 export ANDROID_SDK_VERSION=18 |
205 | 161 |
206 # For the WebView build we always use the NDK and SDK in the Android tree, | 162 # For the WebView build we always use the NDK and SDK in the Android tree. |
207 # and we don't touch ANDROID_TOOLCHAIN which is already set by Android. | |
208 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 | 163 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 |
209 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | 164 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
210 ${ANDROID_SDK_VERSION} | 165 ${ANDROID_SDK_VERSION} |
211 | 166 |
212 common_vars_defines | 167 common_vars_defines |
213 | 168 |
214 # We need to supply SDK paths relative to the top of the Android tree to make | 169 # We need to supply SDK paths relative to the top of the Android tree to make |
215 # sure the generated Android makefiles are portable, as they will be checked | 170 # sure the generated Android makefiles are portable, as they will be checked |
216 # into the Android tree. | 171 # into the Android tree. |
217 ANDROID_SDK=$(python -c \ | 172 ANDROID_SDK=$(python -c \ |
(...skipping 19 matching lines...) Expand all Loading... |
237 DEFINES+=" android_sdk_root=\$(PWD)/${ANDROID_SDK}" | 192 DEFINES+=" android_sdk_root=\$(PWD)/${ANDROID_SDK}" |
238 DEFINES+=" android_sdk_tools=\$(PWD)/${ANDROID_SDK_TOOLS}" | 193 DEFINES+=" android_sdk_tools=\$(PWD)/${ANDROID_SDK_TOOLS}" |
239 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" | 194 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" |
240 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}" | 195 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}" |
241 if [[ -n "$CHROME_ANDROID_WEBVIEW_OFFICIAL_BUILD" ]]; then | 196 if [[ -n "$CHROME_ANDROID_WEBVIEW_OFFICIAL_BUILD" ]]; then |
242 DEFINES+=" logging_like_official_build=1" | 197 DEFINES+=" logging_like_official_build=1" |
243 DEFINES+=" tracing_like_official_build=1" | 198 DEFINES+=" tracing_like_official_build=1" |
244 fi | 199 fi |
245 export GYP_DEFINES="${DEFINES}" | 200 export GYP_DEFINES="${DEFINES}" |
246 } | 201 } |
OLD | NEW |