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) | |
download | rockbox-ab9caead92eb104d30128b7b6c250dae04406850.tar.gz rockbox-ab9caead92eb104d30128b7b6c250dae04406850.zip |
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. | |||
3 | 3 | ||
4 | * Prerequisites | 4 | * Prerequisites |
5 | 5 | ||
6 | Download and install the Android SDK[1] and NDK[2]. | 6 | Download and install the Android SDK[1] and NDK[2], or run installToolchain.sh. |
7 | After you extracted the SDK, you need to run <sdk-dir>/tools/android in order to | 7 | After you extracted the SDK, you need to run <sdk-dir>/tools/android in order to |
8 | install the actual platform sdk from the available packages tab (SDK Platform | 8 | install the actual platform sdk from the available packages tab (SDK Platform |
9 | Android 1.5 or above should work). | 9 | 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 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Abort execution as soon as an error is encountered | ||
4 | # That way the script do not let the user think the process completed correctly | ||
5 | # and leave the opportunity to fix the problem and restart compilation where | ||
6 | # it stopped | ||
7 | set -e | ||
8 | |||
9 | # http://developer.android.com/sdk/index.html | ||
10 | SDK_URL="http://dl.google.com/android/android-sdk_r07-linux_x86.tgz" | ||
11 | # http://developer.android.com/sdk/ndk/index.html | ||
12 | NDK_URL="http://dl.google.com/android/ndk/android-ndk-r4b-linux-x86.zip" | ||
13 | |||
14 | prefix="${INSTALL_PREFIX:-$HOME}" | ||
15 | dldir="${DOWNLOAD_DIR:-/tmp}" | ||
16 | |||
17 | SDK_PATH=$(find $prefix -maxdepth 1 -name "android-sdk-*") | ||
18 | NDK_PATH=$(find $prefix -maxdepth 1 -name "android-ndk-*") | ||
19 | |||
20 | download_and_extract() { | ||
21 | url="$1" | ||
22 | name=${url##*/} | ||
23 | local_file="$dldir/$name" | ||
24 | if [ \! -f "$local_file" ]; then | ||
25 | echo " * Downloading $name..." | ||
26 | wget -O "$local_file" $1 | ||
27 | fi | ||
28 | |||
29 | echo " * Extracting $name..." | ||
30 | case ${local_file#*.} in | ||
31 | zip) | ||
32 | unzip -qo -d "$prefix" "$local_file" | ||
33 | ;; | ||
34 | tgz|tar.gz) | ||
35 | (cd $prefix; tar -xf "$local_file") | ||
36 | ;; | ||
37 | *) | ||
38 | echo "Couldn't figure out how to extract $local_file" ! 1>&2 | ||
39 | ;; | ||
40 | esac | ||
41 | } | ||
42 | |||
43 | if [ -z "$SDK_PATH" ]; then | ||
44 | download_and_extract $SDK_URL | ||
45 | SDK_PATH=$(realpath $prefix/android-sdk-*) | ||
46 | fi | ||
47 | if [ -z "$NDK_PATH" ]; then | ||
48 | download_and_extract $NDK_URL | ||
49 | NDK_PATH=$(realpath $prefix/android-ndk-*) | ||
50 | fi | ||
51 | |||
52 | if [ -z "$(find $SDK_PATH/platforms -type d -name 'android-*')" ]; then | ||
53 | echo " * Installing Android platforms..." | ||
54 | $SDK_PATH/tools/android update sdk --no-ui --filter platform,tool | ||
55 | fi | ||
56 | |||
57 | cat <<EOF | ||
58 | * All done! | ||
59 | |||
60 | Please set the following environment variables before running tools/configure: | ||
61 | export \$ANDROID_SDK_PATH=$SDK_PATH | ||
62 | export \$ANDROID_NDK_PATH=$NDK_PATH | ||
63 | |||
64 | EOF | ||