- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
+- godir: Go to the directory containing a file.
Look at the source to view more functions. The complete list is:
EOF
#
function chooseproduct()
{
- # Find the makefiles that must exist for a product.
- # Send stderr to /dev/null in case partner isn't present.
- local -a choices
- choices=(`/bin/ls build/target/board/*/BoardConfig.mk vendor/*/*/BoardConfig.mk 2> /dev/null`)
-
- local choice
- local -a prodlist
- for choice in ${choices[@]}
- do
- # The product name is the name of the directory containing
- # the makefile we found, above.
- prodlist=(${prodlist[@]} `dirname ${choice} | xargs basename`)
- done
-
- local index=1
- local p
- echo "Product choices are:"
- for p in ${prodlist[@]}
- do
- echo " $index. $p"
- let "index = $index + 1"
- done
-
-
if [ "x$TARGET_PRODUCT" != x ] ; then
default_value=$TARGET_PRODUCT
else
local ANSWER
while [ -z "$TARGET_PRODUCT" ]
do
- echo "You can also type the name of a product if you know it."
- echo -n "Which would you like? [$default_value] "
+ echo -n "Which product would you like? [$default_value] "
if [ -z "$1" ] ; then
read ANSWER
else
if [ -z "$ANSWER" ] ; then
export TARGET_PRODUCT=$default_value
- elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
- local poo=`echo -n $ANSWER`
- if [ $poo -le ${#prodlist[@]} ] ; then
- export TARGET_PRODUCT=${prodlist[$(($ANSWER-$_arrayoffset))]}
- else
- echo "** Bad product selection: $ANSWER"
- fi
else
if check_product $ANSWER
then
local MAKEFILE=
local ARGS=
local DIR TO_CHOP
- for DIR in $@ ; do
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ for DIR in $DIRS ; do
DIR=`echo $DIR | sed -e 's:/$::'`
if [ -f $DIR/Android.mk ]; then
TO_CHOP=`echo $T | wc -c | tr -d ' '`
fi
fi
done
- ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T files $ARGS
+ ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS files $ARGS
else
echo "Couldn't locate the top of the tree. Try setting TOP."
fi
return
fi
local prebuiltdir=$(getprebuilt)
- local KERNEL=$T/prebuilt/android-arm/vmlinux-qemu
+ local KERNEL=$T/prebuilt/android-arm/kernel/vmlinux-qemu
local TRACE=$1
if [ ! "$TRACE" ] ; then
return
fi
+ if [ ! -r "$KERNEL" ] ; then
+ echo "Error: cannot find kernel: '$KERNEL'"
+ return
+ fi
+
local BASETRACE=$(basename $TRACE)
if [ "$BASETRACE" = "$TRACE" ] ; then
TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
adb ${adbOptions} shell >/dev/null mkdir /data/misc
adb ${adbOptions} shell chmod 777 /data/misc
+ # send a SIGUSR1 to cause the hprof dump
echo "Poking $targetPid and waiting for data..."
adb ${adbOptions} shell kill -10 $targetPid
- echo "Press enter when logcat shows \"GC freed ## objects / ## bytes\""
+ echo "Press enter when logcat shows \"hprof: heap dump completed\""
echo -n "> "
read
local availFiles=( $(adb ${adbOptions} shell ls /data/misc | grep '^heap-dump' | sed -e 's/.*heap-dump-/heap-dump-/' | sort -r | tr '[:space:][:cntrl:]' ' ') )
- local devHeadFile=/data/misc/${availFiles[0]}
- local devTailFile=/data/misc/${availFiles[1]}
-
- local localHeadFile=/tmp/$$-hprof-head
- local localTailFile=/tmp/$$-hprof-tail
+ local devFile=/data/misc/${availFiles[0]}
+ local localFile=/tmp/$$-hprof
- echo "Retrieving file $devHeadFile..."
- adb ${adbOptions} pull $devHeadFile $localHeadFile
- echo "Retrieving file $devTailFile..."
- adb ${adbOptions} pull $devTailFile $localTailFile
+ echo "Retrieving file $devFile..."
+ adb ${adbOptions} pull $devFile $localFile
- local combinedFile=$outputFile
- if [ "$combinedFile" = "" ]; then
- combinedFile=/tmp/$$.hprof
- fi
-
- cat $localHeadFile $localTailFile >$combinedFile
- adb ${adbOptions} shell rm $devHeadFile
- adb ${adbOptions} shell rm $devTailFile
- rm $localHeadFile
- rm $localTailFile
+ adb ${adbOptions} shell rm $devFile
- echo "Running hat on $combinedFile"
+ echo "Running hat on $localFile"
echo "View the output by pointing your browser at http://localhost:7000/"
echo ""
- hat $combinedFile
+ hat $localFile
}
function getbugreports()
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
return
fi
- (cd "$T" && development/tools/runtest $@)
+ (cd "$T" && development/testrunner/runtest.py $@)
+}
+
+# TODO: Remove this some time after 1 June 2009
+function runtest_py()
+{
+ echo "runtest_py is obsolete; use runtest instead" >&2
+ return 1
+}
+
+function godir () {
+ if [[ -z "$1" ]]; then
+ echo "Usage: godir <regex>"
+ return
+ fi
+ if [[ ! -f $T/filelist ]]; then
+ echo -n "Creating index..."
+ (cd $T; find . -wholename ./out -prune -o -type f > filelist)
+ echo " Done"
+ echo ""
+ fi
+ local lines
+ lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
+ if [[ ${#lines[@]} = 0 ]]; then
+ echo "Not found"
+ return
+ fi
+ local pathname
+ local choice
+ if [[ ${#lines[@]} > 1 ]]; then
+ while [[ -z "$pathname" ]]; do
+ local index=1
+ local line
+ for line in ${lines[@]}; do
+ printf "%6s %s\n" "[$index]" $line
+ index=$(($index + 1))
+ done
+ echo
+ echo -n "Select one: "
+ unset choice
+ read choice
+ if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
+ echo "Invalid choice"
+ continue
+ fi
+ pathname=${lines[$(($choice-$_arrayoffset))]}
+ done
+ else
+ # even though zsh arrays are 1-based, $foo[0] is an alias for $foo[1]
+ pathname=${lines[0]}
+ fi
+ cd $T/$pathname
}
# determine whether arrays are zero-based (bash) or one-based (zsh)
unset _xarray
# Execute the contents of any vendorsetup.sh files we can find.
-for f in `/bin/ls vendor/*/vendorsetup.sh 2> /dev/null`
+for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh 2> /dev/null`
do
echo "including $f"
. $f