diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-11-06 17:32:52 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-11-06 17:32:52 +0000 |
commit | ab9caead92eb104d30128b7b6c250dae04406850 (patch) | |
tree | e771b0b301efa71170fe2eb7c496434f402f8222 | |
parent | df1ec391ffd625f64e08f70a53dbf56efed4bbb4 (diff) |
Android: add a script which allows headless installation of the Android tools required for compilation
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28525 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | android/README | 2 | ||||
-rwxr-xr-x | android/installToolchain.sh | 64 |
2 files changed, 65 insertions, 1 deletions
diff --git a/android/README b/android/README index 8f0a85cabb..99f33aeb59 100644 --- a/android/README +++ b/android/README @@ -3,7 +3,7 @@ application for android. * Prerequisites -Download and install the Android SDK[1] and NDK[2]. +Download and install the Android SDK[1] and NDK[2], or run installToolchain.sh. After you extracted the SDK, you need to run <sdk-dir>/tools/android in order to install the actual platform sdk from the available packages tab (SDK Platform Android 1.5 or above should work). diff --git a/android/installToolchain.sh b/android/installToolchain.sh new file mode 100755 index 0000000000..4bea4ae0e1 --- /dev/null +++ b/android/installToolchain.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Abort execution as soon as an error is encountered +# That way the script do not let the user think the process completed correctly +# and leave the opportunity to fix the problem and restart compilation where +# it stopped +set -e + +# http://developer.android.com/sdk/index.html +SDK_URL="http://dl.google.com/android/android-sdk_r07-linux_x86.tgz" +# http://developer.android.com/sdk/ndk/index.html +NDK_URL="http://dl.google.com/android/ndk/android-ndk-r4b-linux-x86.zip" + +prefix="${INSTALL_PREFIX:-$HOME}" +dldir="${DOWNLOAD_DIR:-/tmp}" + +SDK_PATH=$(find $prefix -maxdepth 1 -name "android-sdk-*") +NDK_PATH=$(find $prefix -maxdepth 1 -name "android-ndk-*") + +download_and_extract() { + url="$1" + name=${url##*/} + local_file="$dldir/$name" + if [ \! -f "$local_file" ]; then + echo " * Downloading $name..." + wget -O "$local_file" $1 + fi + + echo " * Extracting $name..." + case ${local_file#*.} in + zip) + unzip -qo -d "$prefix" "$local_file" + ;; + tgz|tar.gz) + (cd $prefix; tar -xf "$local_file") + ;; + *) + echo "Couldn't figure out how to extract $local_file" ! 1>&2 + ;; + esac +} + +if [ -z "$SDK_PATH" ]; then + download_and_extract $SDK_URL + SDK_PATH=$(realpath $prefix/android-sdk-*) +fi +if [ -z "$NDK_PATH" ]; then + download_and_extract $NDK_URL + NDK_PATH=$(realpath $prefix/android-ndk-*) +fi + +if [ -z "$(find $SDK_PATH/platforms -type d -name 'android-*')" ]; then + echo " * Installing Android platforms..." + $SDK_PATH/tools/android update sdk --no-ui --filter platform,tool +fi + +cat <<EOF + * All done! + +Please set the following environment variables before running tools/configure: +export \$ANDROID_SDK_PATH=$SDK_PATH +export \$ANDROID_NDK_PATH=$NDK_PATH + +EOF |