OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 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 |
| 5 # found in the LICENSE file. |
| 6 |
| 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 |
| 9 # android source tree. Each has a unique init function which calls functions |
| 10 # prefixed with "common_" that is common for both environment setups. |
| 11 |
| 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) |
| 25 # based on CHROME_SRC and ANDROID_TOOLCHAIN, along with DEFINES for GYP_DEFINES. |
| 26 ################################################################################ |
| 27 common_vars_defines() { |
| 28 |
| 29 # Set toolchain path according to product architecture. |
| 30 toolchain_arch="arm" |
| 31 if [[ "${TARGET_PRODUCT}" =~ .*x86.* ]]; then |
| 32 toolchain_arch="x86" |
| 33 fi |
| 34 |
| 35 toolchain_target=$(basename \ |
| 36 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-*) |
| 37 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ |
| 38 "/prebuilt/${toolchain_dir}/bin/" |
| 39 |
| 40 # Set only if not already set. |
| 41 # Don't override ANDROID_TOOLCHAIN if set by Android configuration env. |
| 42 export ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${toolchain_path}} |
| 43 |
| 44 common_check_toolchain |
| 45 |
| 46 # Add Android SDK/NDK tools to system path. |
| 47 export PATH=$PATH:${ANDROID_NDK_ROOT} |
| 48 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools |
| 49 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools |
| 50 # Must have tools like arm-linux-androideabi-gcc on the path for ninja |
| 51 export PATH=$PATH:${ANDROID_TOOLCHAIN} |
| 52 |
| 53 # Add Chromium Android development scripts to system path. |
| 54 # Must be after CHROME_SRC is set. |
| 55 export PATH=$PATH:${CHROME_SRC}/build/android |
| 56 |
| 57 export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy) |
| 58 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) |
| 59 |
| 60 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories |
| 61 # to canonicalize them (remove double '/', remove trailing '/', etc). |
| 62 DEFINES="OS=android" |
| 63 DEFINES+=" host_os=${host_os}" |
| 64 DEFINES+=" linux_fpic=1" |
| 65 DEFINES+=" release_optimize=s" |
| 66 DEFINES+=" linux_use_tcmalloc=0" |
| 67 DEFINES+=" disable_nacl=1" |
| 68 DEFINES+=" remoting=0" |
| 69 DEFINES+=" p2p_apis=0" |
| 70 DEFINES+=" enable_touch_events=1" |
| 71 DEFINES+=" build_ffmpegsumo=0" |
| 72 |
| 73 DEFINES+=" gtest_target_type=shared_library" |
| 74 if [ -z "$CHROME_ANDROID_OFFICIAL_BUILD" ]; then |
| 75 DEFINES+=" branding=Chromium" |
| 76 else |
| 77 DEFINES+=" branding=Chrome" |
| 78 DEFINES+=" buildtype=Official" |
| 79 |
| 80 # These defines are used by various chrome build scripts to tag the binary's |
| 81 # version string as 'official' in linux builds (e.g. in |
| 82 # chrome/trunk/src/chrome/tools/build/version.py). |
| 83 export OFFICIAL_BUILD=1 |
| 84 export CHROMIUM_BUILD="_google_chrome" |
| 85 export CHROME_BUILD_TYPE="_official" |
| 86 |
| 87 # Used by chrome_version_info_posix.cc to display the channel name. |
| 88 # Valid values: "unstable", "stable", "dev", "beta". |
| 89 export CHROME_VERSION_EXTRA="beta" |
| 90 fi |
| 91 |
| 92 # The order file specifies the order of symbols in the .text section of the |
| 93 # shared library, libchromeview.so. The file is an order list of section |
| 94 # names and the library is linked with option |
| 95 # --section-ordering-file=<orderfile>. The order file is updated by profiling |
| 96 # startup after compiling with the order_profiling=1 GYP_DEFINES flag. |
| 97 ORDER_DEFINES="order_text_section=${CHROME_SRC}/orderfiles/orderfile.out" |
| 98 |
| 99 # The following defines will affect ARM code generation of both C/C++ compiler |
| 100 # and V8 mksnapshot. |
| 101 case "${TARGET_PRODUCT}" in |
| 102 "passion"|"soju"|"sojua"|"sojus"|"yakju"|"mysid"|"nakasi") |
| 103 DEFINES+=" target_arch=arm" |
| 104 DEFINES+=" arm_neon=1 armv7=1 arm_thumb=1" |
| 105 DEFINES+=" ${ORDER_DEFINES}" |
| 106 ;; |
| 107 "trygon"|"tervigon") |
| 108 DEFINES+=" target_arch=arm" |
| 109 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16" |
| 110 DEFINES+=" ${ORDER_DEFINES}" |
| 111 ;; |
| 112 "full") |
| 113 DEFINES+=" target_arch=arm" |
| 114 DEFINES+=" arm_neon=0 armv7=0 arm_thumb=1 arm_fpu=vfp" |
| 115 ;; |
| 116 *x86*) |
| 117 # TODO(tedbo): The ia32 build fails on ffmpeg, so we disable it here. |
| 118 DEFINES+=" target_arch=ia32 use_libffmpeg=0" |
| 119 |
| 120 host_arch=$(uname -m | sed -e \ |
| 121 's/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/;s/i86pc/ia32/') |
| 122 DEFINES+=" host_arch=${host_arch}" |
| 123 ;; |
| 124 *) |
| 125 echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2 |
| 126 return 1 |
| 127 esac |
| 128 } |
| 129 |
| 130 |
| 131 ################################################################################ |
| 132 # Exports common GYP variables based on variable DEFINES and CHROME_SRC. |
| 133 ################################################################################ |
| 134 common_gyp_vars() { |
| 135 export GYP_DEFINES="${DEFINES}" |
| 136 export GYP_GENERATORS="make-android" |
| 137 |
| 138 # Use our All target as the default |
| 139 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 140 |
| 141 # We want to use our version of "all" targets. |
| 142 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" |
| 143 } |
| 144 |
| 145 |
| 146 ################################################################################ |
| 147 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision |
| 148 # 7 on Linux or Mac is offically supported. To run this script, the system |
| 149 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path as well as |
| 150 # ANDROID_SDK_ROOT to the SDK root. |
| 151 # To build Chromium for Android with NDK/SDK follow the steps below: |
| 152 # > export ANDROID_NDK_ROOT=<android ndk root> |
| 153 # > export ANDROID_SDK_ROOT=<android sdk root> |
| 154 # > . build/android/envsetup.sh --sdk |
| 155 # > make |
| 156 ############################################################################# |
| 157 sdk_build_init() { |
| 158 if [ ! -d "${ANDROID_NDK_ROOT}" ]; then |
| 159 echo "ANDROID_NDK_ROOT must be set to the path of Android NDK." >& 2 |
| 160 echo "which could be installed by" >& 2 |
| 161 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2 |
| 162 return 1 |
| 163 fi |
| 164 |
| 165 if [ ! -d "${ANDROID_SDK_ROOT}" ]; then |
| 166 echo "ANDROID_SDK_ROOT must be set to the path of Android SDK." >& 2 |
| 167 echo "which could be installed by" >& 2 |
| 168 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2 |
| 169 return 1 |
| 170 fi |
| 171 |
| 172 # Makes sure ANDROID_BUILD_TOP is unset if build has option --sdk |
| 173 unset ANDROID_BUILD_TOP |
| 174 |
| 175 # Set default target. |
| 176 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" |
| 177 |
| 178 # Android sdk platform version to use |
| 179 export ANDROID_SDK_VERSION=15 |
| 180 # Unset toolchain so that it can be set based on TARGET_PRODUCT. |
| 181 # This makes it easy to switch between architectures. |
| 182 unset ANDROID_TOOLCHAIN |
| 183 |
| 184 common_vars_defines |
| 185 |
| 186 DEFINES+=" sdk_build=1" |
| 187 # If we are building NDK/SDK, and in the upstream (open source) tree, |
| 188 # define a special variable for bringup purposes. |
| 189 case "${ANDROID_BUILD_TOP-undefined}" in |
| 190 "undefined") |
| 191 DEFINES+=" android_upstream_bringup=1" |
| 192 ;; |
| 193 esac |
| 194 |
| 195 # Sets android specific directories to NOT_SDK_COMPLIANT. This will allow |
| 196 # android_gyp to generate make files, but will cause errors when (and only |
| 197 # when) building targets that depend on these directories. |
| 198 DEFINES+=" android_src='NOT_SDK_COMPLIANT'" |
| 199 DEFINES+=" android_product_out=${CHROME_SRC}/out/android" |
| 200 DEFINES+=" android_lib='NOT_SDK_COMPLIANT'" |
| 201 DEFINES+=" android_static_lib='NOT_SDK_COMPLIANT'" |
| 202 DEFINES+=\ |
| 203 " android_sdk=${ANDROID_SDK_ROOT}/platforms/android-${ANDROID_SDK_VERSION}" |
| 204 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools" |
| 205 |
| 206 common_gyp_vars |
| 207 |
| 208 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then |
| 209 # Can not build WebView with NDK/SDK because it needs the Android build |
| 210 # system and build inside an Android source tree. |
| 211 echo "Can not build WebView with NDK/SDK. Requires android source tree." \ |
| 212 >& 2 |
| 213 echo "Try . build/android/envsetup.sh instead." >& 2 |
| 214 return 1 |
| 215 fi |
| 216 |
| 217 } |
| 218 |
| 219 |
| 220 ################################################################################ |
| 221 # Initializes environment variables for build with android source. This expects |
| 222 # android environment to be set up along with lunch. To build: |
| 223 # > . build/envsetup.sh |
| 224 # > lunch <lunch-type> |
| 225 # > . build/android/envsetup.sh |
| 226 # > make |
| 227 ############################################################################# |
| 228 non_sdk_build_init() { |
| 229 # We export "TOP" here so that "mmm" can be run to build Java code without |
| 230 # having to cd to $ANDROID_BUILD_TOP. |
| 231 export TOP="$ANDROID_BUILD_TOP" |
| 232 |
| 233 # We export "ANDROID_NDK_ROOT" for building Chromium for Android by NDK. |
| 234 export ANDROID_NDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/ndk/android-ndk-r7 |
| 235 |
| 236 # Android sdk platform version to use |
| 237 export ANDROID_SDK_VERSION=15 |
| 238 |
| 239 # We export "ANDROID_SDK_ROOT" for building Java source with the SDK. |
| 240 export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\ |
| 241 ${ANDROID_SDK_VERSION} |
| 242 # Needed by android antfiles when creating apks. |
| 243 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT} |
| 244 |
| 245 common_vars_defines |
| 246 |
| 247 DEFINES+=" sdk_build=0" |
| 248 DEFINES+=" android_product_out=${ANDROID_PRODUCT_OUT}" |
| 249 |
| 250 if [ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]; then |
| 251 webview_build_init |
| 252 return |
| 253 fi |
| 254 |
| 255 # The non-SDK build currently requires the SDK path to build the framework |
| 256 # Java aidl files. TODO(steveblock): Investigate avoiding this requirement. |
| 257 DEFINES+=" android_sdk=${ANDROID_SDK_ROOT}" |
| 258 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/../tools/linux" |
| 259 |
| 260 common_gyp_vars |
| 261 } |
| 262 |
| 263 ################################################################################ |
| 264 # To build WebView, we use the Android build system and build inside an Android |
| 265 # source tree. This method is called from non_sdk_build_init() and adds to the |
| 266 # settings specified there. |
| 267 ############################################################################# |
| 268 webview_build_init() { |
| 269 # We need to supply SDK paths relative to the top of the Android tree to make |
| 270 # sure the generated Android makefiles are portable, as they will be checked |
| 271 # into the Android tree. |
| 272 ANDROID_SDK=$(python -c \ |
| 273 "import os.path; print os.path.relpath('${ANDROID_SDK_ROOT}', '${TOP}')") |
| 274 ANDROID_SDK_TOOLS=$(python -c \ |
| 275 "import os.path; \ |
| 276 print os.path.relpath('${ANDROID_SDK_ROOT}/../tools/linux', \ |
| 277 '${TOP}')") |
| 278 DEFINES+=" android_build_type=1" |
| 279 DEFINES+=" android_upstream_bringup=1" |
| 280 DEFINES+=" android_sdk=\$(GYP_ABS_ANDROID_TOP_DIR)/${ANDROID_SDK}" |
| 281 DEFINES+=" android_sdk_tools=\$(GYP_ABS_ANDROID_TOP_DIR)/${ANDROID_SDK_TOOLS}" |
| 282 export GYP_DEFINES="${DEFINES}" |
| 283 |
| 284 export GYP_GENERATORS="android" |
| 285 |
| 286 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 287 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" |
| 288 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" |
| 289 |
| 290 # TODO(torne): This isn't upstream yet. Upstream it or remove this setting. |
| 291 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android_webview.gyp" |
| 292 } |
OLD | NEW |