Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: build/android/envsetup_functions.sh

Issue 11260008: Pass target architecture to build/android/envsetup.sh (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: changed the comment in the code Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/envsetup.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 print_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
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 print_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 print_usage() {
158 echo "usage: ${0##*/} [--target-arch=value] [--help]" >& 2
159 echo "--target-arch=value target CPU architecture (arm=default, x86)" >& 2
160 echo "--help this help" >& 2
161 }
162
163 ################################################################################
164 # Process command line options.
165 # --target-arch= Specifices target CPU architecture. Currently supported
166 # architectures are "arm" (default), and "x86".
167 # --help Prints out help message.
168 ################################################################################
169 process_options() {
170 while [[ $1 ]]; do
171 case "$1" in
172 --target-arch=*)
173 target_arch="$(echo "$1" | sed 's/^[^=]*=//')"
174 ;;
175 --help)
176 print_usage
177 return 1
178 ;;
179 *)
180 # Ignore other command line options
181 echo "Unknown option: $1"
182 ;;
183 esac
184 shift
185 done
186
187 # Sets TARGET_ARCH. Defaults to arm if not specified.
188 TARGET_ARCH=${target_arch:-arm}
189 }
190
191 ################################################################################
167 # Initializes environment variables for NDK/SDK build. Only Android NDK Revision 192 # 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 193 # 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 194 # 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 195 # 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. 196 # the tree under $ROOT/src/third_party/android_tools/sdk.
172 # To build Chromium for Android with NDK/SDK follow the steps below: 197 # To build Chromium for Android with NDK/SDK follow the steps below:
173 # > export ANDROID_NDK_ROOT=<android ndk root> 198 # > export ANDROID_NDK_ROOT=<android ndk root>
174 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk 199 # > export ANDROID_SDK_ROOT=<android sdk root> # to override the default sdk
175 # > . build/android/envsetup.sh 200 # > . build/android/envsetup.sh
176 # > make 201 # > make
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 export GYP_DEFINES="${DEFINES}" 299 export GYP_DEFINES="${DEFINES}"
275 300
276 export GYP_GENERATORS="android" 301 export GYP_GENERATORS="android"
277 302
278 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All" 303 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"
279 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1" 304 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} limit_to_target_all=1"
280 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0" 305 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} auto_regeneration=0"
281 306
282 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp" 307 export CHROMIUM_GYP_FILE="${CHROME_SRC}/android_webview/all_webview.gyp"
283 } 308 }
OLDNEW
« no previous file with comments | « build/android/envsetup.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698