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

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

Issue 10827073: Relanding 148377 - [Android] Upstream additional changes from envsetup." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove ninja from generators list Created 8 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « build/android/adb_device_functions.sh ('k') | build/android/envsetup_functions.sh » ('j') | 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 # Sets up environment for building Chromium on Android. Only Android NDK, 7 # Sets up environment for building Chromium on Android. It can either be
8 # Revision 6b on Linux or Mac is offically supported. 8 # compiled with the Android tree or using the Android SDK/NDK. To build with
9 # 9 # NDK/SDK: ". build/android/envsetup.sh --sdk". Environment variable
10 # To run this script, the system environment ANDROID_NDK_ROOT must be set 10 # ANDROID_SDK_BUILD=1 will then be defined and used in the rest of the setup to
11 # to Android NDK's root path. 11 # specifiy build type.
12 #
13 # TODO(michaelbai): Develop a standard for NDK/SDK integration.
14 #
15 # If current path isn't the Chrome's src directory, CHROME_SRC must be set
16 # to the Chrome's src directory.
17 12
18 if [ ! -d "${ANDROID_NDK_ROOT}" ]; then 13 # NOTE(yfriedman): This looks unnecessary but downstream the default value
19 echo "ANDROID_NDK_ROOT must be set to the path of Android NDK, Revision 6b." \ 14 # should be 0 until all builds switch to SDK/NDK.
20 >& 2 15 export ANDROID_SDK_BUILD=1
21 echo "which could be installed by" >& 2 16 # Loop over args in case we add more arguments in the future.
22 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2 17 while [ "$1" != "" ]; do
23 return 1 18 case $1 in
24 fi 19 -s | --sdk ) export ANDROID_SDK_BUILD=1 ; shift ;;
20 * ) shift ; break ;;
21 esac
22 done
25 23
26 if [ ! -d "${ANDROID_SDK_ROOT}" ]; then 24 if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then
27 echo "ANDROID_SDK_ROOT must be set to the path of Android SDK, Android 3.2." \ 25 echo "Using SDK build"
28 >& 2
29 echo "which could be installed by" >& 2
30 echo "<chromium_tree>/src/build/install-build-deps-android-sdk.sh" >& 2
31 return 1
32 fi 26 fi
33 27
34 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') 28 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
35 29
36 case "${host_os}" in 30 case "${host_os}" in
37 "linux") 31 "linux")
38 toolchain_dir="linux-x86" 32 toolchain_dir="linux-x86"
39 ;; 33 ;;
40 "mac") 34 "mac")
41 toolchain_dir="darwin-x86" 35 toolchain_dir="darwin-x86"
42 ;; 36 ;;
43 *) 37 *)
44 echo "Host platform ${host_os} is not supported" >& 2 38 echo "Host platform ${host_os} is not supported" >& 2
45 return 1 39 return 1
46 esac 40 esac
47 41
48 # The following defines will affect ARM code generation of both C/C++ compiler 42 CURRENT_DIR="$(readlink -f "$(dirname $BASH_SOURCE)/../../")"
49 # and V8 mksnapshot.
50 case "${TARGET_PRODUCT-full}" in
51 "full")
52 DEFINES=" target_arch=arm"
53 DEFINES+=" arm_neon=0 armv7=1 arm_thumb=1 arm_fpu=vfpv3-d16"
54 toolchain_arch="arm-linux-androideabi-4.4.3"
55 ;;
56 *x86*)
57 DEFINES=" target_arch=ia32 use_libffmpeg=0"
58 toolchain_arch="x86-4.4.3"
59 ;;
60 *)
61 echo "TARGET_PRODUCT: ${TARGET_PRODUCT} is not supported." >& 2
62 return 1
63 esac
64
65 # If we are building NDK/SDK, and in the upstream (open source) tree,
66 # define a special variable for bringup purposes.
67 case "${ANDROID_BUILD_TOP-undefined}" in
68 "undefined")
69 DEFINES+=" android_upstream_bringup=1"
70 ;;
71 esac
72
73 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/"
74 export ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin/"
75
76 if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
77 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2
78 echo "The NDK version might be wrong." >& 2
79 return 1
80 fi
81
82 export ANDROID_SDK_VERSION="15"
83
84 # Needed by android antfiles when creating apks.
85 export ANDROID_SDK_HOME=${ANDROID_SDK_ROOT}
86
87 # Add Android SDK/NDK tools to system path.
88 export PATH=$PATH:${ANDROID_NDK_ROOT}
89 export PATH=$PATH:${ANDROID_SDK_ROOT}/tools
90 export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools
91 # Must have tools like arm-linux-androideabi-gcc on the path for ninja
92 export PATH=$PATH:${ANDROID_TOOLCHAIN}
93
94 CURRENT_DIR="$(readlink -f ${PWD})"
95 if [ -z "${CHROME_SRC}" ]; then 43 if [ -z "${CHROME_SRC}" ]; then
96 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC. 44 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
97 export CHROME_SRC="${CURRENT_DIR}" 45 export CHROME_SRC="${CURRENT_DIR}"
98 fi 46 fi
99 47
100 if [ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]; then 48 if [ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]; then
101 # If current directory is not in $CHROME_SRC, it might be set for other 49 # If current directory is not in $CHROME_SRC, it might be set for other
102 # source tree. If $CHROME_SRC was set correctly and we are in the correct 50 # source tree. If $CHROME_SRC was set correctly and we are in the correct
103 # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "". 51 # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "".
104 # Otherwise, it will equal to "${CURRENT_DIR}" 52 # Otherwise, it will equal to "${CURRENT_DIR}"
105 echo "Warning: Current directory is out of CHROME_SRC, it may not be \ 53 echo "Warning: Current directory is out of CHROME_SRC, it may not be \
106 the one you want." 54 the one you want."
107 echo "${CHROME_SRC}" 55 echo "${CHROME_SRC}"
108 fi 56 fi
109 57
110 if [ ! -d "${CHROME_SRC}" ]; then 58 # Source functions script. The file is in the same directory as this script.
111 echo "CHROME_SRC must be set to the path of Chrome source code." >& 2 59 . "$(dirname $BASH_SOURCE)"/envsetup_functions.sh
60
61 if [ "${ANDROID_SDK_BUILD}" -eq 1 ]; then
62 sdk_build_init
63 # Sets up environment for building Chromium for Android with source. Expects
64 # android environment setup and lunch.
65 elif [ -z "$ANDROID_BUILD_TOP" -o -z "$ANDROID_TOOLCHAIN" -o \
66 -z "$ANDROID_PRODUCT_OUT" ]; then
67 echo "Android build environment variables must be set."
68 echo "Please cd to the root of your Android tree and do: "
69 echo " . build/envsetup.sh"
70 echo " lunch"
71 echo "Then try this again."
72 echo "Or did you mean NDK/SDK build. Run envsetup.sh with --sdk argument."
112 return 1 73 return 1
74 else
75 non_sdk_build_init
113 fi 76 fi
114 77
115 # Add Chromium Android development scripts to system path. 78 # Workaround for valgrind build
116 # Must be after CHROME_SRC is set. 79 if [ -n "$CHROME_ANDROID_VALGRIND_BUILD" ]; then
117 export PATH=$PATH:${CHROME_SRC}/build/android 80 # arm_thumb=0 is a workaround for https://bugs.kde.org/show_bug.cgi?id=270709
81 DEFINES+=" arm_thumb=0 release_extra_cflags='-fno-inline\
82 -fno-omit-frame-pointer -fno-builtin' release_valgrind_build=1\
83 release_optimize=1"
84 fi
85
86 # Source a bunch of helper functions
87 . ${CHROME_SRC}/build/android/adb_device_functions.sh
118 88
119 ANDROID_GOMA_WRAPPER="" 89 ANDROID_GOMA_WRAPPER=""
120 if [[ -d $GOMA_DIR ]]; then 90 if [[ -d $GOMA_DIR ]]; then
121 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc" 91 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc"
122 fi 92 fi
123 export ANDROID_GOMA_WRAPPER 93 export ANDROID_GOMA_WRAPPER
124 94
125 export CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) 95 export CC_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc)
126 export CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++) 96 export CXX_target=$(basename ${ANDROID_TOOLCHAIN}/*-g++)
127 export LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc) 97 export LINK_target=$(basename ${ANDROID_TOOLCHAIN}/*-gcc)
128 export AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar) 98 export AR_target=$(basename ${ANDROID_TOOLCHAIN}/*-ar)
129 99
130 # Performs a gyp_chromium run to convert gyp->Makefile for android code. 100 # Performs a gyp_chromium run to convert gyp->Makefile for android code.
131 android_gyp() { 101 android_gyp() {
132 echo "GYP_GENERATORS set to '$GYP_GENERATORS'" 102 echo "GYP_GENERATORS set to '$GYP_GENERATORS'"
133 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" "$@" 103 if [[ $GYP_DEFINES =~ "clang=1" ]]; then
104 echo -n "NOTE: You have \`clang=1' in \$GYP_DEFINES; "
105 echo "did you mean to run \`android_clang_gyp'?"
106 fi
107
108 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" --check "$@"
134 } 109 }
135 110
136 export OBJCOPY=$(echo ${ANDROID_TOOLCHAIN}/*-objcopy) 111 # FLOCK needs to be null on system that has no flock
137 export STRIP=$(echo ${ANDROID_TOOLCHAIN}/*-strip) 112 which flock > /dev/null || export FLOCK=
138
139 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories
140 # to canonicalize them (remove double '/', remove trailing '/', etc).
141 DEFINES+=" OS=android"
142 DEFINES+=" android_build_type=0"
143 DEFINES+=" host_os=${host_os}"
144 DEFINES+=" linux_fpic=1"
145 DEFINES+=" release_optimize=s"
146 DEFINES+=" linux_use_tcmalloc=0"
147 DEFINES+=" disable_nacl=1"
148 DEFINES+=" remoting=0"
149 DEFINES+=" p2p_apis=0"
150 DEFINES+=" enable_touch_events=1"
151 DEFINES+=" build_ffmpegsumo=0"
152 DEFINES+=" gtest_target_type=shared_library"
153 DEFINES+=" branding=Chromium"
154 DEFINES+=\
155 " android_sdk=${ANDROID_SDK_ROOT}/platforms/android-${ANDROID_SDK_VERSION}"
156 DEFINES+=" android_sdk_tools=${ANDROID_SDK_ROOT}/platform-tools"
157
158 export GYP_DEFINES="${DEFINES}"
159
160 # Use the "android" flavor of the Makefile generator for both Linux and OS X.
161 export GYP_GENERATORS="make-android"
162
163 # Use our All target as the default
164 export GYP_GENERATOR_FLAGS="${GYP_GENERATOR_FLAGS} default_target=All"
165
166 # We want to use our version of "all" targets.
167 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp"
OLDNEW
« no previous file with comments | « build/android/adb_device_functions.sh ('k') | build/android/envsetup_functions.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698