diff --git a/xwords4/android/scripts/cleanvariants.sh b/xwords4/android/scripts/cleanvariants.sh index 14351deae..c18fd98bc 100755 --- a/xwords4/android/scripts/cleanvariants.sh +++ b/xwords4/android/scripts/cleanvariants.sh @@ -2,25 +2,21 @@ set -u -e -DIRS="" -VARIANT="" +DIR="" usage() { [ $# -ge 1 ] && echo "ERROR: $1" - echo "usage: $0 [--dest-dir ]*" + echo "usage: $0 [--dir ]" + echo " uses variant parent of CWD as default if not provided" exit 1 } while [ $# -ge 1 ]; do echo "\"$1\"" case $1 in - --variant-name) + --dir) shift - VARIANT=$1 - ;; - --dest-dir) - shift - DIRS="$DIRS $1" + DIR="$DIR $1" ;; *) usage "unexpected param $1" @@ -29,12 +25,26 @@ while [ $# -ge 1 ]; do shift done -for DIR in $DIRS; do - for FILE in $(find $DIR -type f); do - if git ls-files $FILE --error-unmatch 2>/dev/null; then - echo "skipping $FILE; it's under version control within this variant" +if [ -z "$DIR" ]; then + while :; do + WD=$(pwd) + if [ "/" = "$WD" ]; then + echo "reached / without finding AndroidManifest.xml" + exit 1 + elif [ -e ${WD}/AndroidManifest.xml ]; then + DIR=$WD + break else - rm $FILE + cd .. fi done +fi + +for FILE in $(find $DIR -type f); do + if git ls-files $FILE --error-unmatch 2>/dev/null; then + echo "skipping $FILE; it's under version control within this variant" + else + echo "removing $FILE" + rm $FILE + fi done