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|armv5] [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, but not their dependencies.
9 - mmm: Builds all of the modules in the supplied directories, but not their dependencies.
10 - mma: Builds all of the modules in the current directory, and their dependencies.
11 - mmma: Builds all of the modules in the supplied directories, and their dependencies.
12 - cgrep: Greps on all local C/C++ files.
13 - ggrep: Greps on all local Gradle files.
14 - jgrep: Greps on all local Java files.
15 - resgrep: Greps on all local res/*.xml files.
16 - godir: Go to the directory containing a file.
18 Look at the source to view more functions. The complete list is:
23 for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
29 # Get the value of a build variable as an absolute path.
30 function get_abs_build_var()
34 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
37 (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
38 command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1)
41 # Get the exact value of a build variable.
42 function get_build_var()
46 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
49 (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
50 command make --no-print-directory -f build/core/config.mk dumpvar-$1)
53 # check to see if the supplied product is one we can build
54 function check_product()
58 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
61 CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
63 TARGET_BUILD_VARIANT= \
66 get_build_var TARGET_DEVICE > /dev/null
67 # hide successful answers, but allow the errors to show
70 VARIANT_CHOICES=(user userdebug eng)
72 # check to see if the supplied variant is valid
73 function check_variant()
75 for v in ${VARIANT_CHOICES[@]}
89 echo "Couldn't locate the top of the tree. Try setting TOP."
93 ##################################################################
95 # Read me before you modify this code #
97 # This function sets ANDROID_BUILD_PATHS to what it is adding #
98 # to PATH, and the next time it is run, it removes that from #
99 # PATH. This is required so lunch can be run more than once #
100 # and still have working paths. #
102 ##################################################################
104 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
105 # due to "C:\Program Files" being in the path.
108 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
109 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
111 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
112 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
113 # strip leading ':', if any
114 export PATH=${PATH/:%/}
117 # and in with the new
119 prebuiltdir=$(getprebuilt)
120 gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
122 # defined in core/config.mk
123 targetgccversion=$(get_build_var TARGET_GCC_VERSION)
124 export TARGET_GCC_VERSION=$targetgccversion
126 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
127 export ANDROID_EABI_TOOLCHAIN=
128 local ARCH=$(get_build_var TARGET_ARCH)
130 x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
132 x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
134 arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
136 arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin
138 mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
141 echo "Can't find toolchain for unknown architecture: $ARCH"
142 toolchaindir=xxxxxxxxx
145 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
146 export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
149 unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
152 toolchaindir=arm/arm-eabi-$targetgccversion/bin
153 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
154 export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
155 ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
158 mips) toolchaindir=mips/mips-eabi-4.4.3/bin
161 # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
165 export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
166 export ANDROID_QTOOLS=$T/development/emulator/qtools
167 export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools
168 export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN$ARM_EABI_TOOLCHAIN_PATH$CODE_REVIEWS:$ANDROID_DEV_SCRIPTS:
169 export PATH=$ANDROID_BUILD_PATHS$PATH
171 unset ANDROID_JAVA_TOOLCHAIN
172 unset ANDROID_PRE_BUILD_PATHS
173 if [ -n "$JAVA_HOME" ]; then
174 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
175 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
176 export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
179 unset ANDROID_PRODUCT_OUT
180 export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
181 export OUT=$ANDROID_PRODUCT_OUT
183 unset ANDROID_HOST_OUT
184 export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
186 # needed for processing samples collected by perf counters
187 unset OPROFILE_EVENTS_DIR
188 export OPROFILE_EVENTS_DIR=$T/external/oprofile/events
190 # needed for building linux on MacOS
192 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
195 function printconfig()
199 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
202 get_build_var report_config
205 function set_stuff_for_environment()
212 export ANDROID_BUILD_TOP=$(gettop)
213 # With this environment variable new GCC can apply colors to warnings/errors
214 export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
217 function set_sequence_number()
219 export BUILD_ENV_SEQUENCE_NUMBER=10
224 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
225 local arch=$(gettargetarch)
226 local product=$TARGET_PRODUCT
227 local variant=$TARGET_BUILD_VARIANT
228 local apps=$TARGET_BUILD_APPS
229 if [ -z "$apps" ]; then
230 export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
232 export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
237 function addcompletions()
241 # Keep us from trying to run in something that isn't bash.
242 if [ -z "${BASH_VERSION}" ]; then
246 # Keep us from trying to run in bash that's too old.
247 if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
251 dir="sdk/bash_completion"
252 if [ -d ${dir} ]; then
253 for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
260 function choosetype()
262 echo "Build type choices are:"
267 local DEFAULT_NUM DEFAULT_VALUE
269 DEFAULT_VALUE=release
271 export TARGET_BUILD_TYPE=
273 while [ -z $TARGET_BUILD_TYPE ]
275 echo -n "Which would you like? ["$DEFAULT_NUM"] "
276 if [ -z "$1" ] ; then
284 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
287 export TARGET_BUILD_TYPE=release
290 export TARGET_BUILD_TYPE=release
293 export TARGET_BUILD_TYPE=debug
296 export TARGET_BUILD_TYPE=debug
300 echo "I didn't understand your response. Please try again."
304 if [ -n "$1" ] ; then
309 set_stuff_for_environment
313 # This function isn't really right: It chooses a TARGET_PRODUCT
314 # based on the list of boards. Usually, that gets you something
315 # that kinda works with a generic product, but really, you should
316 # pick a product by name.
318 function chooseproduct()
320 if [ "x$TARGET_PRODUCT" != x ] ; then
321 default_value=$TARGET_PRODUCT
326 export TARGET_PRODUCT=
328 while [ -z "$TARGET_PRODUCT" ]
330 echo -n "Which product would you like? [$default_value] "
331 if [ -z "$1" ] ; then
338 if [ -z "$ANSWER" ] ; then
339 export TARGET_PRODUCT=$default_value
341 if check_product $ANSWER
343 export TARGET_PRODUCT=$ANSWER
345 echo "** Not a valid product: $ANSWER"
348 if [ -n "$1" ] ; then
353 set_stuff_for_environment
356 function choosevariant()
358 echo "Variant choices are:"
361 for v in ${VARIANT_CHOICES[@]}
363 # The product name is the name of the directory containing
364 # the makefile we found, above.
369 local default_value=eng
372 export TARGET_BUILD_VARIANT=
373 while [ -z "$TARGET_BUILD_VARIANT" ]
375 echo -n "Which would you like? [$default_value] "
376 if [ -z "$1" ] ; then
383 if [ -z "$ANSWER" ] ; then
384 export TARGET_BUILD_VARIANT=$default_value
385 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
386 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
387 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
390 if check_variant $ANSWER
392 export TARGET_BUILD_VARIANT=$ANSWER
394 echo "** Not a valid variant: $ANSWER"
397 if [ -n "$1" ] ; then
403 function choosecombo()
416 set_stuff_for_environment
420 # Clear this variable. It will be built up again when the vendorsetup.sh
421 # files are included at the end of this file.
422 unset LUNCH_MENU_CHOICES
423 function add_lunch_combo()
427 for c in ${LUNCH_MENU_CHOICES[@]} ; do
428 if [ "$new_combo" = "$c" ] ; then
432 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
435 # add the default one here
436 add_lunch_combo aosp_arm-eng
437 add_lunch_combo aosp_x86-eng
438 add_lunch_combo aosp_mips-eng
439 add_lunch_combo aosp_x86_64-eng
440 add_lunch_combo aosp_arm64-eng
441 add_lunch_combo vbox_x86-eng
443 function print_lunch_menu()
447 echo "You're building on" $uname
449 echo "Lunch menu... pick a combo:"
453 for choice in ${LUNCH_MENU_CHOICES[@]}
470 echo -n "Which would you like? [aosp_arm-eng] "
478 selection=aosp_arm-eng
479 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
481 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
483 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
485 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
490 if [ -z "$selection" ]
493 echo "Invalid lunch combo: $answer"
497 export TARGET_BUILD_APPS=
499 local product=$(echo -n $selection | sed -e "s/-.*$//")
500 check_product $product
504 echo "** Don't have a product spec for: '$product'"
505 echo "** Do you have the right repo manifest?"
509 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
510 check_variant $variant
514 echo "** Invalid variant: '$variant'"
515 echo "** Must be one of ${VARIANT_CHOICES[@]}"
519 if [ -z "$product" -o -z "$variant" ]
525 export TARGET_PRODUCT=$product
526 export TARGET_BUILD_VARIANT=$variant
527 export TARGET_BUILD_TYPE=release
531 set_stuff_for_environment
535 # Tab completion for lunch.
540 cur="${COMP_WORDS[COMP_CWORD]}"
541 prev="${COMP_WORDS[COMP_CWORD-1]}"
543 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
546 complete -F _lunch lunch
548 # Configures the build to build unbundled apps.
549 # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
552 local arch=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5)$'))
553 local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$'))
554 local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5)$'))
556 if [ $(echo $arch | wc -w) -gt 1 ]; then
557 echo "tapas: Error: Multiple build archs supplied: $arch"
560 if [ $(echo $variant | wc -w) -gt 1 ]; then
561 echo "tapas: Error: Multiple build variants supplied: $variant"
567 x86) product=full_x86;;
568 mips) product=full_mips;;
569 armv5) product=generic_armv5;;
571 if [ -z "$variant" ]; then
574 if [ -z "$apps" ]; then
578 export TARGET_PRODUCT=$product
579 export TARGET_BUILD_VARIANT=$variant
580 export TARGET_BUILD_TYPE=release
581 export TARGET_BUILD_APPS=$apps
583 set_stuff_for_environment
589 local TOPFILE=build/core/envsetup.mk
590 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
593 if [ -f $TOPFILE ] ; then
594 # The following circumlocution (repeated below as well) ensures
595 # that we record the true directory name and not one that is
596 # faked up with symlink names.
601 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
606 if [ -f "$T/$TOPFILE" ]; then
613 # Return driver for "make", if any (eg. static analyzer)
617 test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
618 if [ -n "$WITH_STATIC_ANALYZER" ]; then
620 $T/prebuilts/clang/linux-x86/host/3.3/tools/scan-build/scan-build \
621 --use-analyzer $T/prebuilts/clang/linux-x86/host/3.3/bin/analyzer \
630 local DRV=$(getdriver $T)
632 $DRV make -C $T -f build/core/main.mk $@
634 echo "Couldn't locate the top of the tree. Try setting TOP."
638 function findmakefile()
640 TOPFILE=build/core/envsetup.mk
643 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
645 if [ -f "$T/Android.mk" ]; then
658 local DRV=$(getdriver $T)
659 # If we're sitting in the root of the build tree, just do a
661 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
664 # Find the closest Android.mk file.
665 local M=$(findmakefile)
667 local GET_INSTALL_PATH=
669 # Remove the path to top as the makefilepath needs to be relative
670 local M=`echo $M|sed 's:'$T'/::'`
672 echo "Couldn't locate the top of the tree. Try setting TOP."
673 elif [ ! "$M" ]; then
674 echo "Couldn't locate a makefile from the current directory."
678 GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
681 if [ -n "$GET_INSTALL_PATH" ]; then
683 ARGS=GET-INSTALL-PATH
688 ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
696 local DRV=$(getdriver $T)
702 local GET_INSTALL_PATH=
703 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
704 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
705 for DIR in $DIRS ; do
706 MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
707 if [ "$MODULES" = "" ]; then
710 DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
711 if [ -f $DIR/Android.mk ]; then
712 local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
713 local TO_CHOP=`expr $TO_CHOP + 1`
714 local START=`PWD= /bin/pwd`
715 local MFILE=`echo $START | cut -c${TO_CHOP}-`
716 if [ "$MFILE" = "" ] ; then
717 MFILE=$DIR/Android.mk
719 MFILE=$MFILE/$DIR/Android.mk
721 MAKEFILE="$MAKEFILE $MFILE"
724 showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";;
725 GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
726 *) echo "No Android.mk in $DIR."; return 1;;
730 if [ -n "$GET_INSTALL_PATH" ]; then
731 ARGS=$GET_INSTALL_PATH
734 ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
736 echo "Couldn't locate the top of the tree. Try setting TOP."
743 local DRV=$(getdriver $T)
744 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
748 echo "Couldn't locate the top of the tree. Try setting TOP."
750 local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
751 $DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD"
758 local DRV=$(getdriver $T)
760 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
761 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
762 local MY_PWD=`PWD= /bin/pwd`
763 if [ "$MY_PWD" = "$T" ]; then
766 MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'`
771 for DIR in $DIRS ; do
773 if [ "$MY_PWD" = "" ]; then
774 MODULE_PATHS="$MODULE_PATHS $DIR"
776 MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR"
780 showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";;
781 *) echo "Couldn't find directory $DIR"; return 1;;
785 $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS"
787 echo "Couldn't locate the top of the tree. Try setting TOP."
797 echo "Couldn't locate the top of the tree. Try setting TOP."
803 TOPFILE=build/core/envsetup.mk
806 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
808 if [ -f "$T/Android.mk" ]; then
815 echo "can't find Android.mk"
818 # simplified version of ps; output in the form
823 if [ "$1" = "--exact" ]; then
827 elif [ "$1" = "--help" -o "$1" = "-h" ]; then
828 echo "usage: qpid [[--exact] <process name|pid>"
834 qpid | \grep "$prepend$EXE$append"
838 | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
846 if [ "$1" = "--exact" ]; then
853 local PID=`adb shell ps \
855 | \grep "$prepend$EXE$append" \
856 | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
859 echo "usage: pid [--exact] <process name>"
864 # systemstack - dump the current stack trace of all threads in the system process
865 # to the usual ANR traces file
866 function systemstack()
873 if [[ $1 =~ ^[0-9]+$ ]] ; then
876 local PIDLIST="$(pid $1)"
877 if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
879 elif [ "$PIDLIST" ] ; then
880 echo "more than one process: $1"
882 echo "no such process: $1"
885 echo "usage: stacks [pid|process name]"
889 # Determine whether the process is native
890 if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
891 # Dump stacks of Dalvik process
892 local TRACES=/data/anr/traces.txt
893 local ORIG=/data/anr/traces.orig
894 local TMP=/data/anr/traces.tmp
896 # Keep original traces to avoid clobbering
897 adb shell mv $TRACES $ORIG
899 # Make sure we have a usable file
900 adb shell touch $TRACES
901 adb shell chmod 666 $TRACES
903 # Dump stacks and wait for dump to finish
904 adb shell kill -3 $PID
905 adb shell notify $TRACES >/dev/null
907 # Restore original stacks, and show current output
908 adb shell mv $TRACES $TMP
909 adb shell mv $ORIG $TRACES
912 # Dump stacks of native process
913 adb shell debuggerd -b $PID
918 function gdbwrapper()
920 $ANDROID_TOOLCHAIN/$GDB -x "$@"
925 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
926 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
927 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
928 local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
929 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
930 local ARCH=$(get_build_var TARGET_ARCH)
933 x86) GDB=x86_64-linux-android-gdb;;
934 arm) GDB=arm-linux-androideabi-gdb;;
935 mips) GDB=mipsel-linux-android-gdb;;
936 *) echo "Unknown arch $ARCH"; return 1;;
939 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
948 if [ "$PORT" ] ; then
956 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
958 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
959 # that likely didn't work because of returning multiple processes
960 # try again, filtering by root processes (don't contain colon)
961 PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'`
962 if [[ ! "$PID" =~ ^[0-9]+$ ]]
964 echo "Couldn't resolve '$3' to single PID"
968 echo "WARNING: multiple processes matching '$3' observed, using root process"
973 adb forward "tcp$PORT" "tcp$PORT"
974 adb shell gdbserver $PORT --attach $PID &
978 echo "If you haven't done so already, do this first on the device:"
979 echo " gdbserver $PORT /system/bin/$EXE"
981 echo " gdbserver $PORT --attach <PID>"
985 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
986 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"
987 echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb"
988 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
989 echo >>"$OUT_ROOT/gdbclient.cmds" ""
991 gdbwrapper "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
993 echo "Unable to determine build system output dir."
1002 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 "$@"
1009 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 "$@"
1014 function gettargetarch
1016 get_build_var TARGET_ARCH
1021 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" -print0 | xargs -0 grep --color -n "$@"
1026 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
1031 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
1036 for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
1041 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
1046 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@"
1053 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 "$@"
1058 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 "$@"
1065 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 "$@"
1070 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 "$@"
1076 function getprebuilt
1078 get_abs_build_var ANDROID_PREBUILTS
1081 function tracedmdump()
1085 echo "Couldn't locate the top of the tree. Try setting TOP."
1088 local prebuiltdir=$(getprebuilt)
1089 local arch=$(gettargetarch)
1090 local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
1093 if [ ! "$TRACE" ] ; then
1094 echo "usage: tracedmdump tracename"
1098 if [ ! -r "$KERNEL" ] ; then
1099 echo "Error: cannot find kernel: '$KERNEL'"
1103 local BASETRACE=$(basename $TRACE)
1104 if [ "$BASETRACE" = "$TRACE" ] ; then
1105 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
1108 echo "post-processing traces..."
1109 rm -f $TRACE/qtrace.dexlist
1111 if [ $? -ne 0 ]; then
1113 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
1117 echo "generating dexlist output..."
1118 /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
1119 echo "generating dmtrace data..."
1120 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
1121 echo "generating html file..."
1122 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
1123 echo "done, see $TRACE/dmtrace.html for details"
1125 echo " traceview $TRACE/dmtrace"
1128 # communicate with a running device or emulator, set up necessary state,
1129 # and run the hat command.
1132 # process standard adb options
1134 if [ "$1" = "-d" -o "$1" = "-e" ]; then
1137 elif [ "$1" = "-s" ]; then
1141 local adbOptions=${adbTarget}
1142 #echo adbOptions = ${adbOptions}
1147 if [ "$targetPid" = "" ]; then
1148 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
1152 # confirm hat is available
1153 if [ -z $(which hat) ]; then
1154 echo "hat is not available in this configuration."
1158 # issue "am" command to cause the hprof dump
1159 local sdcard=$(adb ${adbOptions} shell echo -n '$EXTERNAL_STORAGE')
1160 local devFile=$sdcard/hprof-$targetPid
1161 #local devFile=/data/local/hprof-$targetPid
1162 echo "Poking $targetPid and waiting for data..."
1163 echo "Storing data at $devFile"
1164 adb ${adbOptions} shell am dumpheap $targetPid $devFile
1165 echo "Press enter when logcat shows \"hprof: heap dump completed\""
1169 local localFile=/tmp/$$-hprof
1171 echo "Retrieving file $devFile..."
1172 adb ${adbOptions} pull $devFile $localFile
1174 adb ${adbOptions} shell rm $devFile
1176 echo "Running hat on $localFile"
1177 echo "View the output by pointing your browser at http://localhost:7000/"
1179 hat -JXmx512m $localFile
1182 function getbugreports()
1184 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
1186 if [ ! "$reports" ]; then
1187 echo "Could not locate any bugreports."
1192 for report in ${reports[@]}
1194 echo "/sdcard/bugreports/${report}"
1195 adb pull /sdcard/bugreports/${report} ${report}
1200 function getsdcardpath()
1202 adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
1205 function getscreenshotpath()
1207 echo "$(getsdcardpath)/Pictures/Screenshots"
1210 function getlastscreenshot()
1212 local screenshot_path=$(getscreenshotpath)
1213 local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
1214 if [ "$screenshot" = "" ]; then
1215 echo "No screenshots found."
1218 echo "${screenshot}"
1219 adb ${adbOptions} pull ${screenshot_path}/${screenshot}
1222 function startviewserver()
1225 if [ $# -gt 0 ]; then
1228 adb shell service call window 1 i32 $port
1231 function stopviewserver()
1233 adb shell service call window 2
1236 function isviewserverstarted()
1238 adb shell service call window 3
1243 adb shell input keyevent 3
1248 adb shell input keyevent 4
1253 adb shell input keyevent 82
1256 function smoketest()
1258 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
1259 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1264 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1268 (\cd "$T" && mmm tests/SmokeTest) &&
1269 adb uninstall com.android.smoketest > /dev/null &&
1270 adb uninstall com.android.smoketest.tests > /dev/null &&
1271 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1272 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1273 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1276 # simple shortcut to the runtest command
1281 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1284 ("$T"/development/testrunner/runtest.py $@)
1288 if [[ -z "$1" ]]; then
1289 echo "Usage: godir <regex>"
1293 if [[ ! -f $T/filelist ]]; then
1294 echo -n "Creating index..."
1295 (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
1300 lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
1301 if [[ ${#lines[@]} = 0 ]]; then
1307 if [[ ${#lines[@]} > 1 ]]; then
1308 while [[ -z "$pathname" ]]; do
1311 for line in ${lines[@]}; do
1312 printf "%6s %s\n" "[$index]" $line
1313 index=$(($index + 1))
1316 echo -n "Select one: "
1319 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1320 echo "Invalid choice"
1323 pathname=${lines[$(($choice-1))]}
1326 pathname=${lines[0]}
1331 # Force JAVA_HOME to point to java 1.7 or java 1.6 if it isn't already set.
1333 # Note that the MacOS path for java 1.7 includes a minor revision number (sigh).
1334 # For some reason, installing the JDK doesn't make it show up in the
1335 # JavaVM.framework/Versions/1.7/ folder.
1336 function set_java_home() {
1337 # Clear the existing JAVA_HOME value if we set it ourselves, so that
1338 # we can reset it later, depending on the value of EXPERIMENTAL_USE_JAVA7.
1340 # If we don't do this, the JAVA_HOME value set by the first call to
1341 # build/envsetup.sh will persist forever.
1342 if [ -n "$ANDROID_SET_JAVA_HOME" ]; then
1346 if [ ! "$JAVA_HOME" ]; then
1347 if [ ! "$EXPERIMENTAL_USE_JAVA7" ]; then
1350 export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
1353 export JAVA_HOME=/usr/lib/jvm/java-6-sun
1359 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
1362 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
1367 # Keep track of the fact that we set JAVA_HOME ourselves, so that
1368 # we can change it on the next envsetup.sh, if required.
1369 export ANDROID_SET_JAVA_HOME=true
1373 # Print colored exit condition
1377 if [ $retval -ne 0 ]
1379 echo -e "\e[0;31mFAILURE\e[00m"
1381 echo -e "\e[0;32mSUCCESS\e[00m"
1388 local start_time=$(date +"%s")
1391 local end_time=$(date +"%s")
1392 local tdiff=$(($end_time-$start_time))
1393 local hours=$(($tdiff / 3600 ))
1394 local mins=$((($tdiff % 3600) / 60))
1395 local secs=$(($tdiff % 60))
1397 if [ $ret -eq 0 ] ; then
1398 echo -n -e "#### make completed successfully "
1400 echo -n -e "#### make failed to build some targets "
1402 if [ $hours -gt 0 ] ; then
1403 printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
1404 elif [ $mins -gt 0 ] ; then
1405 printf "(%02g:%02g (mm:ss))" $mins $secs
1406 elif [ $secs -gt 0 ] ; then
1407 printf "(%s seconds)" $secs
1414 if [ "x$SHELL" != "x/bin/bash" ]; then
1415 case `ps -o command -p $$` in
1419 echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
1424 # Execute the contents of any vendorsetup.sh files we can find.
1425 for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
1426 `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`