1 #!/bin/sh 2 3 # The purpose of this script is the following: 4 # 5 # 1/ Build the libraries under prebuilts/jni/ 6 # 7 # 2/ Build the project under jni/ 8 # 9 # 3/ Check that the prebuilt shared library was copied to 10 # $NDK_OUT/<abi>/objs. 11 # 12 # 4/ Check that the prebuilt static library was not copied to 13 # the same directory. 14 # 15 16 PROGDIR=$(dirname "$0") 17 18 OUT=$PROGDIR/obj/local 19 PREBUILTS_DIR=$PROGDIR/prebuilts 20 PREBUILTS_DIR=$(cd "$PREBUILTS_DIR" && pwd) 21 22 ABIS= 23 for OPT; do 24 case $OPT in 25 APP_ABI=*) 26 ABIS=${OPT##APP_ABI=} 27 ;; 28 esac 29 done 30 31 if [ -z "$ABIS" ]; then 32 ABIS="armeabi armeabi-v7a x86 mips" 33 fi 34 35 # Step 1: Build prebuilt libraries. 36 $NDK/ndk-build -C "$PREBUILTS_DIR" 37 if [ $? != 0 ]; then 38 echo "ERROR: Can't build prebuilt libraries!" 39 exit 1 40 fi 41 42 # Step 2: Build the project 43 PREBUILTS_DIR=$PREBUILTS_DIR $NDK/ndk-build -C "$PROGDIR" 44 if [ $? != 0 ]; then 45 echo "ERROR: Can't build project!" 46 exit 1 47 fi 48 49 # Step 3: Check that the prebuilt shared library was copied to the 50 # right location. 51 # 52 53 FAILURES=0 54 for ABI in $ABIS; do 55 SHARED_LIB=$OUT/$ABI/libfoo.so 56 STATIC_LIB=$OUT/$ABI/libbar.a 57 printf "Checking for $ABI shared library: " 58 if [ ! -f "$SHARED_LIB" ]; then 59 printf "KO! missing file: $SHARED_LIB\n" 60 FAILURES=$(( $FAILURES + 1 )) 61 else 62 printf "ok\n" 63 fi 64 65 printf "Checking for $ABI static library: " 66 if [ -f "$STATIC_LIB" ]; then 67 printf "KO! file should not exist: $STATIC_LIB\n" 68 FAILURES=$(( $FAILURES + 1 )) 69 else 70 printf "ok\n" 71 fi 72 done 73 74 if [ "$FAILURES" = 0 ]; then 75 echo "Everything's ok. Congratulations!" 76 exit 0 77 else 78 echo "Found $FAILURES failures! Please fix ndk-build!" 79 exit 1 80 fi 81