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. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 export PATH=$PATH:${CHROME_SRC}/build/android/${toolchain_arch}-gold | 69 export PATH=$PATH:${CHROME_SRC}/build/android/${toolchain_arch}-gold |
70 | 70 |
71 # Add Chromium Android development scripts to system path. | 71 # Add Chromium Android development scripts to system path. |
72 # Must be after CHROME_SRC is set. | 72 # Must be after CHROME_SRC is set. |
73 export PATH=$PATH:${CHROME_SRC}/build/android | 73 export PATH=$PATH:${CHROME_SRC}/build/android |
74 | 74 |
75 # TODO(beverloo): Remove these once all consumers updated to --strip-binary. | 75 # TODO(beverloo): Remove these once all consumers updated to --strip-binary. |
76 # http://crbug.com/142642 | 76 # http://crbug.com/142642 |
77 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) | 77 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) |
78 | 78 |
79 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories | 79 # The set of GYP_DEFINES to pass to gyp. |
80 # to canonicalize them (remove double '/', remove trailing '/', etc). | |
81 DEFINES="OS=android" | 80 DEFINES="OS=android" |
82 DEFINES+=" host_os=${host_os}" | 81 DEFINES+=" host_os=${host_os}" |
83 | 82 |
84 if [[ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]]; then | 83 if [[ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]]; then |
85 DEFINES+=" branding=Chrome" | 84 DEFINES+=" branding=Chrome" |
86 DEFINES+=" buildtype=Official" | 85 DEFINES+=" buildtype=Official" |
87 | 86 |
88 # These defines are used by various chrome build scripts to tag the binary's | 87 # These defines are used by various chrome build scripts to tag the binary's |
89 # version string as 'official' in linux builds (e.g. in | 88 # version string as 'official' in linux builds (e.g. in |
90 # chrome/trunk/src/chrome/tools/build/version.py). | 89 # chrome/trunk/src/chrome/tools/build/version.py). |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 print_usage() { | 156 print_usage() { |
158 echo "usage: ${0##*/} [--target-arch=value] [--help]" >& 2 | 157 echo "usage: ${0##*/} [--target-arch=value] [--help]" >& 2 |
159 echo "--target-arch=value target CPU architecture (arm=default, x86)" >& 2 | 158 echo "--target-arch=value target CPU architecture (arm=default, x86)" >& 2 |
160 echo "--host-os=value override host OS detection (linux, mac)" >&2 | 159 echo "--host-os=value override host OS detection (linux, mac)" >&2 |
161 echo "--try-32bit-host try building a 32-bit host architecture" >&2 | 160 echo "--try-32bit-host try building a 32-bit host architecture" >&2 |
162 echo "--help this help" >& 2 | 161 echo "--help this help" >& 2 |
163 } | 162 } |
164 | 163 |
165 ################################################################################ | 164 ################################################################################ |
166 # Process command line options. | 165 # Process command line options. |
167 # --target-arch= Specifices target CPU architecture. Currently supported | |
168 # architectures are "arm" (default), and "x86". | |
169 # --help Prints out help message. | |
170 ################################################################################ | 166 ################################################################################ |
171 process_options() { | 167 process_options() { |
172 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') | 168 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') |
173 try_32bit_host_build= | 169 try_32bit_host_build= |
174 while [[ -n $1 ]]; do | 170 while [[ -n $1 ]]; do |
175 case "$1" in | 171 case "$1" in |
176 --target-arch=*) | 172 --target-arch=*) |
177 target_arch="$(echo "$1" | sed 's/^[^=]*=//')" | 173 target_arch="$(echo "$1" | sed 's/^[^=]*=//')" |
178 ;; | 174 ;; |
179 --host-os=*) | 175 --host-os=*) |
(...skipping 12 matching lines...) Expand all Loading... |
192 ;; | 188 ;; |
193 esac | 189 esac |
194 shift | 190 shift |
195 done | 191 done |
196 | 192 |
197 # Sets TARGET_ARCH. Defaults to arm if not specified. | 193 # Sets TARGET_ARCH. Defaults to arm if not specified. |
198 TARGET_ARCH=${target_arch:-arm} | 194 TARGET_ARCH=${target_arch:-arm} |
199 } | 195 } |
200 | 196 |
201 ################################################################################ | 197 ################################################################################ |
202 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision | 198 # Initializes environment variables for NDK/SDK build. |
203 # 7 on Linux or Mac is offically supported. To run this script, the system | |
204 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path. The | |
205 # ANDROID_SDK_ROOT only needs to be set to override the default SDK which is in | |
206 # the tree under $ROOT/src/third_party/android_tools/sdk. | |
207 # To build Chromium for Android with NDK/SDK follow the steps below: | |
208 # > export ANDROID_NDK_ROOT=<android ndk root> | |
209 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk | |
210 # > . build/android/envsetup.sh | |
211 # > make | |
212 ################################################################################ | 199 ################################################################################ |
213 sdk_build_init() { | 200 sdk_build_init() { |
214 | 201 |
215 # Allow the caller to override a few environment variables. If any of them is | 202 # Allow the caller to override a few environment variables. If any of them is |
216 # unset, we default to a sane value that's known to work. This allows for | 203 # unset, we default to a sane value that's known to work. This allows for |
217 # experimentation with a custom SDK. | 204 # experimentation with a custom SDK. |
218 local sdk_defines="" | 205 local sdk_defines="" |
219 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then | 206 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then |
220 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | 207 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
221 fi | 208 fi |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 return 1 | 246 return 1 |
260 fi | 247 fi |
261 | 248 |
262 # Directory containing build-tools: aapt, aidl, dx | 249 # Directory containing build-tools: aapt, aidl, dx |
263 export ANDROID_SDK_TOOLS="${ANDROID_SDK_ROOT}/build-tools/\ | 250 export ANDROID_SDK_TOOLS="${ANDROID_SDK_ROOT}/build-tools/\ |
264 ${ANDROID_SDK_BUILD_TOOLS_VERSION}" | 251 ${ANDROID_SDK_BUILD_TOOLS_VERSION}" |
265 } | 252 } |
266 | 253 |
267 ################################################################################ | 254 ################################################################################ |
268 # To build WebView, we use the Android build system and build inside an Android | 255 # To build WebView, we use the Android build system and build inside an Android |
269 # source tree. This method is called from non_sdk_build_init() and adds to the | 256 # source tree. |
270 # settings specified there. | |
271 ############################################################################# | 257 ############################################################################# |
272 webview_build_init() { | 258 webview_build_init() { |
273 # Use the latest API in the AOSP prebuilts directory (change with AOSP roll). | 259 # Use the latest API in the AOSP prebuilts directory (change with AOSP roll). |
274 export ANDROID_SDK_VERSION=18 | 260 export ANDROID_SDK_VERSION=18 |
275 | 261 |
276 # For the WebView build we always use the NDK and SDK in the Android tree, | 262 # For the WebView build we always use the NDK and SDK in the Android tree, |
277 # and we don't touch ANDROID_TOOLCHAIN which is already set by Android. | 263 # and we don't touch ANDROID_TOOLCHAIN which is already set by Android. |
278 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 | 264 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 |
279 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | 265 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
280 ${ANDROID_SDK_VERSION} | 266 ${ANDROID_SDK_VERSION} |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 fi | 305 fi |
320 export GYP_DEFINES="${DEFINES}" | 306 export GYP_DEFINES="${DEFINES}" |
321 | 307 |
322 export GYP_GENERATORS="android" | 308 export GYP_GENERATORS="android" |
323 | 309 |
324 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 310 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
325 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" | 311 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" |
326 | 312 |
327 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" | 313 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" |
328 } | 314 } |
OLD | NEW |