1 # Special script used to check that LOCAL_SHORT_COMMANDS works 2 # correctly even when using a very large number of source files 3 # when building a static or shared library. 4 # 5 # We're going to auto-generate all the files we need in a 6 # temporary directory, because that's how we roll. 7 # 8 9 PROGDIR=$(dirname $0) 10 PROGDIR=$(cd "$PROGDIR" && pwd) 11 12 # Clean generated binaries 13 rm -rf "$PROGDIR/obj" "$PROGDIR/libs" 14 15 # Now run the build 16 if [ -z "$APP_ABI" ]; then 17 for OPT; do 18 case $OPT in 19 APP_ABI=*) 20 APP_ABI=${OPT##APP_ABI=} 21 ;; 22 esac 23 done 24 $NDK/ndk-build -C "$PROGDIR" "$@" 25 RET=$? 26 else 27 $NDK/ndk-build -C "$PROGDIR" "$@" APP_ABI="$APP_ABI" 28 RET=$? 29 fi 30 31 # find objdump. Any arch's objdump can do "-s -j". We just need to find one 32 # from $NDK/toolchains because MacOSX doesn't have that by default. 33 get_build_var () 34 { 35 if [ -z "$APP_ABI" ]; then 36 make --no-print-dir -f $NDK/build/core/build-local.mk DUMP_$1 | tail -1 37 else 38 make --no-print-dir -f $NDK/build/core/build-local.mk DUMP_$1 APP_ABI="$APP_ABI" | tail -1 39 fi 40 } 41 42 TOOLCHAIN_PREFIX=`get_build_var TOOLCHAIN_PREFIX` 43 OBJDUMP=${TOOLCHAIN_PREFIX}objdump 44 45 # check if linker.list is empty 46 ALL_SO=`find libs -name "*.so"` 47 for SO in $ALL_SO; do 48 NUM_LINE=`$OBJDUMP -s -j.rodata $SO | wc -l | tr -d ' '` 49 if [ "$NUM_LINE" != "7" ]; then 50 echo "ERROR: Fail to merge string literals!" 51 exit 1 52 fi 53 NUM_ABCD=`$OBJDUMP -s -j.rodata $SO | grep abcd | wc -l | tr -d ' '` 54 if [ "$NUM_ABCD" != "2" ]; then 55 echo "ERROR: abcd should appear exactly twice!" 56 exit 1 57 fi 58 done 59 60 # Clean generated binaries 61 rm -rf "$PROGDIR/obj" "$PROGDIR/libs" 62 63 # Exit 64 exit $RET 65