2014-02-02 20:27:09 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e -u
|
|
|
|
|
|
|
|
MANIFEST=AndroidManifest.xml
|
2015-06-02 17:04:06 +02:00
|
|
|
XWORDS=org.eehouse.android.xw4
|
2014-09-05 16:29:03 +02:00
|
|
|
INSTALL=''
|
2015-06-02 17:04:06 +02:00
|
|
|
UNINSTALL=''
|
2014-09-08 16:25:05 +02:00
|
|
|
CMDS=''
|
2014-02-02 20:27:09 +01:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
[ $# -ge 1 ] && echo "ERROR: $1"
|
2014-09-08 16:25:05 +02:00
|
|
|
echo "usage: $0 <cmds to ant>"
|
2014-02-02 20:27:09 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-06-02 17:04:06 +02:00
|
|
|
uninstall() {
|
|
|
|
adb devices | while read DEV TYPE; do
|
|
|
|
case "$TYPE" in
|
|
|
|
device)
|
|
|
|
adb -s $DEV uninstall $XWORDS
|
|
|
|
;;
|
|
|
|
emulator)
|
|
|
|
adb -s $DEV uninstall $XWORDS
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-09-08 16:25:05 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
2014-02-02 20:27:09 +01:00
|
|
|
case $1 in
|
2014-09-08 16:25:05 +02:00
|
|
|
--help|-h|-help|-?)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
clean|debug|release)
|
|
|
|
CMDS="$CMDS $1"
|
|
|
|
;;
|
|
|
|
install)
|
|
|
|
INSTALL=1
|
|
|
|
;;
|
2015-06-02 17:04:06 +02:00
|
|
|
reinstall)
|
|
|
|
UNINSTALL=1
|
|
|
|
INSTALL=1
|
|
|
|
;;
|
2014-09-08 16:25:05 +02:00
|
|
|
*)
|
|
|
|
usage "Unexpected param $1"
|
|
|
|
;;
|
2014-02-02 20:27:09 +01:00
|
|
|
esac
|
|
|
|
shift
|
2014-09-08 16:25:05 +02:00
|
|
|
done
|
2014-02-02 20:27:09 +01:00
|
|
|
|
2014-03-01 21:39:51 +01:00
|
|
|
while [ ! -e $MANIFEST -o $(basename $(pwd)) = 'bin' ]; do
|
2014-02-02 20:27:09 +01:00
|
|
|
[ '/' = $(pwd) ] && usage "reached root without finding $MANIFEST"
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
|
2014-02-07 16:34:09 +01:00
|
|
|
DIRNAME=$(basename $(pwd))
|
|
|
|
case $DIRNAME in
|
|
|
|
XWords4-bt)
|
|
|
|
PKG=xw4bt
|
|
|
|
;;
|
2014-02-10 16:31:52 +01:00
|
|
|
XWords4-dbg)
|
|
|
|
PKG=xw4dbg
|
|
|
|
;;
|
2014-02-07 16:34:09 +01:00
|
|
|
XWords4)
|
|
|
|
PKG=xw4
|
|
|
|
;;
|
|
|
|
*)
|
2015-08-02 23:15:14 +02:00
|
|
|
echo "running in unexpected directory $DIRNAME; hope that's ok"
|
2014-02-07 16:34:09 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-08-07 06:01:15 +02:00
|
|
|
# if we're running for the first time in this directory/variant,
|
|
|
|
# generate local.properties
|
2016-07-27 07:08:29 +02:00
|
|
|
if [ -e ../scripts/setup_local_props.sh ]; then
|
|
|
|
[ -e local.properties ] || ../scripts/setup_local_props.sh
|
|
|
|
fi
|
2015-08-07 06:01:15 +02:00
|
|
|
|
2016-03-05 21:16:23 +01:00
|
|
|
# If this fails, the "set -e" above means we won't try to install anything
|
2016-04-09 20:51:48 +02:00
|
|
|
[ -n "$CMDS" ] && ant $CMDS
|
2014-02-07 16:34:09 +01:00
|
|
|
|
2015-06-02 17:04:06 +02:00
|
|
|
if [ -n "$UNINSTALL" ]; then
|
|
|
|
uninstall
|
|
|
|
fi
|
2016-03-05 21:16:23 +01:00
|
|
|
|
2014-09-05 16:29:03 +02:00
|
|
|
if [ -n "$INSTALL" ]; then
|
2016-03-05 21:16:23 +01:00
|
|
|
# Find the newest apk in this directory and install it
|
|
|
|
APK=$(ls -t bin/*.apk | head -n 1)
|
|
|
|
adb-install.sh -p $APK
|
2014-02-07 16:34:09 +01:00
|
|
|
fi
|
2014-09-05 16:29:03 +02:00
|
|
|
|
|
|
|
# if [ "$CMDS" != "${CMDS%%install}" ]; then
|
2016-07-10 22:09:20 +02:00
|
|
|
# adb shell am start -n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.MainActivity
|
2014-09-05 16:29:03 +02:00
|
|
|
# fi
|