1#!/bin/bash
2
3# Run a GN-built Android binary on the connected device.
4#
5# Example usage:
6#  $ ninja -C out dm
7#  $ droid out/dm --src gm --config gpu
8#
9# See https://skia.org/user/quick/gn for build instructions.
10
11dst_dir=/data/local/tmp
12path="$1"
13name="$(basename "$path")"
14shift
15
16if ! [ -d resources ]; then
17    echo run this from the skia tree
18    exit 1
19fi
20
21dirs=''
22for dir in $(find resources -type d); do dirs="$dirs \"${dir}\""; done
23
24set -e
25set -x
26
27adb shell "cd \"$dst_dir\"; mkdir -p $dirs"
28adb push --sync resources "${dst_dir}/"
29adb push --sync "$path" "${dst_dir}/${name}"
30adb shell "cd \"$dst_dir\"; chmod +x \"$name\"; \"./$name\" $*"
31