OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 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 set -e | 7 set -e |
8 | 8 |
9 # The script is to install Android SDK, NDK for build chromium on Android, and | 9 # The script is to install Android SDK, NDK for build chromium on Android, and |
10 # doesn't need to run as root. | 10 # doesn't need to run as root. |
(...skipping 10 matching lines...) Expand all Loading... |
21 # 'android-13' is the SDK_TARGET_ID in this case. | 21 # 'android-13' is the SDK_TARGET_ID in this case. |
22 # id: 9 or "android-13" | 22 # id: 9 or "android-13" |
23 # Name: Android 3.2 | 23 # Name: Android 3.2 |
24 # Type: Platform | 24 # Type: Platform |
25 # API level: 13 | 25 # API level: 13 |
26 # Revision: 1 | 26 # Revision: 1 |
27 # Skins: WXGA (default) | 27 # Skins: WXGA (default) |
28 SDK_TARGET_ID=android-14 | 28 SDK_TARGET_ID=android-14 |
29 | 29 |
30 # Using NDK r7; The package is about 64M. | 30 # Using NDK r7; The package is about 64M. |
| 31 # *** DO NOT UPDATE THE NDK without updating the 64-bit linker changes *** |
| 32 # *** at the end of this file *** |
31 NDK_FILE_NAME="android-ndk-r7-linux-x86.tar.bz2" | 33 NDK_FILE_NAME="android-ndk-r7-linux-x86.tar.bz2" |
32 NDK_DOWNLOAD_URL="http://dl.google.com/android/ndk/${NDK_FILE_NAME}" | 34 NDK_DOWNLOAD_URL="http://dl.google.com/android/ndk/${NDK_FILE_NAME}" |
33 NDK_MD5SUM="bf15e6b47bf50824c4b96849bf003ca3" | 35 NDK_MD5SUM="bf15e6b47bf50824c4b96849bf003ca3" |
34 | 36 |
35 # The temporary directory used to store the downloaded file. | 37 # The temporary directory used to store the downloaded file. |
36 TEMPDIR=$(mktemp -d) | 38 TEMPDIR=$(mktemp -d) |
37 cleanup() { | 39 cleanup() { |
38 local status=${?} | 40 local status=${?} |
39 trap - EXIT | 41 trap - EXIT |
40 rm -rf "${TEMPDIR}" | 42 rm -rf "${TEMPDIR}" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 # Install Android SDK if it doesn't exist. | 92 # Install Android SDK if it doesn't exist. |
91 if [[ ! -d "${ANDROID_SDK_ROOT}" ]]; then | 93 if [[ ! -d "${ANDROID_SDK_ROOT}" ]]; then |
92 echo 'Install ANDROID SDK ...' | 94 echo 'Install ANDROID SDK ...' |
93 (install_dev_kit "${SDK_FILE_NAME}" "${SDK_DOWNLOAD_URL}" "${SDK_MD5SUM}" \ | 95 (install_dev_kit "${SDK_FILE_NAME}" "${SDK_DOWNLOAD_URL}" "${SDK_MD5SUM}" \ |
94 $(dirname "${ANDROID_SDK_ROOT}")) | 96 $(dirname "${ANDROID_SDK_ROOT}")) |
95 fi | 97 fi |
96 | 98 |
97 # Install the target if it doesn't exist. The package installed above contains | 99 # Install the target if it doesn't exist. The package installed above contains |
98 # no platform, platform-tool or tool, all those should be installed by | 100 # no platform, platform-tool or tool, all those should be installed by |
99 # ${ANDROID_SDK_ROOT}/tools/android. | 101 # ${ANDROID_SDK_ROOT}/tools/android. |
100 if [[ ! $("${ANDROID_SDK_ROOT}/tools/android" list targets \ | 102 found=$("${ANDROID_SDK_ROOT}/tools/android" list targets \ |
101 | grep -q "${SDK_TARGET_ID}") ]]; then | 103 | grep "${SDK_TARGET_ID}" | wc -l) |
| 104 if [[ "$found" = "0" ]]; then |
102 # Updates the SDK by installing the necessary components. | 105 # Updates the SDK by installing the necessary components. |
103 # From current configuration, all android platforms will be installed. | 106 # From current configuration, all android platforms will be installed. |
104 # This will take a little bit long time. | 107 # This will take a little bit long time. |
105 echo "Install platform, platform-tool and tool ..." | 108 echo "Install platform, platform-tool and tool ..." |
106 | 109 |
107 "${ANDROID_SDK_ROOT}"/tools/android update sdk -o --no-ui \ | 110 "${ANDROID_SDK_ROOT}"/tools/android update sdk -o --no-ui \ |
108 --filter platform,platform-tool,tool,system-image | 111 --filter platform,platform-tool,tool,system-image |
109 fi | 112 fi |
110 | 113 |
111 # Create a Android Virtual Device named 'buildbot' with default hardware | 114 # Create a Android Virtual Device named 'buildbot' with default hardware |
112 # configuration and override the existing one, since there is no easy way to | 115 # configuration and override the existing one, since there is no easy way to |
113 # check whether current AVD has correct configuration and it takes almost no | 116 # check whether current AVD has correct configuration and it takes almost no |
114 # time to create a new one. | 117 # time to create a new one. |
115 "${ANDROID_SDK_ROOT}/tools/android" --silent create avd --name buildbot \ | 118 "${ANDROID_SDK_ROOT}/tools/android" --silent create avd --name buildbot \ |
116 --target ${SDK_TARGET_ID} --force <<< "no" | 119 --target ${SDK_TARGET_ID} --force <<< "no" |
117 | 120 |
118 # Install Android NDK if it doesn't exist. | 121 # Install Android NDK if it doesn't exist. |
119 if [[ ! -d "${ANDROID_NDK_ROOT}" ]]; then | 122 if [[ ! -d "${ANDROID_NDK_ROOT}" ]]; then |
120 echo 'Install ANDROID NDK ...' | 123 echo 'Install ANDROID NDK ...' |
121 (install_dev_kit "${NDK_FILE_NAME}" "${NDK_DOWNLOAD_URL}" "${NDK_MD5SUM}" \ | 124 (install_dev_kit "${NDK_FILE_NAME}" "${NDK_DOWNLOAD_URL}" "${NDK_MD5SUM}" \ |
122 $(dirname "${ANDROID_NDK_ROOT}")) | 125 $(dirname "${ANDROID_NDK_ROOT}")) |
123 fi | 126 fi |
| 127 |
| 128 # Install the 64-bit linker if needed. |
| 129 ROOT=$(cd "$(dirname $0)/.."; pwd) |
| 130 LINKER_DIR_PREFIX="$ANDROID_NDK_ROOT/toolchains/\ |
| 131 arm-linux-androideabi-4.4.3/prebuilt/linux-x86" |
| 132 LINKER_DIRNAME_1="$LINKER_DIR_PREFIX/bin" |
| 133 LINKER_BASENAME_1=arm-linux-androideabi-ld |
| 134 LINKER_DIRNAME_2="$LINKER_DIR_PREFIX/arm-linux-androideabi/bin" |
| 135 LINKER_BASENAME_2=ld |
| 136 NEW_LINKER=arm-linux-androideabi-ld.e4df3e0a5bb640ccfa2f30ee67fe9b3146b152d6 |
| 137 |
| 138 # $1: destination directory |
| 139 # $2: destination binary |
| 140 function replace_linker { |
| 141 local linker_dirname=$1 |
| 142 local linker_basename=$2 |
| 143 if [[ -f "$ROOT/third_party/aosp/$NEW_LINKER" ]]; then |
| 144 if [[ -d "$linker_dirname" ]]; then |
| 145 if [[ ! -f "$linker_dirname/$NEW_LINKER" ]]; then |
| 146 echo "Installing linker in $linker_dirname" |
| 147 cp $ROOT/third_party/aosp/$NEW_LINKER "$linker_dirname/$NEW_LINKER" |
| 148 mv "$linker_dirname/$linker_basename" \ |
| 149 "$linker_dirname/$linker_basename.orig" |
| 150 ( cd "$linker_dirname" ; ln -s "$NEW_LINKER" "$linker_basename" ) |
| 151 fi |
| 152 if [[ ! -f "$linker_dirname/$NEW_LINKER" ]]; then |
| 153 echo "Could not copy linker" |
| 154 exit 1 |
| 155 fi |
| 156 fi |
| 157 fi |
| 158 } |
| 159 |
| 160 replace_linker $LINKER_DIRNAME_1 $LINKER_BASENAME_1 |
| 161 replace_linker $LINKER_DIRNAME_2 $LINKER_BASENAME_2 |
OLD | NEW |