From 238aa4edfb44a90743d14b6fd8b55afb316af2c0 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Tue, 1 Jul 2014 15:13:14 -0400 Subject: [PATCH] update scripts in tools/ to work with the new directory structure --- tools/check-missing-drawables.py | 4 ++-- tools/checkstyle.sh | 6 ++++-- tools/release-checks.sh | 14 ++++++++------ tools/remove-unused-strings.sh | 10 ++++++---- tools/update-translations.sh | 9 +++++---- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/tools/check-missing-drawables.py b/tools/check-missing-drawables.py index cadcfb15f30d..1f573ad7cd07 100644 --- a/tools/check-missing-drawables.py +++ b/tools/check-missing-drawables.py @@ -3,13 +3,14 @@ import os import sys +RESDIR="WordPress/src/main/res" TO_CHECK = ["-mdpi", "-hdpi", "-xhdpi", "-xxhdpi", ""] def main(): if len(sys.argv) == 2: check_drawables(sys.argv[1]) else: - check_drawables("res/") + check_drawables(RESDIR) def check_drawables(rootdir): filenames = defaultdict(set) @@ -36,6 +37,5 @@ def check_drawables(rootdir): for i in results: print(i + " missing in: " + " ".join(results[i])) - if __name__ == "__main__": main() diff --git a/tools/checkstyle.sh b/tools/checkstyle.sh index 8f536e286455..542756932d27 100755 --- a/tools/checkstyle.sh +++ b/tools/checkstyle.sh @@ -1,7 +1,9 @@ #!/bin/sh +DEFAULT_SRC_SOURCES=WordPress/src/main/java + if [ x"$1" == x ]; then - checkstyle -c cq-configs/checkstyle/checkstyle.xml -r src/ + checkstyle -c cq-configs/checkstyle/checkstyle.xml -r $DEFAULT_SRC_SOURCES else checkstyle -c cq-configs/checkstyle/checkstyle.xml $@ -fi \ No newline at end of file +fi diff --git a/tools/release-checks.sh b/tools/release-checks.sh index 56c797321061..5d0b1a25c775 100755 --- a/tools/release-checks.sh +++ b/tools/release-checks.sh @@ -1,6 +1,8 @@ #!/bin/sh LANG_FILE=tools/exported-language-codes.csv +RESDIR=WordPress/src/main/res/ +BUILDFILE=WordPress/build.gradle function checkDeviceToTest() { lines=$(adb devices -l|wc -l) @@ -27,7 +29,7 @@ function pFail() { function checkENStrings() { if [[ -n $(git status --porcelain|grep "M res") ]]; then - /bin/echo -n "Unstagged changes detected in res/ - can't continue..." + /bin/echo -n "Unstagged changes detected in $RESDIR/ - can't continue..." pFail exit 3 fi @@ -35,11 +37,11 @@ function checkENStrings() { git stash | grep "No local changes to save" > /dev/null needpop=$? - rm -f res/values-??/strings.xml + rm -f $RESDIR/values-??/strings.xml /bin/echo -n "Check for missing strings (slow)..." ./gradlew build > /dev/null 2>&1 && pOk || (pFail; ./gradlew build) ./gradlew clean - git checkout -- res/ + git checkout -- $RESDIR/ # restore local changes if [ $needpop -eq 1 ]; then @@ -68,13 +70,13 @@ function checkNewLanguages() { } function checkVersions() { - gradle_version=$(grep -E 'versionName' build.gradle | sed s/versionName// | grep -Eo "[a-zA-Z0-9.-]+" ) + gradle_version=$(grep -E 'versionName' $BUILDFILE | sed s/versionName// | grep -Eo "[a-zA-Z0-9.-]+" ) tag=$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags|tail -1) if [[ $gradle_version != $tag ]]; then - /bin/echo -n "build.gradle version and git tag version mismatch..." + /bin/echo -n "$BUILDFILE version and git tag version mismatch..." pFail fi - echo "build.gradle version $gradle_version" + echo "$BUILDFILE version $gradle_version" echo "last git tag version is $tag" } diff --git a/tools/remove-unused-strings.sh b/tools/remove-unused-strings.sh index 517a70aa8fc4..2b0c6eaf4368 100755 --- a/tools/remove-unused-strings.sh +++ b/tools/remove-unused-strings.sh @@ -1,7 +1,9 @@ #!/bin/sh +RESDIR=WordPress/src/main/res/ + unused_strings=$(lint --check UnusedResources . \ - | grep "res/values/strings.xml" \ + | grep "$RESDIR/values/strings.xml" \ | grep -o "R\.string\.[^ ]*" \ | sed "s/R.string.//" \ | tr "\n" "|" \ @@ -10,9 +12,9 @@ unused_strings=$(lint --check UnusedResources . \ | sed 's/|"$//') if [ "$unused_strings"x = x ]; then - echo res/values/strings.xml is already clean + echo $RESDIR/values/strings.xml is already clean else - grep -E -v "$unused_strings" res/values/strings.xml > tmp.xml - mv tmp.xml res/values/strings.xml + grep -E -v "$unused_strings" $RESDIR/values/strings.xml > tmp.xml + mv tmp.xml $RESDIR/values/strings.xml echo $(echo "$unused_strings" | sed "s/[^|]//g" | wc -c) strings removed fi diff --git a/tools/update-translations.sh b/tools/update-translations.sh index 1a9b2f5bfe93..ccdbe2469d6c 100755 --- a/tools/update-translations.sh +++ b/tools/update-translations.sh @@ -1,13 +1,14 @@ #!/bin/sh LANG_FILE=tools/exported-language-codes.csv +RESDIR=WordPress/src/main/res/ for line in $(cat $LANG_FILE) ; do code=$(echo $line|cut -d "," -f1|tr -d " ") local=$(echo $line|cut -d "," -f2|tr -d " ") echo updating $local - $code - test -d res/values-$local/ || mkdir res/values-$local/ - test -f res/values-$local/strings.xml && cp res/values-$local/strings.xml res/values-$local/strings.xml.bak - curl -sSf --globoff -o res/values-$local/strings.xml "http://translate.wordpress.org/projects/android/dev/$code/default/export-translations?filters[status]=current&format=android" || (echo Error downloading $code && rm -rf res/values-$local/) - test -f res/values-$local/strings.xml.bak && rm res/values-$local/strings.xml.bak + test -d $RESDIR/values-$local/ || mkdir $RESDIR/values-$local/ + test -f $RESDIR/values-$local/strings.xml && cp $RESDIR/values-$local/strings.xml $RESDIR/values-$local/strings.xml.bak + curl -sSf --globoff -o $RESDIR/values-$local/strings.xml "http://translate.wordpress.org/projects/android/dev/$code/default/export-translations?filters[status]=current&format=android" || (echo Error downloading $code && rm -rf $RESDIR/values-$local/) + test -f $RESDIR/values-$local/strings.xml.bak && rm $RESDIR/values-$local/strings.xml.bak done