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. | 13 # Check to make sure the toolchain exists for the NDK version. |
14 ################################################################################ | 14 ################################################################################ |
15 common_check_toolchain() { | 15 common_check_toolchain() { |
16 if [[ ! -d "${ANDROID_TOOLCHAIN}" ]]; then | 16 if [[ ! -d "${ANDROID_TOOLCHAIN}" ]]; then |
17 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 | 17 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 |
18 echo "The NDK version might be wrong." >& 2 | 18 echo "The NDK version might be wrong." >& 2 |
19 return 1 | 19 return 1 |
20 fi | 20 fi |
21 } | 21 } |
22 | 22 |
23 ################################################################################ | 23 ################################################################################ |
24 # Exports environment variables common to both sdk and non-sdk build (e.g. PATH) | 24 # 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. | 25 # based on CHROME_SRC and ANDROID_TOOLCHAIN, along with DEFINES for GYP_DEFINES. |
26 ################################################################################ | 26 ################################################################################ |
27 common_vars_defines() { | 27 common_vars_defines() { |
28 | 28 |
29 # Set toolchain path according to product architecture. | 29 # Set toolchain path according to product architecture. |
30 toolchain_arch="arm" | 30 toolchain_arch="arm-linux-androideabi" |
31 if [[ "${TARGET_PRODUCT}" =~ .*x86.* ]]; then | 31 if [[ "${TARGET_PRODUCT}" =~ .*x86.* ]]; then |
32 toolchain_arch="x86" | 32 toolchain_arch="x86" |
| 33 toolchain_dir="linux-x86" |
33 fi | 34 fi |
34 | 35 |
| 36 toolchain_version="4.6" |
35 toolchain_target=$(basename \ | 37 toolchain_target=$(basename \ |
36 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-*) | 38 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-${toolchain_version}) |
37 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ | 39 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ |
38 "/prebuilt/${toolchain_dir}/bin/" | 40 "/prebuilt/${toolchain_dir}/bin/" |
39 | 41 |
40 # Set only if not already set. | 42 # Set only if not already set. |
41 # Don't override ANDROID_TOOLCHAIN if set by Android configuration env. | 43 # Don't override ANDROID_TOOLCHAIN if set by Android configuration env. |
42 export ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${toolchain_path}} | 44 export ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${toolchain_path}} |
43 | 45 |
44 common_check_toolchain | 46 common_check_toolchain |
45 | 47 |
46 # Add Android SDK/NDK tools to system path. | 48 # Add Android SDK/NDK tools to system path. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 # Can not build WebView with NDK/SDK because it needs the Android build | 202 # Can not build WebView with NDK/SDK because it needs the Android build |
201 # system and build inside an Android source tree. | 203 # system and build inside an Android source tree. |
202 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ | 204 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ |
203 >& 2 | 205 >& 2 |
204 echo "Try . build/android/envsetup.sh instead." >& 2 | 206 echo "Try . build/android/envsetup.sh instead." >& 2 |
205 return 1 | 207 return 1 |
206 fi | 208 fi |
207 | 209 |
208 } | 210 } |
209 | 211 |
210 | |
211 ################################################################################ | 212 ################################################################################ |
212 # Initializes environment variables for build with android source. This expects | 213 # Initializes environment variables for build with android source. This expects |
213 # android environment to be set up along with lunch. To build: | 214 # android environment to be set up along with lunch. To build: |
214 # > . build/envsetup.sh | 215 # > . build/envsetup.sh |
215 # > lunch <lunch-type> | 216 # > lunch <lunch-type> |
216 # > . build/android/envsetup.sh | 217 # > . build/android/envsetup.sh |
217 # > make | 218 # > make |
218 ############################################################################# | 219 ############################################################################# |
219 non_sdk_build_init() { | 220 non_sdk_build_init() { |
220 # We export "TOP" here so that "mmm" can be run to build Java code without | 221 # We export "TOP" here so that "mmm" can be run to build Java code without |
221 # having to cd to $ANDROID_BUILD_TOP. | 222 # having to cd to $ANDROID_BUILD_TOP. |
222 export TOP="$ANDROID_BUILD_TOP" | 223 export TOP="$ANDROID_BUILD_TOP" |
223 | 224 |
224 # We export "ANDROID_NDK_ROOT" for building Chromium for Android by NDK. | 225 # Set "ANDROID_NDK_ROOT" as checked-in version, if it was not set. |
225 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/android-ndk-r7 | 226 if [ ! -d "$ANDROID_NDK_ROOT" ] ; then |
| 227 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
| 228 fi |
| 229 if [ ! -d "$ANDROID_NDK_ROOT" ] ; then |
| 230 echo "Can not find Android NDK root ${ANDROID_NDK_ROOT}." >& 2 |
| 231 return 1 |
| 232 fi |
226 | 233 |
227 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. | 234 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. |
228 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | 235 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
229 ${ANDROID_SDK_VERSION} | 236 ${ANDROID_SDK_VERSION} |
230 # Needed by android antfiles when creating apks. | 237 # Needed by android antfiles when creating apks. |
231 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} | 238 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} |
232 | 239 |
| 240 # Unset ANDROID_TOOLCHAIN, so it could be set to checked-in 64-bit toolchain. |
| 241 # in common_vars_defines |
| 242 unset ANDROID_TOOLCHAIN |
| 243 |
233 common_vars_defines | 244 common_vars_defines |
234 | 245 |
235 DEFINES+=" sdk_build=0" | 246 DEFINES+=" sdk_build=0" |
236 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" | 247 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" |
237 | 248 |
238 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then | 249 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then |
239 webview_build_init | 250 webview_build_init |
240 return | 251 return |
241 fi | 252 fi |
242 | 253 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 288 |
278 export GYP_GENERATORS="android" | 289 export GYP_GENERATORS="android" |
279 | 290 |
280 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 291 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
281 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" | 292 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" |
282 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" | 293 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" |
283 | 294 |
284 # TODO(torne): This isn't upstream yet. Upstream it or remove this setting. | 295 # TODO(torne): This isn't upstream yet. Upstream it or remove this setting. |
285 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android_webview.gyp" | 296 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android_webview.gyp" |
286 } | 297 } |
OLD | NEW |