Skip to content

Commit 7834473

Browse files
committed
add more sanity check about android sdk / ndk. dont do anything if sdk/ndk path are wrong, or if we dont found arm gcc compiler cause of missing sdk android platform tools
1 parent 9b7df79 commit 7834473

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

distribute.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ function push_arm() {
104104
fi
105105

106106
export PATH="$ANDROIDNDK/toolchains/$TOOLCHAIN_PREFIX-$TOOLCHAIN_VERSION/prebuilt/linux-x86/bin/:$ANDROIDNDK:$ANDROIDSDK/tools:$PATH"
107+
108+
# search compiler in the path, to fail now instead of later.
109+
CC=$(which $TOOLCHAIN_PREFIX-gcc)
110+
if [ "X$CC" == "X" ]; then
111+
error "Unable to found compiler ($TOOLCHAIN_PREFIX-gcc) !!"
112+
error "1. Ensure that SDK/NDK paths are correct"
113+
error "2. Ensure that you've the Android API $ANDROIDAPI SDK Platform (via android tool)"
114+
exit 1
115+
else
116+
debug "Compiler found at $CC"
117+
fi
118+
107119
export CC="$TOOLCHAIN_PREFIX-gcc $CFLAGS"
108120
export CXX="$TOOLCHAIN_PREFIX-g++ $CXXFLAGS"
109121
export AR="$TOOLCHAIN_PREFIX-ar"
@@ -156,11 +168,21 @@ function run_prepare() {
156168
error "No ANDROIDSDK environment set, abort"
157169
exit -1
158170
fi
171+
if [ ! -d "$ANDROIDSDK" ]; then
172+
echo "ANDROIDSDK=$ANDROIDSDK"
173+
error "ANDROIDSDK path is invalid, it must be a directory. abort."
174+
exit 1
175+
fi
159176

160177
if [ "X$ANDROIDNDK" == "X" ]; then
161178
error "No ANDROIDNDK environment set, abort"
162179
exit -1
163180
fi
181+
if [ ! -d "$ANDROIDNDK" ]; then
182+
echo "ANDROIDNDK=$ANDROIDSDK"
183+
error "ANDROIDNDK path is invalid, it must be a directory. abort."
184+
exit 1
185+
fi
164186

165187
if [ "X$ANDROIDAPI" == "X" ]; then
166188
export ANDROIDAPI=14
@@ -220,6 +242,11 @@ function run_prepare() {
220242
# create initial files
221243
echo "target=android-$ANDROIDAPI" > $SRC_PATH/default.properties
222244
echo "sdk.dir=$ANDROIDSDK" > $SRC_PATH/local.properties
245+
246+
# check arm env
247+
push_arm
248+
debug "PATH is $PATH"
249+
pop_arm
223250
}
224251

225252
function in_array() {
@@ -490,11 +517,6 @@ function run() {
490517
run_prepare
491518
run_source_modules
492519
run_get_packages
493-
494-
push_arm
495-
debug "PATH is $PATH"
496-
pop_arm
497-
498520
run_prebuild
499521
run_build
500522
run_postbuild

0 commit comments

Comments
 (0)