[Android] [PATCH 1/6] compile.sh: handle arguments in one place

Thomas Guillem tom at gllm.fr
Tue Oct 21 11:48:38 CEST 2014


---
 compile.sh | 51 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/compile.sh b/compile.sh
index fad780f..abb3773 100755
--- a/compile.sh
+++ b/compile.sh
@@ -6,22 +6,6 @@
 
 set -e
 
-BUILD=
-FETCH=
-case "$1" in
-    --fetch)
-    FETCH=1
-    shift
-    ;;
-    --build)
-    BUILD=1
-    shift
-    ;;
-    *)
-    FETCH=1
-    BUILD=1
-    ;;
-esac
 
 if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" ]; then
    echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting."
@@ -34,6 +18,35 @@ if [ -z "$ANDROID_ABI" ]; then
    exit 1
 fi
 
+BUILD=0
+FETCH=0
+RELEASE=0
+JNI=0
+
+for i in ${@}; do
+    case "$i" in
+        --fetch)
+        FETCH=1
+        ;;
+        --build)
+        BUILD=1
+        ;;
+        release|--release)
+        RELEASE=1
+        ;;
+        jni|--jni)
+        JNI=1
+        ;;
+        *)
+        ;;
+    esac
+done
+
+if [ "$BUILD" = 0 -a "$FETCH" = 0 ];then
+    BUILD=1
+    FETCH=1
+fi
+
 # Set up ABI variables
 if [ ${ANDROID_ABI} = "x86" ] ; then
     TARGET_TUPLE="i686-linux-android"
@@ -274,13 +287,11 @@ cd contrib/contrib-android-${TARGET_TUPLE}
 [ ${ANDROID_ABI} = "armeabi-v7a" ] && echo "NOTHUMB := -marm" >> config.mak
 
 # Release or not?
-if [ $# -ne 0 ] && [ "$1" = "release" ]; then
+if [ "$RELEASE" = 1 ]; then
     OPTS=""
     EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
-    RELEASE=1
 else
     OPTS="--enable-debug"
-    RELEASE=0
 fi
 
 echo "EXTRA_CFLAGS= -g ${EXTRA_CFLAGS}" >> config.mak
@@ -300,7 +311,7 @@ make $MAKEFLAGS
 ############
 cd ../.. && mkdir -p build-android-${TARGET_TUPLE} && cd build-android-${TARGET_TUPLE}
 
-if [ $# -eq 1 ] && [ "$1" = "jni" ]; then
+if [ "$JNI" = 1 ]; then
     CLEAN="jniclean"
     TARGET="vlc-android/obj/local/${ANDROID_ABI}/libvlcjni.so"
 else
-- 
2.1.0



More information about the Android mailing list