3 Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
4 - lunch: lunch <product_name>-<build_variant>
5 - tapas: tapas [<App1> <App2> ...] [arm|x86|mips] [eng|userdebug|user]
6 - croot: Changes directory to the top of the tree.
7 - m: Makes from the top of the tree.
8 - mm: Builds all of the modules in the current directory.
9 - mmm: Builds all of the modules in the supplied directories.
10 - cgrep: Greps on all local C/C++ files.
11 - jgrep: Greps on all local Java files.
12 - resgrep: Greps on all local res/*.xml files.
13 - godir: Go to the directory containing a file.
15 Look at the source to view more functions. The complete list is:
20 for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
26 # Get the value of a build variable as an absolute path.
27 function get_abs_build_var()
31 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
34 (cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
35 make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1)
38 # Get the exact value of a build variable.
39 function get_build_var()
43 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
46 CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
47 make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-$1
50 # check to see if the supplied product is one we can build
51 function check_product()
55 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
58 CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
60 TARGET_BUILD_VARIANT= \
63 get_build_var TARGET_DEVICE > /dev/null
64 # hide successful answers, but allow the errors to show
67 VARIANT_CHOICES=(user userdebug eng)
69 # check to see if the supplied variant is valid
70 function check_variant()
72 for v in ${VARIANT_CHOICES[@]}
86 echo "Couldn't locate the top of the tree. Try setting TOP."
90 ##################################################################
92 # Read me before you modify this code #
94 # This function sets ANDROID_BUILD_PATHS to what it is adding #
95 # to PATH, and the next time it is run, it removes that from #
96 # PATH. This is required so lunch can be run more than once #
97 # and still have working paths. #
99 ##################################################################
101 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
102 # due to "C:\Program Files" being in the path.
105 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
106 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
108 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
109 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
110 # strip trailing ':', if any
111 export PATH=${PATH/%:/}
114 # and in with the new
116 prebuiltdir=$(getprebuilt)
117 gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
119 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
120 export ANDROID_EABI_TOOLCHAIN=
121 local ARCH=$(get_build_var TARGET_ARCH)
123 x86) toolchaindir=x86/i686-linux-android-4.6/bin
125 arm) toolchaindir=arm/arm-linux-androideabi-4.6/bin
127 mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
130 echo "Can't find toolchain for unknown architecture: $ARCH"
131 toolchaindir=xxxxxxxxx
134 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
135 export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
138 unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
141 toolchaindir=arm/arm-eabi-4.6/bin
142 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
143 export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
144 ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
147 mips) toolchaindir=mips/mips-eabi-4.4.3/bin
150 # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
154 export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
155 export ANDROID_QTOOLS=$T/development/emulator/qtools
156 export ANDROID_DEV_SCRIPTS=$T/development/scripts
157 export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN$ARM_EABI_TOOLCHAIN_PATH$CODE_REVIEWS:$ANDROID_DEV_SCRIPTS
158 export PATH=$PATH$ANDROID_BUILD_PATHS
160 unset ANDROID_JAVA_TOOLCHAIN
161 unset ANDROID_PRE_BUILD_PATHS
162 if [ -n "$JAVA_HOME" ]; then
163 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
164 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
165 export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
168 unset ANDROID_PRODUCT_OUT
169 export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
170 export OUT=$ANDROID_PRODUCT_OUT
172 unset ANDROID_HOST_OUT
173 export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
175 # needed for processing samples collected by perf counters
176 unset OPROFILE_EVENTS_DIR
177 export OPROFILE_EVENTS_DIR=$T/external/oprofile/events
179 # needed for building linux on MacOS
181 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
184 function printconfig()
188 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
191 get_build_var report_config
194 function set_stuff_for_environment()
201 export ANDROID_BUILD_TOP=$(gettop)
204 function set_sequence_number()
206 export BUILD_ENV_SEQUENCE_NUMBER=10
211 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
212 local arch=$(gettargetarch)
213 local product=$TARGET_PRODUCT
214 local variant=$TARGET_BUILD_VARIANT
215 local apps=$TARGET_BUILD_APPS
216 if [ -z "$apps" ]; then
217 export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
219 export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
224 function addcompletions()
228 # Keep us from trying to run in something that isn't bash.
229 if [ -z "${BASH_VERSION}" ]; then
233 # Keep us from trying to run in bash that's too old.
234 if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
238 dir="sdk/bash_completion"
239 if [ -d ${dir} ]; then
240 for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
247 function choosetype()
249 echo "Build type choices are:"
254 local DEFAULT_NUM DEFAULT_VALUE
256 DEFAULT_VALUE=release
258 export TARGET_BUILD_TYPE=
260 while [ -z $TARGET_BUILD_TYPE ]
262 echo -n "Which would you like? ["$DEFAULT_NUM"] "
263 if [ -z "$1" ] ; then
271 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
274 export TARGET_BUILD_TYPE=release
277 export TARGET_BUILD_TYPE=release
280 export TARGET_BUILD_TYPE=debug
283 export TARGET_BUILD_TYPE=debug
287 echo "I didn't understand your response. Please try again."
291 if [ -n "$1" ] ; then
296 set_stuff_for_environment
300 # This function isn't really right: It chooses a TARGET_PRODUCT
301 # based on the list of boards. Usually, that gets you something
302 # that kinda works with a generic product, but really, you should
303 # pick a product by name.
305 function chooseproduct()
307 if [ "x$TARGET_PRODUCT" != x ] ; then
308 default_value=$TARGET_PRODUCT
313 export TARGET_PRODUCT=
315 while [ -z "$TARGET_PRODUCT" ]
317 echo -n "Which product would you like? [$default_value] "
318 if [ -z "$1" ] ; then
325 if [ -z "$ANSWER" ] ; then
326 export TARGET_PRODUCT=$default_value
328 if check_product $ANSWER
330 export TARGET_PRODUCT=$ANSWER
332 echo "** Not a valid product: $ANSWER"
335 if [ -n "$1" ] ; then
340 set_stuff_for_environment
343 function choosevariant()
345 echo "Variant choices are:"
348 for v in ${VARIANT_CHOICES[@]}
350 # The product name is the name of the directory containing
351 # the makefile we found, above.
356 local default_value=eng
359 export TARGET_BUILD_VARIANT=
360 while [ -z "$TARGET_BUILD_VARIANT" ]
362 echo -n "Which would you like? [$default_value] "
363 if [ -z "$1" ] ; then
370 if [ -z "$ANSWER" ] ; then
371 export TARGET_BUILD_VARIANT=$default_value
372 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
373 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
374 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
377 if check_variant $ANSWER
379 export TARGET_BUILD_VARIANT=$ANSWER
381 echo "** Not a valid variant: $ANSWER"
384 if [ -n "$1" ] ; then
390 function choosecombo()
403 set_stuff_for_environment
407 # Clear this variable. It will be built up again when the vendorsetup.sh
408 # files are included at the end of this file.
409 unset LUNCH_MENU_CHOICES
410 function add_lunch_combo()
414 for c in ${LUNCH_MENU_CHOICES[@]} ; do
415 if [ "$new_combo" = "$c" ] ; then
419 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
422 # add the default one here
423 add_lunch_combo full-eng
424 add_lunch_combo full_x86-eng
425 add_lunch_combo vbox_x86-eng
426 add_lunch_combo full_mips-eng
428 function print_lunch_menu()
432 echo "You're building on" $uname
434 echo "Lunch menu... pick a combo:"
438 for choice in ${LUNCH_MENU_CHOICES[@]}
455 echo -n "Which would you like? [full-eng] "
464 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
466 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
468 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
470 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
475 if [ -z "$selection" ]
478 echo "Invalid lunch combo: $answer"
482 export TARGET_BUILD_APPS=
484 local product=$(echo -n $selection | sed -e "s/-.*$//")
485 check_product $product
489 echo "** Don't have a product spec for: '$product'"
490 echo "** Do you have the right repo manifest?"
494 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
495 check_variant $variant
499 echo "** Invalid variant: '$variant'"
500 echo "** Must be one of ${VARIANT_CHOICES[@]}"
504 if [ -z "$product" -o -z "$variant" ]
510 export TARGET_PRODUCT=$product
511 export TARGET_BUILD_VARIANT=$variant
512 export TARGET_BUILD_TYPE=release
516 set_stuff_for_environment
520 # Tab completion for lunch.
525 cur="${COMP_WORDS[COMP_CWORD]}"
526 prev="${COMP_WORDS[COMP_CWORD-1]}"
528 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
531 complete -F _lunch lunch
533 # Configures the build to build unbundled apps.
534 # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
537 local arch=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips)$'))
538 local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$'))
539 local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips)$'))
541 if [ $(echo $arch | wc -w) -gt 1 ]; then
542 echo "tapas: Error: Multiple build archs supplied: $arch"
545 if [ $(echo $variant | wc -w) -gt 1 ]; then
546 echo "tapas: Error: Multiple build variants supplied: $variant"
552 x86) product=full_x86;;
553 mips) product=full_mips;;
555 if [ -z "$variant" ]; then
558 if [ -z "$apps" ]; then
562 export TARGET_PRODUCT=$product
563 export TARGET_BUILD_VARIANT=$variant
564 export TARGET_BUILD_TYPE=release
565 export TARGET_BUILD_APPS=$apps
567 set_stuff_for_environment
573 local TOPFILE=build/core/envsetup.mk
574 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
577 if [ -f $TOPFILE ] ; then
578 # The following circumlocution (repeated below as well) ensures
579 # that we record the true directory name and not one that is
580 # faked up with symlink names.
583 # We redirect cd to /dev/null in case it's aliased to
584 # a command that prints something as a side-effect
588 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
593 if [ -f "$T/$TOPFILE" ]; then
606 echo "Couldn't locate the top of the tree. Try setting TOP."
610 function findmakefile()
612 TOPFILE=build/core/envsetup.mk
613 # We redirect cd to /dev/null in case it's aliased to
614 # a command that prints something as a side-effect
618 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
620 if [ -f "$T/Android.mk" ]; then
632 # If we're sitting in the root of the build tree, just do a
634 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
637 # Find the closest Android.mk file.
639 local M=$(findmakefile)
640 # Remove the path to top as the makefilepath needs to be relative
641 local M=`echo $M|sed 's:'$T'/::'`
643 echo "Couldn't locate the top of the tree. Try setting TOP."
644 elif [ ! "$M" ]; then
645 echo "Couldn't locate a makefile from the current directory."
647 ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@
660 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
661 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
662 for DIR in $DIRS ; do
663 MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
664 if [ "$MODULES" = "" ]; then
667 DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
668 if [ -f $DIR/Android.mk ]; then
669 TO_CHOP=`(cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
670 TO_CHOP=`expr $TO_CHOP + 1`
671 START=`PWD= /bin/pwd`
672 MFILE=`echo $START | cut -c${TO_CHOP}-`
673 if [ "$MFILE" = "" ] ; then
674 MFILE=$DIR/Android.mk
676 MFILE=$MFILE/$DIR/Android.mk
678 MAKEFILE="$MAKEFILE $MFILE"
680 if [ "$DIR" = snod ]; then
682 elif [ "$DIR" = showcommands ]; then
683 ARGS="$ARGS showcommands"
684 elif [ "$DIR" = dist ]; then
686 elif [ "$DIR" = incrementaljavac ]; then
687 ARGS="$ARGS incrementaljavac"
689 echo "No Android.mk in $DIR."
694 ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS $MODULES $ARGS
696 echo "Couldn't locate the top of the tree. Try setting TOP."
706 echo "Couldn't locate the top of the tree. Try setting TOP."
712 TOPFILE=build/core/envsetup.mk
713 # We redirect cd to /dev/null in case it's aliased to
714 # a command that prints something as a side-effect
718 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
720 if [ -f "$T/Android.mk" ]; then
727 echo "can't find Android.mk"
734 local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
737 echo "usage: pid name"
741 # systemstack - dump the current stack trace of all threads in the system process
742 # to the usual ANR traces file
743 function systemstack()
745 adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server)
750 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
751 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
752 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
753 local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
754 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
755 local ARCH=$(get_build_var TARGET_ARCH)
758 x86) GDB=i686-linux-android-gdb;;
759 arm) GDB=arm-linux-androideabi-gdb;;
760 mips) GDB=mipsel-linux-android-gdb;;
761 *) echo "Unknown arch $ARCH"; return 1;;
764 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
773 if [ "$PORT" ] ; then
781 if [ "$PROG" ] ; then
782 if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
787 adb forward "tcp$PORT" "tcp$PORT"
788 adb shell gdbserver $PORT --attach $PID &
792 echo "If you haven't done so already, do this first on the device:"
793 echo " gdbserver $PORT /system/bin/$EXE"
795 echo " gdbserver $PORT --attach $PID"
799 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
800 echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx"
801 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
802 echo >>"$OUT_ROOT/gdbclient.cmds" ""
804 $ANDROID_TOOLCHAIN/$GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
806 echo "Unable to determine build system output dir."
815 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
822 find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
827 function gettargetarch
829 get_build_var TARGET_ARCH
834 find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
839 find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
844 for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
851 find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
856 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
863 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
868 find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
876 get_abs_build_var ANDROID_PREBUILTS
879 function tracedmdump()
883 echo "Couldn't locate the top of the tree. Try setting TOP."
886 local prebuiltdir=$(getprebuilt)
887 local arch=$(gettargetarch)
888 local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
891 if [ ! "$TRACE" ] ; then
892 echo "usage: tracedmdump tracename"
896 if [ ! -r "$KERNEL" ] ; then
897 echo "Error: cannot find kernel: '$KERNEL'"
901 local BASETRACE=$(basename $TRACE)
902 if [ "$BASETRACE" = "$TRACE" ] ; then
903 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
906 echo "post-processing traces..."
907 rm -f $TRACE/qtrace.dexlist
909 if [ $? -ne 0 ]; then
911 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
915 echo "generating dexlist output..."
916 /bin/ls $ANDROID_PRODUCT_OUT/system/framework/*.jar $ANDROID_PRODUCT_OUT/system/app/*.apk $ANDROID_PRODUCT_OUT/data/app/*.apk 2>/dev/null | xargs dexlist > $TRACE/qtrace.dexlist
917 echo "generating dmtrace data..."
918 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
919 echo "generating html file..."
920 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
921 echo "done, see $TRACE/dmtrace.html for details"
923 echo " traceview $TRACE/dmtrace"
926 # communicate with a running device or emulator, set up necessary state,
927 # and run the hat command.
930 # process standard adb options
932 if [ "$1" = "-d" -o "$1" = "-e" ]; then
935 elif [ "$1" = "-s" ]; then
939 local adbOptions=${adbTarget}
940 #echo adbOptions = ${adbOptions}
945 if [ "$targetPid" = "" ]; then
946 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
950 # confirm hat is available
951 if [ -z $(which hat) ]; then
952 echo "hat is not available in this configuration."
956 # issue "am" command to cause the hprof dump
957 local sdcard=$(adb shell echo -n '$EXTERNAL_STORAGE')
958 local devFile=$sdcard/hprof-$targetPid
959 #local devFile=/data/local/hprof-$targetPid
960 echo "Poking $targetPid and waiting for data..."
961 echo "Storing data at $devFile"
962 adb ${adbOptions} shell am dumpheap $targetPid $devFile
963 echo "Press enter when logcat shows \"hprof: heap dump completed\""
967 local localFile=/tmp/$$-hprof
969 echo "Retrieving file $devFile..."
970 adb ${adbOptions} pull $devFile $localFile
972 adb ${adbOptions} shell rm $devFile
974 echo "Running hat on $localFile"
975 echo "View the output by pointing your browser at http://localhost:7000/"
977 hat -JXmx512m $localFile
980 function getbugreports()
982 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
984 if [ ! "$reports" ]; then
985 echo "Could not locate any bugreports."
990 for report in ${reports[@]}
992 echo "/sdcard/bugreports/${report}"
993 adb pull /sdcard/bugreports/${report} ${report}
998 function getsdcardpath()
1000 adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
1003 function getscreenshotpath()
1005 echo "$(getsdcardpath)/Pictures/Screenshots"
1008 function getlastscreenshot()
1010 local screenshot_path=$(getscreenshotpath)
1011 local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
1012 if [ "$screenshot" = "" ]; then
1013 echo "No screenshots found."
1016 echo "${screenshot}"
1017 adb ${adbOptions} pull ${screenshot_path}/${screenshot}
1020 function startviewserver()
1023 if [ $# -gt 0 ]; then
1026 adb shell service call window 1 i32 $port
1029 function stopviewserver()
1031 adb shell service call window 2
1034 function isviewserverstarted()
1036 adb shell service call window 3
1041 adb shell input keyevent 3
1046 adb shell input keyevent 4
1051 adb shell input keyevent 82
1054 function smoketest()
1056 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
1057 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1062 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1066 (cd "$T" && mmm tests/SmokeTest) &&
1067 adb uninstall com.android.smoketest > /dev/null &&
1068 adb uninstall com.android.smoketest.tests > /dev/null &&
1069 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1070 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1071 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1074 # simple shortcut to the runtest command
1079 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1082 ("$T"/development/testrunner/runtest.py $@)
1086 if [[ -z "$1" ]]; then
1087 echo "Usage: godir <regex>"
1091 if [[ ! -f $T/filelist ]]; then
1092 echo -n "Creating index..."
1093 (cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
1098 lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
1099 if [[ ${#lines[@]} = 0 ]]; then
1105 if [[ ${#lines[@]} > 1 ]]; then
1106 while [[ -z "$pathname" ]]; do
1109 for line in ${lines[@]}; do
1110 printf "%6s %s\n" "[$index]" $line
1111 index=$(($index + 1))
1114 echo -n "Select one: "
1117 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1118 echo "Invalid choice"
1121 pathname=${lines[$(($choice-1))]}
1124 pathname=${lines[0]}
1129 # Force JAVA_HOME to point to java 1.6 if it isn't already set
1130 function set_java_home() {
1131 if [ ! "$JAVA_HOME" ]; then
1134 export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
1137 export JAVA_HOME=/usr/lib/jvm/java-6-sun
1143 if [ "x$SHELL" != "x/bin/bash" ]; then
1144 case `ps -o command -p $$` in
1148 echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
1153 # Execute the contents of any vendorsetup.sh files we can find.
1154 for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`