11#! /bin/bash
22
3+ set -e
4+
35BASEDIR=$( dirname " $0 " )
46cd $BASEDIR /../
57BASEDIR=` pwd`
@@ -12,17 +14,39 @@ CARGO_HOME=$BASEDIR/tools/.cargo
1214RUSTUP_HOME=$BASEDIR /tools/.rustup
1315
1416# Install the latest rust stable and cargo
15- ` curl https://sh.rustup.rs -sSf | CARGO_HOME=$BASEDIR /tools/.cargo RUSTUP_HOME=$BASEDIR /tools/.rustup sh -s -- -y`
16- PATH=$PATH :$CARGO_HOME /bin
17+ PATH=$CARGO_HOME /bin:$PATH
18+
19+ curl https://sh.rustup.rs -sSf > tools/rustup.sh
20+ chmod +x tools/rustup.sh
1721
18- rustup default stable
19- rustup target add arm-linux-androideabi
22+ CARGO_HOME=$BASEDIR /tools/.cargo RUSTUP_HOME=$BASEDIR /tools/.rustup sh tools/rustup.sh --no-modify-path -y
23+
24+ $CARGO_HOME /bin/rustup default stable
25+ $CARGO_HOME /bin/rustup target add arm-linux-androideabi
2026
2127# Install xargo
22- cargo install xargo --force
28+ $CARGO_HOME /bin/ cargo install xargo --force --root $CARGO_HOME
2329
2430# Create an Android toolchain
2531cd $BASEDIR
32+
33+ # Get the appropriate env variable in order to create the needed toolchain
34+
35+ if [ -n " ${ANDROID_NDK} " ]; then
36+ echo " Found a pre-installed NDK in ${ANDROID_NDK} "
37+ else
38+ # If the NDK does not exist, download it
39+ echo " Did not find a pre-installed NDK... Downloading one"
40+ curl -L http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -O
41+ chmod u+x android-ndk-r10e-linux-x86_64.bin
42+ ./android-ndk-r10e-linux-x86_64.bin > /dev/null
43+ rm android-ndk-r10e-linux-x86_64.bin
44+ ANDROID_NDK=` pwd` /android-ndk-r10e
45+ PATH=$PATH :${ANDROID_NDK}
46+ fi
47+
48+ ANDROID_NDK_HOME=${ANDROID_NDK}
49+
2650sh $ANDROID_NDK /build/tools/make-standalone-toolchain.sh --platform=android-16 --arch=arm --install-dir=android-toolchain
2751cd android-toolchain
2852ANDROID_TOOLCHAIN_DIR=` pwd`
@@ -34,7 +58,7 @@ mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=${BA
3458
3559# Go to the .cargo directory
3660cd $BASEDIR /rust
37- mkdir .cargo
61+ mkdir -p .cargo
3862cd .cargo
3963CURR_DIR=` pwd`
4064echo Entered directory $CURR_DIR
0 commit comments