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
9 SDK_DOWNLOAD_URL
="http://developer.android.com/sdk/index.html"
10 NDK_DOWNLOAD_URL
="http://developer.android.com/sdk/ndk/index.html"
15 wget
-q -O - $base_url |
grep dl.google.com |
sed 's/.*"\(http:\/\/.*\)".*/\1/' |
grep $os |
grep -v .exe
# Windows hack
21 SDK_URL
=$
(find_url
$SDK_DOWNLOAD_URL linux
)
22 NDK_URL
=$
(find_url
$NDK_DOWNLOAD_URL linux
)
27 SDK_URL
=$
(find_url
$SDK_DOWNLOAD_URL mac
)
28 NDK_URL
=$
(find_url
$NDK_DOWNLOAD_URL darwin
)
33 SDK_URL
=$
(find_url
$SDK_DOWNLOAD_URL windows
)
34 NDK_URL
=$
(find_url
$NDK_DOWNLOAD_URL windows
)
35 ANDROID
=tools
/android.bat
39 prefix
="${INSTALL_PREFIX:-$HOME}"
40 dldir
="${DOWNLOAD_DIR:-/tmp}"
42 SDK_PATH
=$
(find $prefix -maxdepth 1 -name "android-sdk-*")
43 NDK_PATH
=$
(find $prefix -maxdepth 1 -name "android-ndk-*")
45 download_and_extract
() {
48 local_file
="$dldir/$name"
49 if [ \
! -f "$local_file" ]; then
50 echo " * Downloading $name..."
51 wget
-O "$local_file" $1
54 echo " * Extracting $name..."
55 case ${local_file#*.} in
57 unzip -qo -d "$prefix" "$local_file"
60 (cd $prefix; tar -xf "$local_file")
63 (cd $prefix; tar -xjf "$local_file")
66 echo "Couldn't figure out how to extract $local_file" ! 1>&2
71 if [ -z "$SDK_PATH" ]; then
72 download_and_extract
$SDK_URL
73 # OS X doesn't know about realname, use basename instead.
74 SDK_PATH
=$prefix/$
(basename $prefix/android-sdk-
*)
76 if [ -z "$NDK_PATH" ]; then
77 download_and_extract
$NDK_URL
78 NDK_PATH
=$prefix/$
(basename $prefix/android-ndk-
*)
81 if [ -z "$(find $SDK_PATH/platforms -type d -name 'android-*')" ]; then
82 echo " * Installing Android platforms..."
83 $SDK_PATH/$ANDROID update sdk
--no-ui --filter platform
,platform-tool
,tool
89 Please set the following environment variables before running tools/configure:
90 export ANDROID_SDK_PATH=$SDK_PATH
91 export ANDROID_NDK_PATH=$NDK_PATH