diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:19 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:19 -0800 |
commit | 95cf464c5a9f2bb7d6bf3a231862323dcbf854f8 (patch) | |
tree | 1d8570ed831feb1053a458a46138d9764dae0c9c /tools/findunused | |
parent | e943f2fd8e7623ba3ea12bb65294d30446db4174 (diff) | |
download | android_development-95cf464c5a9f2bb7d6bf3a231862323dcbf854f8.tar.gz android_development-95cf464c5a9f2bb7d6bf3a231862323dcbf854f8.tar.bz2 android_development-95cf464c5a9f2bb7d6bf3a231862323dcbf854f8.zip |
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'tools/findunused')
-rwxr-xr-x | tools/findunused/findunusedresources | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/findunused/findunusedresources b/tools/findunused/findunusedresources index 85e15b283..963e2f1e6 100755 --- a/tools/findunused/findunusedresources +++ b/tools/findunused/findunusedresources @@ -28,11 +28,21 @@ do if [ -d $app/res ] then appname=$(basename $app) + + # find the R.java file that contains all the generated resource identifiers rDotJava=$(find out/target/common/obj/APPS/${appname}_intermediates/ -name R.java) + + # Simplistically process the content of the file to get the names of all the constants, + # and try to find a reference to each constant. for i in $(cat $rDotJava | grep "\w*=0x\d*" | sed 's/ *public static final int //' | sed 's/=0x.*//') do - echo $i $(grep -Rw R\\..*\\.$i\\\|@style/$i\\\|@drawable/$i\\\|@anim/$i\\\|@color/$i\\\|@xml/$i\\\|@layout/$i\\\|@menu/$i\\\|@+id/$i\\\|@array/$i\\\|@string/$i $app | wc -l) + # Since periods in the names get translated to underscores in R.java, and you can actually + # refer to such constants from java by using an underscore instead of a period, we also + # replace all underscores with a pattern that will match periods and underscores. + p=$(echo $i | sed 's/_/[\\._]/g') + echo $i $(grep -Rw R\\..*\\.$i\\\|@style/$p\\\|@drawable/$p\\\|@anim/$p\\\|@color/$p\\\|@xml/$p\\\|@layout/$p\\\|@menu/$p\\\|@+id/$p\\\|@array/$p\\\|@string/$p $app | wc -l) done | grep " 0$" | { + # this block gets as its input a list of constants which no references were found, one per line if [ "$showall" == "yes" ] then echo $app |