| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 # TODO(beverloo): Remove these once all consumers updated to --strip-binary. | 58 # TODO(beverloo): Remove these once all consumers updated to --strip-binary. |
| 59 export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy) | 59 export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy) |
| 60 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) | 60 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) |
| 61 | 61 |
| 62 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories | 62 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories |
| 63 # to canonicalize them (remove double '/', remove trailing '/', etc). | 63 # to canonicalize them (remove double '/', remove trailing '/', etc). |
| 64 DEFINES="OS=android" | 64 DEFINES="OS=android" |
| 65 DEFINES+=" host_os=${host_os}" | 65 DEFINES+=" host_os=${host_os}" |
| 66 | 66 |
| 67 if [ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]; then | 67 if [[ -n "$CHROME_ANDROID_OFFICIAL_BUILD" ]]; then |
| 68 DEFINES+=" branding=Chrome" | 68 DEFINES+=" branding=Chrome" |
| 69 DEFINES+=" buildtype=Official" | 69 DEFINES+=" buildtype=Official" |
| 70 | 70 |
| 71 # These defines are used by various chrome build scripts to tag the binary's | 71 # These defines are used by various chrome build scripts to tag the binary's |
| 72 # version string as 'official' in linux builds (e.g. in | 72 # version string as 'official' in linux builds (e.g. in |
| 73 # chrome/trunk/src/chrome/tools/build/version.py). | 73 # chrome/trunk/src/chrome/tools/build/version.py). |
| 74 export OFFICIAL_BUILD=1 | 74 export OFFICIAL_BUILD=1 |
| 75 export CHROMIUM_BUILD="_google_chrome" | 75 export CHROMIUM_BUILD="_google_chrome" |
| 76 export CHROME_BUILD_TYPE="_official" | 76 export CHROME_BUILD_TYPE="_official" |
| 77 | 77 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 # TODO(navabi): Add NDK to $ROOT/src/third_party/android_tools/ndk. | 161 # TODO(navabi): Add NDK to $ROOT/src/third_party/android_tools/ndk. |
| 162 # To build Chromium for Android with NDK/SDK follow the steps below: | 162 # To build Chromium for Android with NDK/SDK follow the steps below: |
| 163 # > export ANDROID_NDK_ROOT=<android ndk root> | 163 # > export ANDROID_NDK_ROOT=<android ndk root> |
| 164 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk | 164 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk |
| 165 # > . build/android/envsetup.sh --sdk | 165 # > . build/android/envsetup.sh --sdk |
| 166 # > make | 166 # > make |
| 167 ################################################################################ | 167 ################################################################################ |
| 168 sdk_build_init() { | 168 sdk_build_init() { |
| 169 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by | 169 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by |
| 170 # the environment variable. Otherwise, use the default ndk from the tree. | 170 # the environment variable. Otherwise, use the default ndk from the tree. |
| 171 if [ ! -d "${ANDROID_NDK_ROOT}" ]; then | 171 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then |
| 172 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | 172 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
| 173 fi | 173 fi |
| 174 | 174 |
| 175 # If ANDROID_SDK_ROOT is set when envsetup is run, use the sdk pointed to by | 175 # If ANDROID_SDK_ROOT is set when envsetup is run, and if it has the |
| 176 # the environment variable. Otherwise, use the default sdk from the tree. | 176 # right SDK-compatible directory layout, use the sdk pointed to by the |
| 177 if [ ! -d "${ANDROID_SDK_ROOT}" ]; then | 177 # environment variable. Otherwise, use the default sdk from the tree. |
| 178 local sdk_suffix=platforms/android-${ANDROID_SDK_VERSION} |
| 179 if [[ -z "${ANDROID_SDK_ROOT}" || \ |
| 180 ! -d "${ANDROID_SDK_ROOT}/${sdk_suffix}" ]]; then |
| 178 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" | 181 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" |
| 179 fi | 182 fi |
| 180 | 183 |
| 181 # Makes sure ANDROID_BUILD_TOP is unset if build has option --sdk | 184 # Makes sure ANDROID_BUILD_TOP is unset if build has option --sdk |
| 182 unset ANDROID_BUILD_TOP | 185 unset ANDROID_BUILD_TOP |
| 183 | 186 |
| 184 # Set default target. | 187 # Set default target. |
| 185 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" | 188 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" |
| 186 | 189 |
| 187 # Unset toolchain so that it can be set based on TARGET_PRODUCT. | 190 # Unset toolchain so that it can be set based on TARGET_PRODUCT. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 199 ;; | 202 ;; |
| 200 esac | 203 esac |
| 201 | 204 |
| 202 # Sets android specific directories to NOT_SDK_COMPLIANT. This will allow | 205 # Sets android specific directories to NOT_SDK_COMPLIANT. This will allow |
| 203 # android_gyp to generate make files, but will cause errors when (and only | 206 # android_gyp to generate make files, but will cause errors when (and only |
| 204 # when) building targets that depend on these directories. | 207 # when) building targets that depend on these directories. |
| 205 DEFINES+=" android_src='NOT_SDK_COMPLIANT'" | 208 DEFINES+=" android_src='NOT_SDK_COMPLIANT'" |
| 206 DEFINES+=" android_product_out=${CHROME_SRC}/out/android" | 209 DEFINES+=" android_product_out=${CHROME_SRC}/out/android" |
| 207 DEFINES+=" android_lib='NOT_SDK_COMPLIANT'" | 210 DEFINES+=" android_lib='NOT_SDK_COMPLIANT'" |
| 208 DEFINES+=" android_static_lib='NOT_SDK_COMPLIANT'" | 211 DEFINES+=" android_static_lib='NOT_SDK_COMPLIANT'" |
| 209 DEFINES+=\ | 212 DEFINES+=" android_sdk=${ANDROID_SDK_ROOT}/${sdk_suffix}" |
| 210 " android_sdk=${ANDROID_SDK_ROOT}/platforms/android-${ANDROID_SDK_VERSION}" | |
| 211 DEFINES+=" android_sdk_root=${ANDROID_SDK_ROOT}" | 213 DEFINES+=" android_sdk_root=${ANDROID_SDK_ROOT}" |
| 212 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools" | 214 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools" |
| 213 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" | 215 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" |
| 214 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}" | 216 DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}" |
| 215 | 217 |
| 216 common_gyp_vars | 218 common_gyp_vars |
| 217 | 219 |
| 218 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then | 220 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then |
| 219 # Can not build WebView with NDK/SDK because it needs the Android build | 221 # Can not build WebView with NDK/SDK because it needs the Android build |
| 220 # system and build inside an Android source tree. | 222 # system and build inside an Android source tree. |
| 221 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ | 223 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ |
| 222 >& 2 | 224 >& 2 |
| 223 echo "Try . build/android/envsetup.sh instead." >& 2 | 225 echo "Try . build/android/envsetup.sh instead." >& 2 |
| 224 return 1 | 226 return 1 |
| 225 fi | 227 fi |
| 226 | 228 |
| 227 } | 229 } |
| 228 | 230 |
| 229 ################################################################################ | 231 ################################################################################ |
| 230 # Initializes environment variables for build with android source. This expects | 232 # Initializes environment variables for build with android source. This expects |
| 231 # android environment to be set up along with lunch. To build: | 233 # android environment to be set up along with lunch. To build: |
| 232 # > . build/envsetup.sh | 234 # > . build/envsetup.sh |
| 233 # > lunch <lunch-type> | 235 # > lunch <lunch-type> |
| 234 # > . build/android/envsetup.sh | 236 # > . build/android/envsetup.sh |
| 235 # > make | 237 # > make |
| 236 ############################################################################# | 238 ############################################################################# |
| 237 non_sdk_build_init() { | 239 non_sdk_build_init() { |
| 238 # We export "TOP" here so that "mmm" can be run to build Java code without | 240 # We export "TOP" here so that "mmm" can be run to build Java code without |
| 239 # having to cd to $ANDROID_BUILD_TOP. | 241 # having to cd to $ANDROID_BUILD_TOP. |
| 240 export TOP="$ANDROID_BUILD_TOP" | 242 export TOP="$ANDROID_BUILD_TOP" |
| 241 | 243 |
| 242 # Set "ANDROID_NDK_ROOT" as checked-in version, if it was not set. | 244 # Set "ANDROID_NDK_ROOT" as checked-in version, if it was not set. |
| 243 if [ ! -d "$ANDROID_NDK_ROOT" ] ; then | 245 if [[ "${ANDROID_NDK_ROOT}" || ! -d "$ANDROID_NDK_ROOT" ]] ; then |
| 244 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | 246 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
| 245 fi | 247 fi |
| 246 if [ ! -d "$ANDROID_NDK_ROOT" ] ; then | 248 if [[ ! -d "${ANDROID_NDK_ROOT}" ]] ; then |
| 247 echo "Can not find Android NDK root ${ANDROID_NDK_ROOT}." >& 2 | 249 echo "Can not find Android NDK root ${ANDROID_NDK_ROOT}." >& 2 |
| 248 return 1 | 250 return 1 |
| 249 fi | 251 fi |
| 250 | 252 |
| 251 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. | 253 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. |
| 252 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ | 254 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
| 253 ${ANDROID_SDK_VERSION} | 255 ${ANDROID_SDK_VERSION} |
| 254 # Needed by android antfiles when creating apks. | 256 # Needed by android antfiles when creating apks. |
| 255 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} | 257 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} |
| 256 | 258 |
| 257 # Unset ANDROID_TOOLCHAIN, so it could be set to checked-in 64-bit toolchain. | 259 # Unset ANDROID_TOOLCHAIN, so it could be set to checked-in 64-bit toolchain. |
| 258 # in common_vars_defines | 260 # in common_vars_defines |
| 259 unset ANDROID_TOOLCHAIN | 261 unset ANDROID_TOOLCHAIN |
| 260 | 262 |
| 261 common_vars_defines | 263 common_vars_defines |
| 262 | 264 |
| 263 DEFINES+=" sdk_build=0" | 265 DEFINES+=" sdk_build=0" |
| 264 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" | 266 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" |
| 265 | 267 |
| 266 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then | 268 if [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then |
| 267 webview_build_init | 269 webview_build_init |
| 268 return | 270 return |
| 269 fi | 271 fi |
| 270 | 272 |
| 271 # The non-SDK build currently requires the SDK path to build the framework | 273 # The non-SDK build currently requires the SDK path to build the framework |
| 272 # Java aidl files. TODO(steveblock): Investigate avoiding this requirement. | 274 # Java aidl files. TODO(steveblock): Investigate avoiding this requirement. |
| 273 DEFINES+=" android_sdk=${ANDROID_SDK_ROOT}" | 275 DEFINES+=" android_sdk=${ANDROID_SDK_ROOT}" |
| 274 DEFINES+=" android_sdk_root=${ANDROID_SDK_ROOT}" | 276 DEFINES+=" android_sdk_root=${ANDROID_SDK_ROOT}" |
| 275 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/../tools/linux" | 277 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/../tools/linux" |
| 276 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" | 278 DEFINES+=" android_sdk_version=${ANDROID_SDK_VERSION}" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 305 | 307 |
| 306 export GYP_GENERATORS="android" | 308 export GYP_GENERATORS="android" |
| 307 | 309 |
| 308 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 310 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 309 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" |
| 310 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" | 312 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" |
| 311 | 313 |
| 312 # TODO(torne): This isn't upstream yet. Upstream it or remove this setting. | 314 # TODO(torne): This isn't upstream yet. Upstream it or remove this setting. |
| 313 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android_webview.gyp" | 315 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android_webview.gyp" |
| 314 } | 316 } |
| OLD | NEW |