#!/bin/sh
ABI=`adb shell getprop ro.product.cpu.abi | tr -d '\r'`
OUTPUT_DIR=/data/local/tmp

cd $(dirname $0)
ndk-build -j8

if [[ "$?" != "0" ]]; then
  echo "Compile failed"
  exit 1
fi

# Copy over files
for f in libs/$ABI/*; do
  adb push $f $OUTPUT_DIR;
done

# Execute
adb shell "LD_LIBRARY_PATH=$OUTPUT_DIR $OUTPUT_DIR/reactnative_test $*"
