1#!/bin/bash
2
3# Run an Android NDK binary on the connected device.
4#
5# Example usage:
6# $ cd <builddir>
7# $ make vk-unittests
8# $ ../rundroid vk-unittests
9
10if [ "$#" -lt 1 ]; then
11    echo "Usage: $0 <executable>"
12    exit 1
13fi
14
15dst_dir=/data/local/tmp
16path="$1"
17name="$(basename "$path")"
18shift
19
20if [ -z "$ANDROID_HOME" ]; then
21    ANDROID_HOME=$HOME/Android/Sdk
22fi
23
24set -e
25set -x
26
27for lib in libGLESv2_swiftshader.so libEGL_swiftshader.so libvk_swiftshader.so; do
28    adb push --sync "$lib" "${dst_dir}/${lib}"
29done
30
31adb push --sync "$ANDROID_HOME/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so" "${dst_dir}/libc++_shared.so"
32
33adb push --sync "$path" "${dst_dir}/${name}"
34adb shell "cd \"$dst_dir\"; chmod +x \"$name\"; LD_LIBRARY_PATH=. ./$name $*"
35