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

Unified Diff: build/install-android-sdk-ndk.sh

Issue 10694048: Refactor and rename install-build-deps-android-sdk (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/envsetup.sh ('k') | build/install-build-deps-android-sdk.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/install-android-sdk-ndk.sh
diff --git a/build/install-android-sdk-ndk.sh b/build/install-android-sdk-ndk.sh
new file mode 100755
index 0000000000000000000000000000000000000000..3ecf8c4c689868ba5cec0b6976a88c9064e625d3
--- /dev/null
+++ b/build/install-android-sdk-ndk.sh
@@ -0,0 +1,136 @@
+#!/bin/bash -e
+# Copyright (c) 2012 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.
+#
+# This installs Android SDK and NDK for chromium android builds. It does
+# not require root.
+
+if [[ $1 == '--auto' ]]; then
+ USE_VERSION_FILE=1
+ set -x
+fi
+
+# Increment to induce bots to install updates and/or a new sdk version
+SCRIPT_VERSION=1
+
+if [[ -z $ANDROID_SDK_ROOT ]]; then
+ DEFAULT_SDK_ROOT="/usr/local/google/android-sdk-linux"
+ read -p "ANDROID_SDK_ROOT not set. Hit enter to use $DEFAULT_SDK_ROOT."
+ export ANDROID_SDK_ROOT="$DEFAULT_SDK_ROOT"
+fi
+
+if [[ -z $ANDROID_NDK_ROOT ]]; then
+ DEFAULT_NDK_ROOT="/usr/local/google/android-ndk-r7"
+ read -p "ANDROID_NDK_ROOT not set. Hit enter to use $DEFAULT_NDK_ROOT."
+ export ANDROID_NDK_ROOT="$DEFAULT_NDK_ROOT"
+fi
+
+base_dir=$(dirname $ANDROID_SDK_ROOT)
+if [[ ! -d $base_dir ]]; then
+ echo "Base directory '$base_dir' doesn't exist. Creating..."
+ mkdir "$base_dir"
bulach 2012/07/02 10:19:41 nit: -p
Isaac (away) 2012/07/03 06:49:59 Wanted the script to try to create one level and t
+fi
+
+VERSION_FILE="$ANDROID_SDK_ROOT/INSTALL_SDK_VERSION"
+if [[ $USE_VERSION_FILE ]]; then
+ if [[ -f $VERSION_FILE && $(cat "$VERSION_FILE") == $SCRIPT_VERSION ]]; then
+ echo "sdk / ndk up to date, not installing."
+ exit
+ fi
+
+ rm -rf "$ANDROID_SDK_ROOT"
+ rm -rf "$ANDROID_NDK_ROOT"
+fi
+
+#########################################################
+### FUNCTION DEFINITIONS - SCRIPT CONTINUES AT BOTTOM ###
bulach 2012/07/02 10:19:41 :) tbh, it'd be better to create functions for the
Isaac (away) 2012/07/03 06:49:59 Sounds good, will do.
+#########################################################
+
+# Download a tarball using wget and extract it.
+# Arguments:
+# download_url, the url to download the package.
+# md5, the expected md5
+function download_and_extract {
+ local download_url="$1"
+ local md5="$2"
+ local local_file="$$.$(basename $download_url)"
+ wget "$download_url" -O $local_file
+ if [[ $(md5sum $local_file | cut -d' ' -f1) != $md5 ]]; then
+ return 1
+ fi
+ tar -xf $local_file
+ rm $local_file
+}
+
+function install_sdk {
+ # Targets can be found with 'tools/android list sdk --extended'
+ local SDK_TARGET_ID="android-15"
+ local SDK_DOWNLOAD_URL="http://dl.google.com/android/android-sdk_r20-linux.tgz"
+ local SDK_MD5SUM="22a81cf1d4a951c62f71a8758290e9bb"
+
+ echo 'Installing ANDROID SDK ...'
+ pushd $(dirname "$ANDROID_SDK_ROOT")
+ if [[ ! -d $ANDROID_SDK_ROOT ]]; then
+ download_and_extract $SDK_DOWNLOAD_URL $SDK_MD5SUM
+ fi
+ cd "$ANDROID_SDK_ROOT"
+ if ! tools/android list sdk --extended | grep -q "^id.*$SDK_TARGET_ID"; then
+ echo "SDK target $SDK_TARGET_ID already up to date, skipping sdk update"
+ return
+ fi
+
+ # Updates the SDK by installing the necessary components.
+ # From current configuration, all android platforms will be installed.
+ echo "Installing platform, platform-tool and tool ..."
+ # Updates the SDK to latest version firstly.
+ tools/android update sdk --no-ui \
+ --filter "platform-tool,tool,system-image,$SDK_TARGET_ID"
+
+ # Create android vitual devices for ARM and x86.
+ # With --force this overwrites prior configurations, if they exist.
+ tools/android create avd --name buildbot --abi armeabi-v7a \
+ --target $SDK_TARGET_ID --force <<< "no"
+
+ tools/android create avd --name buildbot-x86 --abi x86 \
+ --target $SDK_TARGET_ID --force <<< "no"
+
+ popd
+}
+
+function replace_binary {
+ local source_file=$1
+ local dest_dir=$2
+ local dest_basename=$3
+ mv -n "$dest_dir/$dest_basename" "$dest_dir/$dest_basename.orig"
+ cp "$source_file" "$dest_dir/$dest_basename"
+ echo "$dest_basename replaced by $source_file" > $dest_dir/README.PATCH
+}
+
+function install_ndk {
+ # *** Do not change without updating the 64-bit linker ***
+ local NDK_DOWNLOAD_URL="http://dl.google.com/android/ndk/android-ndk-r7-linux-x86.tar.bz2"
+ local NDK_MD5SUM="bf15e6b47bf50824c4b96849bf003ca3"
+ local NEW_LINKER_FILE="arm-linux-androideabi-ld.e4df3e0a5bb640ccfa2f30ee67fe9b3146b152d6"
+
+ if [[ -d $ANDROID_NDK_ROOT ]]; then
+ echo "NDK directory already exists, skipping install"
+ return
+ fi
+
+ echo "Installing ANDROID NDK..."
+ local SRC_ROOT="$(cd "$(dirname $0)/.."; pwd)"
+ pushd $(dirname "$ANDROID_NDK_ROOT")
+ download_and_extract "$NDK_DOWNLOAD_URL" $NDK_MD5SUM
+
+ echo "Replacing the NDK linker..."
+ local NEW_LINKER="$SRC_ROOT/third_party/aosp/$NEW_LINKER_FILE"
+ local LINKER_BASE_DIR="toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86"
+ replace_binary "$NEW_LINKER" "$LINKER_BASE_DIR/bin" "arm-linux-androideabi-ld"
+ replace_binary "$NEW_LINKER" "$LINKER_BASE_DIR/arm-linux-androideabi/bin" "ld"
+ popd
+}
+
+install_sdk
+install_ndk
+echo "$SCRIPT_VERSION" > "$VERSION_FILE"
« no previous file with comments | « build/android/envsetup.sh ('k') | build/install-build-deps-android-sdk.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698