From ff12cc6f91928987684eda1e9d0f2f8a2b166218 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 5 Mar 2016 12:16:23 -0800 Subject: [PATCH] tweak scripts to have better default behavior --- xwords4/android/scripts/adb-install.sh | 47 +++++++++++++++---------- xwords4/android/scripts/find-and-ant.sh | 6 +++- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/xwords4/android/scripts/adb-install.sh b/xwords4/android/scripts/adb-install.sh index 967f82e1d..96891887e 100755 --- a/xwords4/android/scripts/adb-install.sh +++ b/xwords4/android/scripts/adb-install.sh @@ -1,10 +1,10 @@ -#!/bin/sh +#!/bin/bash set -u -e usage() { [ $# -ge 1 ] && echo "Error: $1" - echo "usage: $(basename $0) [-e|-d] [-p /path/to/.apk]" + echo "usage: $(basename $0) [-e|-d] (-p /path/to/.apk)+" exit 1 } @@ -12,8 +12,11 @@ if [ ! -e build.xml ]; then usage "No build.xml; please run me from the top android directory" fi -APK=./bin/XWords4-debug.apk +APKS='' +DEVICES='' DIRNAME=$(basename $(pwd)) +ADB="$(which adb)" + case $DIRNAME in XWords4-dbg) PKG=xw4dbg @@ -29,22 +32,20 @@ case $DIRNAME in ;; esac -DEVICES='' - while [ $# -ge 1 ]; do case $1 in -e) - DEV="$(adb devices | grep '^emulator' | awk '{print $1}')" + DEV="$($ADB devices | grep '^emulator' | awk '{print $1}')" DEVICES="$DEVICES $DEV" ;; -d) - DEV="$(adb devices | grep -v emulator | grep 'device$' | awk '{print $1}')" + DEV="$($ADB devices | grep -v emulator | grep 'device$' | awk '{print $1}')" DEVICES="$DEVICES $DEV" ;; -p) [ $# -gt 1 ] || usage "-p requires an argument" shift - APK=$1 + APKS="$APKS $1" ;; *) usage @@ -53,22 +54,30 @@ while [ $# -ge 1 ]; do shift done -[ -e $APK ] || usage "$APK not found" +if [ -z "$DEVICES" ]; then + while read LINE; do + if echo $LINE | grep -q "device$"; then + DEVICE=$(echo $LINE | awk '{print $1}') + DEVICES="$DEVICES $DEVICE" + fi + done <<< "$($ADB devices)" +fi -if [ -n "$DEVICES" ]; then - echo "installing this binary. Check the age..." - ls -l $APK - echo "" +# If no apk specified, take the newest built +if [ -z "$APKS" ]; then + APKS=$(ls -t bin/*.apk | head -n 1) fi COUNT=0 - for DEVICE in $DEVICES; do - echo $DEVICE - adb -s $DEVICE install -r $APK - adb -s $DEVICE shell am start \ - -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity - COUNT=$((COUNT+1)) + for APK in $APKS; do + echo "installing $APK; details:" + ls -l $APK + $ADB -s $DEVICE install -r $APK + $ADB -s $DEVICE shell am start \ + -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesListActivity + done + COUNT=$((COUNT+1)) done echo "installed into $COUNT devices/emulators" diff --git a/xwords4/android/scripts/find-and-ant.sh b/xwords4/android/scripts/find-and-ant.sh index 76d91d679..35e98fd30 100755 --- a/xwords4/android/scripts/find-and-ant.sh +++ b/xwords4/android/scripts/find-and-ant.sh @@ -74,13 +74,17 @@ esac # generate local.properties [ -e local.properties ] || ../scripts/setup_local_props.sh +# If this fails, the "set -e" above means we won't try to install anything ant $CMDS if [ -n "$UNINSTALL" ]; then uninstall fi + if [ -n "$INSTALL" ]; then - adb-install.sh -e -d + # Find the newest apk in this directory and install it + APK=$(ls -t bin/*.apk | head -n 1) + adb-install.sh -p $APK fi # if [ "$CMDS" != "${CMDS%%install}" ]; then