Chromium Code Reviews| Index: build/install-build-deps-android.sh |
| diff --git a/build/install-build-deps-android.sh b/build/install-build-deps-android.sh |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..ae3616980146c743dc416cd00508fae24d878270 |
| --- /dev/null |
| +++ b/build/install-build-deps-android.sh |
| @@ -0,0 +1,93 @@ |
| +#!/bin/bash -e |
|
Mark Mentovai
2011/10/05 18:16:05
I don’t think this is as portable as making “set -
michaelbai
2011/10/05 20:55:18
Done.
|
| + |
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +# The script is to install Android SDK, NDK for build chromium on Android, and |
| +# doesn't need to run as root. |
| + |
| +# Using Android 3.2, API Level: 13 (Honeycomb). The SDK package is about 30M. |
| +SDK_FILE_NAME="android-sdk_r13-linux_x86.tgz" |
| +SDK_DOWNLOAD_URL="http://dl.google.com/android/android-sdk_r13-linux_x86.tgz" |
| +SDK_MD5SUM="d80d7530a46c665644ae76084a9a0dc4" |
| +# Using "ADROID_SDK_ROOT/tools/android list targets" to get the matching target |
|
Mark Mentovai
2011/10/05 18:16:05
Blank line before.
Also, you misspelled ANDROID_S
michaelbai
2011/10/05 20:55:18
Done.
|
| +# id which will be loaded in simulator for testing. |
| +# For example: the output of the listed the target could be below, and the |
| +# 'android-13' is the SDK_TARGET_ID in this case. |
| +# id: 9 or "android-13" |
| +# Name: Android 3.2 |
| +# Type: Platform |
| +# API level: 13 |
| +# Revision: 1 |
| +# Skins: WXGA (default) |
| +SDK_TARGET_ID=android-13 |
| + |
| +# Using NDK r6b; The package is about 44M. |
| +NDK_FILE_NAME="android-ndk-r6b-linux-x86.tar.bz2" |
| +NDK_DOWNLOAD_URL="http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2" |
| +NDK_MD5SUM="309f35e49b64313cfb20ac428df4cec2" |
| + |
| +# Download and install a tgz package by wget and tar -xvf. |
| +# This should be called as: |
| +# install local_file_name download_url md5 install_path |
| +install_dev_kit() { |
| + test -f $1 || wget $2 |
|
Mark Mentovai
2011/10/05 18:16:05
Always use {braces} like ${1} and ${2}. Also, alwa
michaelbai
2011/10/05 20:55:18
Done.
|
| + if test "`md5sum $1 |cut -d' ' -f1`" != $3; then |
|
Mark Mentovai
2011/10/05 18:16:05
Don’t write “if test”, use “if [[”.
Don’t use `ba
michaelbai
2011/10/05 20:55:18
Done.
|
| + echo "Bad md5sum of $2" >& 2 |
| + rm $1 |
| + exit 1 |
| + fi |
| + |
| + echo "Install $1" |
| + mv $1 $4 |
| + pushd . |
|
Mark Mentovai
2011/10/05 18:16:05
Rather than pushd/cd/operate/popd, you can do
(cd
michaelbai
2011/10/05 20:55:18
Done.
|
| + cd $4 |
| + tar -xvf $4/$1 |
| + popd |
| +} |
| + |
| +if [ -z "${ANDROID_SDK_ROOT}" ]; then |
|
Mark Mentovai
2011/10/05 18:16:05
[[ double brackets ]] throughout (see e-mail comin
michaelbai
2011/10/05 20:55:18
Done.
|
| + echo "Please set ANDROID_SDK_ROOT to where they should installed to." >& 2 |
| + echo "For example: /usr/local/android-sdk-linux_x86" >& 2 |
| + exit 1 |
| +fi |
| + |
| +if [ -z "${ANDROID_NDK_ROOT}" ]; then |
| + echo "Please set ANDROID_NDK_ROOT to where they should installed to." >& 2 |
| + echo "For example: /usr/local/android-ndk-r6b" >& 2 |
| + exit 1 |
| +fi |
| + |
| +# Install Android SDK if it doesn't exist. |
| +if [ ! -d ${ANDROID_SDK_ROOT} ]; then |
| + echo 'Install ANDROID SDK ...' |
| + install_dev_kit ${SDK_FILE_NAME} ${SDK_DOWNLOAD_URL} ${SDK_MD5SUM} \ |
| + $(dirname ${ANDROID_SDK_ROOT}) |
| +fi |
| + |
| +# Install the target if it doesn't exist. The package installed above contains |
| +# no platform, platform-tool or tool, all those should be installed by |
| +# ${ANDROID_SDK_ROOT}/tools/android. |
| +if [ $(${ANDROID_SDK_ROOT}/tools/android list targets \ |
|
Mark Mentovai
2011/10/05 18:16:05
Don’t forget to quote things like ANDROID_SDK_ROOT
michaelbai
2011/10/05 20:55:18
Done.
|
| + | grep "${SDK_TARGET_ID}" | wc -w) == 0 ]; then |
|
Mark Mentovai
2011/10/05 18:16:05
What’s the wc about? Why not test grep’s exit stat
michaelbai
2011/10/05 20:55:18
Done.
|
| + # Updates the SDK by installing the necessary components. |
| + # From current configuration, all android platforms will be installed. |
| + # This will take a little bit long time. |
| + $echo "Install platform, platform-tool and tool ..." |
|
Mark Mentovai
2011/10/05 18:16:05
What’s $echo?
michaelbai
2011/10/05 20:55:18
Done.
|
| + ${ANDROID_SDK_ROOT}/tools/android update sdk --no-ui \ |
| + --filter platform,platform-tool,tool |
| +fi |
| + |
| +# Create a AVD named 'buildbot' with default hw configuration and override the |
|
Mark Mentovai
2011/10/05 18:16:05
I don’t know what AVD means. This comment can expl
michaelbai
2011/10/05 20:55:18
Done.
|
| +# existing one since there is no easy way to check whether current AVD has |
| +# correct configuration and it takes almost no time to create a new one. |
| +echo no | ${ANDROID_SDK_ROOT}/tools/android --silent create avd \ |
|
Mark Mentovai
2011/10/05 18:16:05
Since you’re a bash script, you can use <<< to giv
michaelbai
2011/10/05 20:55:18
Done.
|
| + --name buildbot --target ${SDK_TARGET_ID} --force |
| + |
| +# Install Android NDK if it doesn't exist. |
| +if [ ! -d ${ANDROID_NDK_ROOT} ]; then |
| + echo 'Install ANDROID NDK ...' |
| + install_dev_kit ${NDK_FILE_NAME} ${NDK_DOWNLOAD_URL} ${NDK_MD5SUM} \ |
| + $(dirname ${ANDROID_NDK_ROOT}) |
| +fi |