Skip to content

Commit

Permalink
update scripts in tools/ to work with the new directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jul 1, 2014
1 parent f61631e commit 238aa4e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions tools/check-missing-drawables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,6 +37,5 @@ def check_drawables(rootdir):
for i in results:
print(i + " missing in: " + " ".join(results[i]))


if __name__ == "__main__":
main()
6 changes: 4 additions & 2 deletions tools/checkstyle.sh
Original file line number Diff line number Diff line change
@@ -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
fi
14 changes: 8 additions & 6 deletions tools/release-checks.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -27,19 +29,19 @@ 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
# save local changes
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
Expand Down Expand Up @@ -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"
}

Expand Down
10 changes: 6 additions & 4 deletions tools/remove-unused-strings.sh
Original file line number Diff line number Diff line change
@@ -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" "|" \
Expand All @@ -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
9 changes: 5 additions & 4 deletions tools/update-translations.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 238aa4e

Please sign in to comment.