1dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# Special script used to check that LOCAL_SHORT_COMMANDS works 2dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# correctly even when using a very large number of source files 3dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# when building a static or shared library. 4dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# 5dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# We're going to auto-generate all the files we need in a 6dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# temporary directory, because that's how we roll. 7dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# 8dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 9dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew HsiehPROGDIR=$(dirname $0) 10dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew HsiehPROGDIR=$(cd "$PROGDIR" && pwd) 11dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 12dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# Clean generated binaries 13dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsiehrm -rf "$PROGDIR/obj" "$PROGDIR/libs" 14dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 15dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# Now run the build 16252397df58493a303bc63f241843fbcf787fa82fAndrew Hsiehif [ -z "$APP_ABI" ]; then 17252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh for OPT; do 18252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh case $OPT in 19252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh APP_ABI=*) 20252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh APP_ABI=${OPT##APP_ABI=} 21252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh ;; 22252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh esac 23252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh done 24252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh $NDK/ndk-build -C "$PROGDIR" "$@" 25252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh RET=$? 26252397df58493a303bc63f241843fbcf787fa82fAndrew Hsiehelse 27252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh $NDK/ndk-build -C "$PROGDIR" "$@" APP_ABI="$APP_ABI" 28252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh RET=$? 29252397df58493a303bc63f241843fbcf787fa82fAndrew Hsiehfi 30dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 3116b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh# find objdump. Any arch's objdump can do "-s -j". We just need to find one 3216b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh# from $NDK/toolchains because MacOSX doesn't have that by default. 3316b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsiehget_build_var () 3416b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh{ 35252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh if [ -z "$APP_ABI" ]; then 36252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh make --no-print-dir -f $NDK/build/core/build-local.mk DUMP_$1 | tail -1 37252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh else 38252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh make --no-print-dir -f $NDK/build/core/build-local.mk DUMP_$1 APP_ABI="$APP_ABI" | tail -1 39252397df58493a303bc63f241843fbcf787fa82fAndrew Hsieh fi 4016b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh} 4116b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh 4216b247b7d634eb880b42f56c939323ae16cc6275Andrew HsiehTOOLCHAIN_PREFIX=`get_build_var TOOLCHAIN_PREFIX` 4316b247b7d634eb880b42f56c939323ae16cc6275Andrew HsiehOBJDUMP=${TOOLCHAIN_PREFIX}objdump 4416b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh 45dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# check if linker.list is empty 46dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew HsiehALL_SO=`find libs -name "*.so"` 47dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsiehfor SO in $ALL_SO; do 4816b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh NUM_LINE=`$OBJDUMP -s -j.rodata $SO | wc -l | tr -d ' '` 49dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh if [ "$NUM_LINE" != "7" ]; then 50dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh echo "ERROR: Fail to merge string literals!" 51dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh exit 1 52dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh fi 5316b247b7d634eb880b42f56c939323ae16cc6275Andrew Hsieh NUM_ABCD=`$OBJDUMP -s -j.rodata $SO | grep abcd | wc -l | tr -d ' '` 54dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh if [ "$NUM_ABCD" != "2" ]; then 55dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh echo "ERROR: abcd should appear exactly twice!" 56dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh exit 1 57dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh fi 58dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsiehdone 59dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 60dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# Clean generated binaries 61dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsiehrm -rf "$PROGDIR/obj" "$PROGDIR/libs" 62dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh 63dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsieh# Exit 64dbc3c9a2888fcc3c729d10c76490fd8adc001f15Andrew Hsiehexit $RET 65