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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" | 158 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 ################################################################################ | 162 ################################################################################ |
163 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision | 163 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision |
164 # 7 on Linux or Mac is offically supported. To run this script, the system | 164 # 7 on Linux or Mac is offically supported. To run this script, the system |
165 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path. The | 165 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path. The |
166 # ANDROID_SDK_ROOT only needs to be set to override the default SDK which is in | 166 # ANDROID_SDK_ROOT only needs to be set to override the default SDK which is in |
167 # the tree under $ROOT/src/third_party/android_tools/sdk. | 167 # the tree under $ROOT/src/third_party/android_tools/sdk. |
168 # TODO(navabi): Add NDK to $ROOT/src/third_party/android_tools/ndk. | |
169 # To build Chromium for Android with NDK/SDK follow the steps below: | 168 # To build Chromium for Android with NDK/SDK follow the steps below: |
170 # > export ANDROID_NDK_ROOT=<android ndk root> | 169 # > export ANDROID_NDK_ROOT=<android ndk root> |
171 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk | 170 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk |
172 # > . build/android/envsetup.sh --sdk | 171 # > . build/android/envsetup.sh |
173 # > make | 172 # > make |
174 ################################################################################ | 173 ################################################################################ |
175 sdk_build_init() { | 174 sdk_build_init() { |
176 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by | 175 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by |
177 # the environment variable. Otherwise, use the default ndk from the tree. | 176 # the environment variable. Otherwise, use the default ndk from the tree. |
178 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then | 177 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then |
179 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | 178 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
180 fi | 179 fi |
181 | 180 |
182 # If ANDROID_SDK_ROOT is set when envsetup is run, and if it has the | 181 # If ANDROID_SDK_ROOT is set when envsetup is run, and if it has the |
183 # right SDK-compatible directory layout, use the sdk pointed to by the | 182 # right SDK-compatible directory layout, use the sdk pointed to by the |
184 # environment variable. Otherwise, use the default sdk from the tree. | 183 # environment variable. Otherwise, use the default sdk from the tree. |
185 local sdk_suffix=platforms/android-${ANDROID_SDK_VERSION} | 184 local sdk_suffix=platforms/android-${ANDROID_SDK_VERSION} |
186 if [[ -z "${ANDROID_SDK_ROOT}" || \ | 185 if [[ -z "${ANDROID_SDK_ROOT}" || \ |
187 ! -d "${ANDROID_SDK_ROOT}/${sdk_suffix}" ]]; then | 186 ! -d "${ANDROID_SDK_ROOT}/${sdk_suffix}" ]]; then |
188 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" | 187 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" |
189 fi | 188 fi |
190 | 189 |
191 # Makes sure ANDROID_BUILD_TOP is unset if build has option --sdk | |
192 unset ANDROID_BUILD_TOP | 190 unset ANDROID_BUILD_TOP |
193 | 191 |
194 # Set default target. | 192 # Set default target. |
195 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" | 193 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" |
196 | 194 |
197 # Unset toolchain so that it can be set based on TARGET_PRODUCT. | 195 # Unset toolchain so that it can be set based on TARGET_PRODUCT. |
198 # This makes it easy to switch between architectures. | 196 # This makes it easy to switch between architectures. |
199 unset ANDROID_TOOLCHAIN | 197 unset ANDROID_TOOLCHAIN |
200 | 198 |
201 common_vars_defines | 199 common_vars_defines |
(...skipping 27 matching lines...) Expand all Loading... |
229 # system and build inside an Android source tree. | 227 # system and build inside an Android source tree. |
230 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ | 228 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ |
231 >& 2 | 229 >& 2 |
232 echo "Try . build/android/envsetup.sh instead." >& 2 | 230 echo "Try . build/android/envsetup.sh instead." >& 2 |
233 return 1 | 231 return 1 |
234 fi | 232 fi |
235 | 233 |
236 } | 234 } |
237 | 235 |
238 ################################################################################ | 236 ################################################################################ |
239 # Initializes environment variables for build with android source. This expects | |
240 # android environment to be set up along with lunch. To build: | |
241 # > . build/envsetup.sh | |
242 # > lunch <lunch-type> | |
243 # > . build/android/envsetup.sh | |
244 # > make | |
245 ############################################################################# | |
246 non_sdk_build_init() { | |
247 # We export "TOP" here so that "mmm" can be run to build Java code without | |
248 # having to cd to $ANDROID_BUILD_TOP. | |
249 export TOP="$ANDROID_BUILD_TOP" | |
250 | |
251 # Set "ANDROID_NDK_ROOT" as checked-in version, if it was not set. | |
252 if [[ "${ANDROID_NDK_ROOT}" || ! -d "$ANDROID_NDK_ROOT" ]] ; then | |
253 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | |
254 fi | |
255 if [[ ! -d "${ANDROID_NDK_ROOT}" ]] ; then | |
256 echo "Can not find Android NDK root ${ANDROID_NDK_ROOT}." >& 2 | |
257 return 1 | |
258 fi | |
259 | |
260 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. | |
261 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | |
262 ${ANDROID_SDK_VERSION} | |
263 # Needed by android antfiles when creating apks. | |
264 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} | |
265 | |
266 # Unset ANDROID_TOOLCHAIN, so it could be set to checked-in 64-bit toolchain. | |
267 # in common_vars_defines | |
268 unset ANDROID_TOOLCHAIN | |
269 | |
270 common_vars_defines | |
271 | |
272 DEFINES+=" sdk_build=0" | |
273 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" | |
274 | |
275 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then | |
276 webview_build_init | |
277 return | |
278 fi | |
279 | |
280 # The non-SDK build currently requires the SDK path to build the framework | |
281 # Java aidl files. TODO(steveblock): Investigate avoiding this requirement. | |
282 DEFINES+=" android_sdk=${ANDROID_SDK_ROOT}" | |
283 DEFINES+=" android_sdk_root=${ANDROID_SDK_ROOT}" | |
284 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/../tools/linux" | |
285 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" | |
286 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}" | |
287 | |
288 common_gyp_vars | |
289 } | |
290 | |
291 ################################################################################ | |
292 # To build WebView, we use the Android build system and build inside an Android | 237 # To build WebView, we use the Android build system and build inside an Android |
293 # source tree. This method is called from non_sdk_build_init() and adds to the | 238 # source tree. This method is called from non_sdk_build_init() and adds to the |
294 # settings specified there. | 239 # settings specified there. |
295 ############################################################################# | 240 ############################################################################# |
296 webview_build_init() { | 241 webview_build_init() { |
297 # For the WebView build we always use the NDK and SDK in the Android tree, | 242 # For the WebView build we always use the NDK and SDK in the Android tree, |
298 # and we don't touch ANDROID_TOOLCHAIN which is already set by Android. | 243 # and we don't touch ANDROID_TOOLCHAIN which is already set by Android. |
299 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 | 244 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/8 |
300 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | 245 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
301 ${ANDROID_SDK_VERSION} | 246 ${ANDROID_SDK_VERSION} |
(...skipping 23 matching lines...) Expand all Loading... |
325 export GYP_DEFINES="${DEFINES}" | 270 export GYP_DEFINES="${DEFINES}" |
326 | 271 |
327 export GYP_GENERATORS="android" | 272 export GYP_GENERATORS="android" |
328 | 273 |
329 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 274 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
330 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" | 275 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" |
331 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" | 276 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" |
332 | 277 |
333 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" | 278 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" |
334 } | 279 } |
OLD | NEW |