Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
Mark Mentovai
2011/09/26 21:14:31
I was asking for a blank line between #!/bin/bash
michaelbai
2011/09/26 21:28:11
Sorry, Done
| |
| 3 | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Sets up environment for building Chromium on Android. Only Android NDK, | |
| 8 # Revision 6b on Linux or Mac is offically supported. | |
| 9 # | |
| 10 # To run this script, the system environment ANDROID_NDK_ROOT must be set | |
| 11 # to Android NDK's root path. | |
| 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 | |
| 18 if [ ! -d "${ANDROID_NDK_ROOT}" ]; then | |
| 19 echo "ANDROID_NDK_ROOT must be set to the path of Android NDK, Revision 6b." | |
|
Mark Mentovai
2011/09/26 21:14:31
These three echoes should go to stderr (see the ne
michaelbai
2011/09/26 21:28:11
Done.
| |
| 20 echo "which could be downloaded from" | |
| 21 echo "http://developer.android.com/sdk/ndk/index.html" | |
| 22 return 1 | |
| 23 fi | |
| 24 | |
| 25 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') | |
| 26 | |
| 27 case "${host_os}" in | |
| 28 "linux") | |
| 29 toolchain_dir="linux-x86" | |
| 30 ;; | |
| 31 "mac") | |
| 32 toolchain_dir="darwin-x86" | |
| 33 ;; | |
| 34 *) | |
| 35 echo "Host platform ${host_os} is not supported" | |
|
Mark Mentovai
2011/09/26 21:14:31
Direct error messages to stderr. This should be
michaelbai
2011/09/26 21:28:11
Done.
| |
| 36 return 1 | |
| 37 esac | |
| 38 | |
| 39 export ANDROID_TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/arm-linux-androideabi-4 .4.3/prebuilt/${toolchain_dir}/bin/" | |
| 40 | |
| 41 if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then | |
| 42 echo "Can not find Android toolchain in ${ANDROID_TOOLCHAIN}." | |
|
Mark Mentovai
2011/09/26 21:14:31
Both of these echoes should go to stderr (>& 2) to
michaelbai
2011/09/26 21:28:11
Done.
| |
| 43 echo "The NDK version might be wrong." | |
| 44 return 1 | |
| 45 fi | |
| 46 | |
| 47 if [ -z "${CHROME_SRC}" ]; then | |
| 48 # if $CHROME_SRC was not set, assume current directory is CHROME_SRC. | |
| 49 export CHROME_SRC=$(pwd) | |
| 50 fi | |
| 51 | |
| 52 if [ ! -d "${CHROME_SRC}" ]; then | |
| 53 echo "CHROME_SRC must be set to the path of Chrome source code." | |
|
Mark Mentovai
2011/09/26 21:14:31
stderr.
michaelbai
2011/09/26 21:28:11
Done.
| |
| 54 return 1 | |
| 55 fi | |
| 56 | |
| 57 make() { | |
| 58 # TODO(michaelbai): how to use ccache in NDK. | |
| 59 if [ -n "${USE_CCACHE}" ]; then | |
| 60 if [ -e "${PREBUILT_CCACHE_PATH}" ]; then | |
| 61 use_ccache_var="$PREBUILT_CCACHE_PATH " | |
| 62 else | |
| 63 use_ccache_var="" | |
| 64 fi | |
| 65 fi | |
| 66 if [ -f "$PWD/build/android/envsetup.sh" ]; then | |
| 67 CC="${use_ccache_var}${CROSS_CC}" CXX="${use_ccache_var}${CROSS_CXX}" \ | |
| 68 LINK="${CROSS_LINK}" AR="${CROSS_AR}" RANLIB="${CROSS_RANLIB}" \ | |
| 69 command make $* | |
| 70 else | |
| 71 command make $* | |
| 72 fi | |
| 73 } | |
| 74 | |
| 75 # Performs a gyp_chromium run to convert gyp->Makefile for android code. | |
| 76 android_gyp() { | |
| 77 "${CHROME_SRC}"/build/gyp_chromium --depth="${CHROME_SRC}" | |
|
Mark Mentovai
2011/09/26 21:14:31
The quotes should encompass the entire word. You d
michaelbai
2011/09/26 21:28:11
Done.
| |
| 78 } | |
| 79 | |
| 80 firstword() { | |
| 81 echo "${1}" | |
| 82 } | |
| 83 | |
| 84 export CROSS_AR="$(firstword "${ANDROID_TOOLCHAIN}"/*-ar)" | |
| 85 export CROSS_CC="$(firstword "${ANDROID_TOOLCHAIN}"/*-gcc)" | |
| 86 export CROSS_CXX="$(firstword "${ANDROID_TOOLCHAIN}"/*-g++)" | |
| 87 export CROSS_LINK="$(firstword "${ANDROID_TOOLCHAIN}"/*-gcc)" | |
| 88 export CROSS_RANLIB="$(firstword "${ANDROID_TOOLCHAIN}"/*-ranlib)" | |
| 89 export OBJCOPY="$(firstword "${ANDROID_TOOLCHAIN}"/*-objcopy)" | |
| 90 export STRIP="$(firstword "${ANDROID_TOOLCHAIN}"/*-strip)" | |
| 91 | |
| 92 # The set of GYP_DEFINES to pass to gyp. Use 'readlink -e' on directories | |
| 93 # to canonicalize them (remove double '/', remove trailing '/', etc). | |
| 94 DEFINES="OS=android" | |
| 95 DEFINES+=" android_build_type=0" # Currently, Only '0' is supportted. | |
| 96 DEFINES+=" host_os=${host_os}" | |
| 97 DEFINES+=" linux_fpic=1" | |
| 98 DEFINES+=" release_optimize=s" | |
| 99 DEFINES+=" linux_use_tcmalloc=0" | |
| 100 DEFINES+=" disable_nacl=1" | |
| 101 DEFINES+=" remoting=0" | |
| 102 DEFINES+=" p2p_apis=0" | |
| 103 DEFINES+=" enable_touch_events=1" | |
| 104 # TODO(bulach): use "shared_libraries" once the transition from executable | |
| 105 # is over. | |
| 106 DEFINES+=" gtest_target_type=executable" | |
| 107 DEFINES+=" branding=Chromium" | |
| 108 | |
| 109 # If the TARGET_PRODUCT wasn't set, use 'full' by default. | |
| 110 if [ -z "${TARGET_PRODUCT}" ]; then | |
| 111 TARGET_PRODUCT="full" | |
| 112 fi | |
| 113 | |
| 114 # The following defines will affect ARM code generation of both C/C++ compiler | |
| 115 # and V8 mksnapshot. | |
| 116 case "${TARGET_PRODUCT}" in | |
| 117 "full") | |
| 118 DEFINES+=" target_arch=arm" | |
| 119 DEFINES+=" arm_neon=0 armv7=0 arm_thumb=1 arm_fpu=vfp" | |
| 120 ;; | |
| 121 *x86*) | |
| 122 DEFINES+=" target_arch=ia32 use_libffmpeg=0" | |
| 123 ;; | |
| 124 *) | |
| 125 echo "TARGET_PRODUCT:${TARGET_PRODUCT} is not supported." | |
|
Mark Mentovai
2011/09/26 21:14:31
I think the colon (:) should be a space. And this
michaelbai
2011/09/26 21:28:11
Done.
| |
| 126 return 1 | |
| 127 esac | |
| 128 | |
| 129 export GYP_DEFINES="${DEFINES}" | |
| 130 | |
| 131 # Use the "android" flavor of the Makefile generator for both Linux and OS X. | |
| 132 export GYP_GENERATORS="make-android" | |
| 133 | |
| 134 # We want to use our version of "all" targets. | |
| 135 export CHROMIUM_GYP_FILE="${CHROME_SRC}/build/all_android.gyp" | |
| OLD | NEW |