Chromium Code Reviews| 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 | |
| 29 # Set toolchain path according to product architecture. | 28 # Set toolchain path according to product architecture. |
| 30 toolchain_arch="arm-linux-androideabi" | 29 case "${TARGET_ARCH}" in |
| 31 if [[ "${TARGET_PRODUCT}" =~ .*x86.* ]]; then | 30 "arm") |
| 32 toolchain_arch="x86" | 31 toolchain_arch="arm-linux-androideabi" |
| 33 fi | 32 ;; |
| 33 "x86") | |
| 34 toolchain_arch="x86" | |
| 35 ;; | |
| 36 *) | |
| 37 echo "TARGET_ARCH: ${TARGET_ARCH} is not supported." >& 2 | |
| 38 usage | |
| 39 return 1 | |
| 40 ;; | |
| 41 esac | |
| 34 | 42 |
| 35 toolchain_version="4.6" | 43 toolchain_version="4.6" |
| 36 # We directly set the gcc_version since we know what we use, and it should | 44 # We directly set the gcc_version since we know what we use, and it should |
| 37 # be set to xx instead of x.x. Refer the output of compiler_version.py. | 45 # be set to xx instead of x.x. Refer the output of compiler_version.py. |
| 38 gcc_version="46" | 46 gcc_version="46" |
| 39 toolchain_target=$(basename \ | 47 toolchain_target=$(basename \ |
| 40 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-${toolchain_version}) | 48 ${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}-${toolchain_version}) |
| 41 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ | 49 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_target}"\ |
| 42 "/prebuilt/${toolchain_dir}/bin/" | 50 "/prebuilt/${toolchain_dir}/bin/" |
| 43 | 51 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 101 |
| 94 # The order file specifies the order of symbols in the .text section of the | 102 # The order file specifies the order of symbols in the .text section of the |
| 95 # shared library, libchromeview.so. The file is an order list of section | 103 # shared library, libchromeview.so. The file is an order list of section |
| 96 # names and the library is linked with option | 104 # names and the library is linked with option |
| 97 # --section-ordering-file=<orderfile>. The order file is updated by profiling | 105 # --section-ordering-file=<orderfile>. The order file is updated by profiling |
| 98 # startup after compiling with the order_profiling=1 GYP_DEFINES flag. | 106 # startup after compiling with the order_profiling=1 GYP_DEFINES flag. |
| 99 ORDER_DEFINES="order_text_section=${CHROME_SRC}/orderfiles/orderfile.out" | 107 ORDER_DEFINES="order_text_section=${CHROME_SRC}/orderfiles/orderfile.out" |
| 100 | 108 |
| 101 # The following defines will affect ARM code generation of both C/C++ compiler | 109 # The following defines will affect ARM code generation of both C/C++ compiler |
| 102 # and V8 mksnapshot. | 110 # and V8 mksnapshot. |
| 103 case "${TARGET_PRODUCT}" in | 111 case "${TARGET_ARCH}" in |
| 104 "passion"|"soju"|"sojua"|"sojus"|"yakju"|"mysid"|"nakasi") | 112 "arm") |
| 105 DEFINES+=" arm_neon=1 armv7=1 arm_thumb=1" | |
| 106 DEFINES+=" ${ORDER_DEFINES}" | |
| 107 TARGET_ARCH="arm" | |
| 108 ;; | |
| 109 "trygon"|"tervigon") | |
| 110 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16" | 113 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16" |
| 111 DEFINES+=" ${ORDER_DEFINES}" | 114 DEFINES+=" ${ORDER_DEFINES}" |
| 112 TARGET_ARCH="arm" | 115 DEFINES+=" target_arch=arm" |
| 113 ;; | 116 ;; |
| 114 "full") | 117 "x86") |
| 115 DEFINES+=" arm_neon=0 armv7=0 arm_thumb=1 arm_fpu=vfp" | |
| 116 TARGET_ARCH="arm" | |
| 117 ;; | |
| 118 *x86*) | |
| 119 # TODO(tedbo): The ia32 build fails on ffmpeg, so we disable it here. | 118 # TODO(tedbo): The ia32 build fails on ffmpeg, so we disable it here. |
| 120 DEFINES+=" use_libffmpeg=0" | 119 DEFINES+=" use_libffmpeg=0" |
| 121 | 120 |
| 122 host_arch=$(uname -m | sed -e \ | 121 host_arch=$(uname -m | sed -e \ |
| 123 's/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/;s/i86pc/ia32/') | 122 's/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/;s/i86pc/ia32/') |
| 124 DEFINES+=" host_arch=${host_arch}" | 123 DEFINES+=" host_arch=${host_arch}" |
| 125 TARGET_ARCH="x86" | |
| 126 ;; | |
| 127 *) | |
| 128 echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2 | |
| 129 return 1 | |
| 130 esac | |
| 131 | |
| 132 case "${TARGET_ARCH}" in | |
| 133 "arm") | |
| 134 DEFINES+=" target_arch=arm" | |
| 135 ;; | |
| 136 "x86") | |
| 137 DEFINES+=" target_arch=ia32" | 124 DEFINES+=" target_arch=ia32" |
| 138 ;; | 125 ;; |
| 139 *) | 126 *) |
| 140 echo "TARGET_ARCH: ${TARGET_ARCH} is not supported." >& 2 | 127 echo "TARGET_ARCH: ${TARGET_ARCH} is not supported." >& 2 |
| 128 usage | |
| 141 return 1 | 129 return 1 |
| 142 esac | 130 esac |
| 143 | 131 |
| 144 DEFINES+=" android_gdbserver=${ANDROID_NDK_ROOT}/prebuilt/\ | 132 DEFINES+=" android_gdbserver=${ANDROID_NDK_ROOT}/prebuilt/\ |
| 145 android-${TARGET_ARCH}/gdbserver/gdbserver" | 133 android-${TARGET_ARCH}/gdbserver/gdbserver" |
| 146 } | 134 } |
| 147 | 135 |
| 148 | 136 |
| 149 ################################################################################ | 137 ################################################################################ |
| 150 # Exports common GYP variables based on variable DEFINES and CHROME_SRC. | 138 # Exports common GYP variables based on variable DEFINES and CHROME_SRC. |
| 151 ################################################################################ | 139 ################################################################################ |
| 152 common_gyp_vars() { | 140 common_gyp_vars() { |
| 153 export GYP_DEFINES="${DEFINES}" | 141 export GYP_DEFINES="${DEFINES}" |
| 154 | 142 |
| 155 # Set GYP_GENERATORS to make-android if it's currently unset or null. | 143 # Set GYP_GENERATORS to make-android if it's currently unset or null. |
| 156 export GYP_GENERATORS="${GYP_GENERATORS:-make-android}" | 144 export GYP_GENERATORS="${GYP_GENERATORS:-make-android}" |
| 157 | 145 |
| 158 # Use our All target as the default | 146 # Use our All target as the default |
| 159 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 147 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 160 | 148 |
| 161 # We want to use our version of "all" targets. | 149 # We want to use our version of "all" targets. |
| 162 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" | 150 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" |
| 163 } | 151 } |
| 164 | 152 |
| 165 | 153 |
| 166 ################################################################################ | 154 ################################################################################ |
| 155 # Prints out help message on usage. | |
| 156 ################################################################################ | |
| 157 usage() { | |
|
Isaac (away)
2012/10/24 20:54:48
rename print_usage
Jinsuk Kim (do not use this)
2012/10/25 01:03:59
Done.
| |
| 158 echo "usage: ${0##*/} [-t target_arch] [-h]" >& 2 | |
| 159 echo "-t target_arch target CPU architecture (arm=default, x86)" >& 2 | |
| 160 echo "-h this help" >& 2 | |
| 161 } | |
| 162 | |
| 163 ################################################################################ | |
| 164 # Process command line options. | |
| 165 # -t target_arch Specifices target CPU architecture. Currently supported | |
| 166 # architectures are "arm" (default), and "x86". | |
| 167 # -h Prints out help message. | |
| 168 ################################################################################ | |
| 169 process_options() { | |
| 170 while getopts “ht:” OPTION; do | |
| 171 case $OPTION in | |
| 172 h) | |
| 173 usage | |
| 174 return 1 | |
| 175 ;; | |
| 176 t) | |
| 177 target_arch=$OPTARG | |
| 178 ;; | |
| 179 *) | |
| 180 echo "invalid command line option: $OPTARG" >& 2 | |
| 181 usage | |
| 182 return 1 | |
| 183 ;; | |
| 184 esac | |
| 185 done | |
| 186 | |
| 187 if [ $# -ge ${OPTIND} ]; then | |
|
Isaac (away)
2012/10/24 20:54:48
I don't see where $OPTIND is defined.
Jinsuk Kim (do not use this)
2012/10/25 01:03:59
OPTIND (together with OPTERR, OPTARG) is defined (
| |
| 188 eval echo "Unexpected command line argument: \${${OPTIND}}" >& 2 | |
| 189 usage | |
| 190 return 1 | |
| 191 fi | |
| 192 | |
| 193 # Sets TARGET_ARCH. Defaults to arm if not specified. | |
| 194 TARGET_ARCH=${target_arch:-arm} | |
| 195 } | |
| 196 | |
| 197 ################################################################################ | |
| 167 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision | 198 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision |
| 168 # 7 on Linux or Mac is offically supported. To run this script, the system | 199 # 7 on Linux or Mac is offically supported. To run this script, the system |
| 169 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path. The | 200 # environment ANDROID_NDK_ROOT must be set to Android NDK's root path. The |
| 170 # ANDROID_SDK_ROOT only needs to be set to override the default SDK which is in | 201 # ANDROID_SDK_ROOT only needs to be set to override the default SDK which is in |
| 171 # the tree under $ROOT/src/third_party/android_tools/sdk. | 202 # the tree under $ROOT/src/third_party/android_tools/sdk. |
| 172 # To build Chromium for Android with NDK/SDK follow the steps below: | 203 # To build Chromium for Android with NDK/SDK follow the steps below: |
| 173 # > export ANDROID_NDK_ROOT=<android ndk root> | 204 # > export ANDROID_NDK_ROOT=<android ndk root> |
| 174 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk | 205 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk |
| 175 # > . build/android/envsetup.sh | 206 # > . build/android/envsetup.sh |
| 176 # > make | 207 # > make |
| 177 ################################################################################ | 208 ################################################################################ |
| 178 sdk_build_init() { | 209 sdk_build_init() { |
| 179 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by | 210 # If ANDROID_NDK_ROOT is set when envsetup is run, use the ndk pointed to by |
| 180 # the environment variable. Otherwise, use the default ndk from the tree. | 211 # the environment variable. Otherwise, use the default ndk from the tree. |
| 181 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then | 212 if [[ -z "${ANDROID_NDK_ROOT}" || ! -d "${ANDROID_NDK_ROOT}" ]]; then |
| 182 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" | 213 export ANDROID_NDK_ROOT="${CHROME_SRC}/third_party/android_tools/ndk/" |
| 183 fi | 214 fi |
| 184 | 215 |
| 185 # If ANDROID_SDK_ROOT is set when envsetup is run, and if it has the | 216 # If ANDROID_SDK_ROOT is set when envsetup is run, and if it has the |
| 186 # right SDK-compatible directory layout, use the sdk pointed to by the | 217 # right SDK-compatible directory layout, use the sdk pointed to by the |
| 187 # environment variable. Otherwise, use the default sdk from the tree. | 218 # environment variable. Otherwise, use the default sdk from the tree. |
| 188 local sdk_suffix=platforms/android-${ANDROID_SDK_VERSION} | 219 local sdk_suffix=platforms/android-${ANDROID_SDK_VERSION} |
| 189 if [[ -z "${ANDROID_SDK_ROOT}" || \ | 220 if [[ -z "${ANDROID_SDK_ROOT}" || \ |
| 190 ! -d "${ANDROID_SDK_ROOT}/${sdk_suffix}" ]]; then | 221 ! -d "${ANDROID_SDK_ROOT}/${sdk_suffix}" ]]; then |
| 191 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" | 222 export ANDROID_SDK_ROOT="${CHROME_SRC}/third_party/android_tools/sdk/" |
| 192 fi | 223 fi |
| 193 | 224 |
| 194 unset ANDROID_BUILD_TOP | 225 unset ANDROID_BUILD_TOP |
| 195 | 226 |
| 196 # Set default target. | |
| 197 export TARGET_PRODUCT="${TARGET_PRODUCT:-trygon}" | |
|
Yaron
2012/10/24 20:50:17
build/android/emulator.py refers to this environme
Jinsuk Kim (do not use this)
2012/10/25 01:03:59
Thanks for catching it. I reverted the change to h
| |
| 198 | |
| 199 # Unset toolchain so that it can be set based on TARGET_PRODUCT. | 227 # Unset toolchain so that it can be set based on TARGET_PRODUCT. |
| 200 # This makes it easy to switch between architectures. | 228 # This makes it easy to switch between architectures. |
| 201 unset ANDROID_TOOLCHAIN | 229 unset ANDROID_TOOLCHAIN |
| 202 | 230 |
| 203 common_vars_defines | 231 common_vars_defines |
| 204 | 232 |
| 205 DEFINES+=" sdk_build=1" | 233 DEFINES+=" sdk_build=1" |
| 206 # If we are building NDK/SDK, and in the upstream (open source) tree, | 234 # If we are building NDK/SDK, and in the upstream (open source) tree, |
| 207 # define a special variable for bringup purposes. | 235 # define a special variable for bringup purposes. |
| 208 case "${ANDROID_BUILD_TOP-undefined}" in | 236 case "${ANDROID_BUILD_TOP-undefined}" in |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 export GYP_DEFINES="${DEFINES}" | 302 export GYP_DEFINES="${DEFINES}" |
| 275 | 303 |
| 276 export GYP_GENERATORS="android" | 304 export GYP_GENERATORS="android" |
| 277 | 305 |
| 278 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" | 306 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" |
| 279 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" | 307 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" |
| 280 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" | 308 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" |
| 281 | 309 |
| 282 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" | 310 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" |
| 283 } | 311 } |
| OLD | NEW |