3 Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
4 - croot: Changes directory to the top of the tree.
5 - m: Makes from the top of the tree.
6 - mm: Builds all of the modules in the current directory.
7 - mmm: Builds all of the modules in the supplied directories.
8 - cgrep: Greps on all local C/C++ files.
9 - jgrep: Greps on all local Java files.
10 - resgrep: Greps on all local res/*.xml files.
11 - godir: Go to the directory containing a file.
13 Look at the source to view more functions. The complete list is:
18 for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
24 # Get the value of a build variable as an absolute path.
25 function get_abs_build_var()
29 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
32 (cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
33 make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1)
36 # Get the exact value of a build variable.
37 function get_build_var()
41 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
44 CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
45 make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-$1
48 # check to see if the supplied product is one we can build
49 function check_product()
53 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
56 CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
57 TARGET_PRODUCT=$1 TARGET_BUILD_VARIANT= \
58 TARGET_SIMULATOR= TARGET_BUILD_TYPE= \
60 get_build_var TARGET_DEVICE > /dev/null
61 # hide successful answers, but allow the errors to show
64 VARIANT_CHOICES=(user userdebug eng)
66 # check to see if the supplied variant is valid
67 function check_variant()
69 for v in ${VARIANT_CHOICES[@]}
83 echo "Couldn't locate the top of the tree. Try setting TOP."
87 ##################################################################
89 # Read me before you modify this code #
91 # This function sets ANDROID_BUILD_PATHS to what it is adding #
92 # to PATH, and the next time it is run, it removes that from #
93 # PATH. This is required so lunch can be run more than once #
94 # and still have working paths. #
96 ##################################################################
98 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
99 # due to "C:\Program Files" being in the path.
102 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
103 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
105 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
106 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
107 # strip trailing ':', if any
108 export PATH=${PATH/%:/}
111 # and in with the new
113 prebuiltdir=$(getprebuilt)
115 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
116 export ANDROID_EABI_TOOLCHAIN=
117 toolchaindir=toolchain/arm-linux-androideabi-4.4.x/bin
118 if [ -d "$prebuiltdir/$toolchaindir" ]; then
119 export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
122 export ARM_EABI_TOOLCHAIN=
123 toolchaindir=toolchain/arm-eabi-4.4.3/bin
124 if [ -d "$prebuiltdir/$toolchaindir" ]; then
125 export ARM_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
128 export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
129 export ANDROID_QTOOLS=$T/development/emulator/qtools
130 export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS
131 export PATH=$PATH$ANDROID_BUILD_PATHS
133 unset ANDROID_JAVA_TOOLCHAIN
134 if [ -n "$JAVA_HOME" ]; then
135 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
137 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN
138 if [ -n "$ANDROID_PRE_BUILD_PATHS" ]; then
139 export PATH=$ANDROID_PRE_BUILD_PATHS:$PATH
142 unset ANDROID_PRODUCT_OUT
143 export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
144 export OUT=$ANDROID_PRODUCT_OUT
146 unset ANDROID_HOST_OUT
147 export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
149 # needed for building linux on MacOS
151 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
154 function printconfig()
158 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
161 get_build_var report_config
164 function set_stuff_for_environment()
171 export ANDROID_BUILD_TOP=$(gettop)
174 function set_sequence_number()
176 export BUILD_ENV_SEQUENCE_NUMBER=10
181 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
182 local product=$TARGET_PRODUCT
183 local variant=$TARGET_BUILD_VARIANT
184 local apps=$TARGET_BUILD_APPS
185 if [ -z "$apps" ]; then
186 export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
188 export PROMPT_COMMAND="echo -ne \"\033]0;[$apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
197 echo "Build for the simulator or the device?"
202 export TARGET_SIMULATOR=
204 while [ -z $TARGET_SIMULATOR ]
206 echo -n "Which would you like? [1] "
207 if [ -z "$1" ] ; then
215 export TARGET_SIMULATOR=false
218 export TARGET_SIMULATOR=false
221 export TARGET_SIMULATOR=false
224 export TARGET_SIMULATOR=true
227 export TARGET_SIMULATOR=true
231 echo "I didn't understand your response. Please try again."
235 if [ -n "$1" ] ; then
240 set_stuff_for_environment
246 echo "Only device builds are supported for" `uname -s`
247 echo " Forcing TARGET_SIMULATOR=false"
251 echo -n "Press enter: "
255 export TARGET_SIMULATOR=false
256 set_stuff_for_environment
261 function choosetype()
263 echo "Build type choices are:"
268 local DEFAULT_NUM DEFAULT_VALUE
269 if [ $TARGET_SIMULATOR = "false" ] ; then
271 DEFAULT_VALUE=release
277 export TARGET_BUILD_TYPE=
279 while [ -z $TARGET_BUILD_TYPE ]
281 echo -n "Which would you like? ["$DEFAULT_NUM"] "
282 if [ -z "$1" ] ; then
290 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
293 export TARGET_BUILD_TYPE=release
296 export TARGET_BUILD_TYPE=release
299 export TARGET_BUILD_TYPE=debug
302 export TARGET_BUILD_TYPE=debug
306 echo "I didn't understand your response. Please try again."
310 if [ -n "$1" ] ; then
315 set_stuff_for_environment
319 # This function isn't really right: It chooses a TARGET_PRODUCT
320 # based on the list of boards. Usually, that gets you something
321 # that kinda works with a generic product, but really, you should
322 # pick a product by name.
324 function chooseproduct()
326 if [ "x$TARGET_PRODUCT" != x ] ; then
327 default_value=$TARGET_PRODUCT
329 if [ "$TARGET_SIMULATOR" = true ] ; then
336 export TARGET_PRODUCT=
338 while [ -z "$TARGET_PRODUCT" ]
340 echo -n "Which product would you like? [$default_value] "
341 if [ -z "$1" ] ; then
348 if [ -z "$ANSWER" ] ; then
349 export TARGET_PRODUCT=$default_value
351 if check_product $ANSWER
353 export TARGET_PRODUCT=$ANSWER
355 echo "** Not a valid product: $ANSWER"
358 if [ -n "$1" ] ; then
363 set_stuff_for_environment
366 function choosevariant()
368 echo "Variant choices are:"
371 for v in ${VARIANT_CHOICES[@]}
373 # The product name is the name of the directory containing
374 # the makefile we found, above.
379 local default_value=eng
382 export TARGET_BUILD_VARIANT=
383 while [ -z "$TARGET_BUILD_VARIANT" ]
385 echo -n "Which would you like? [$default_value] "
386 if [ -z "$1" ] ; then
393 if [ -z "$ANSWER" ] ; then
394 export TARGET_BUILD_VARIANT=$default_value
395 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
396 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
397 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
400 if check_variant $ANSWER
402 export TARGET_BUILD_VARIANT=$ANSWER
404 echo "** Not a valid variant: $ANSWER"
407 if [ -n "$1" ] ; then
413 function choosecombo()
430 set_stuff_for_environment
434 # Clear this variable. It will be built up again when the vendorsetup.sh
435 # files are included at the end of this file.
436 unset LUNCH_MENU_CHOICES
437 function add_lunch_combo()
441 for c in ${LUNCH_MENU_CHOICES[@]} ; do
442 if [ "$new_combo" = "$c" ] ; then
446 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
449 # add the default one here
450 add_lunch_combo full-eng
451 add_lunch_combo full_x86-eng
452 add_lunch_combo vbox_x86-eng
454 function print_lunch_menu()
458 echo "You're building on" $uname
460 echo "Lunch menu... pick a combo:"
464 for choice in ${LUNCH_MENU_CHOICES[@]}
481 echo -n "Which would you like? [full-eng] "
490 elif [ "$answer" = "simulator" ]
493 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
495 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
497 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
499 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
504 if [ -z "$selection" ]
507 echo "Invalid lunch combo: $answer"
511 export TARGET_BUILD_APPS=
513 # special case the simulator
514 if [ "$selection" = "simulator" ]
516 export TARGET_PRODUCT=sim
517 export TARGET_BUILD_VARIANT=eng
518 export TARGET_SIMULATOR=true
519 export TARGET_BUILD_TYPE=debug
521 local product=$(echo -n $selection | sed -e "s/-.*$//")
522 check_product $product
526 echo "** Don't have a product spec for: '$product'"
527 echo "** Do you have the right repo manifest?"
531 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
532 check_variant $variant
536 echo "** Invalid variant: '$variant'"
537 echo "** Must be one of ${VARIANT_CHOICES[@]}"
541 if [ -z "$product" -o -z "$variant" ]
547 export TARGET_PRODUCT=$product
548 export TARGET_BUILD_VARIANT=$variant
549 export TARGET_SIMULATOR=false
550 export TARGET_BUILD_TYPE=release
555 set_stuff_for_environment
559 # Tab completion for lunch.
564 cur="${COMP_WORDS[COMP_CWORD]}"
565 prev="${COMP_WORDS[COMP_CWORD-1]}"
567 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
570 complete -F _lunch lunch
572 # Configures the build to build unbundled apps.
573 # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
576 local variant=$(echo -n $(echo $* | xargs -n 1 echo | grep -E '^(user|userdebug|eng)$'))
577 local apps=$(echo -n $(echo $* | xargs -n 1 echo | grep -E -v '^(user|userdebug|eng)$'))
579 if [ $(echo $variant | wc -w) -gt 1 ]; then
580 echo "tapas: Error: Multiple build variants supplied: $variant"
583 if [ -z "$variant" ]; then
586 if [ -z "$apps" ]; then
590 export TARGET_PRODUCT=full
591 export TARGET_BUILD_VARIANT=$variant
592 export TARGET_SIMULATOR=false
593 export TARGET_BUILD_TYPE=release
594 export TARGET_BUILD_APPS=$apps
596 set_stuff_for_environment
602 local TOPFILE=build/core/envsetup.mk
603 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
606 if [ -f $TOPFILE ] ; then
607 # The following circumlocution (repeated below as well) ensures
608 # that we record the true directory name and not one that is
609 # faked up with symlink names.
612 # We redirect cd to /dev/null in case it's aliased to
613 # a command that prints something as a side-effect
617 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
622 if [ -f "$T/$TOPFILE" ]; then
635 echo "Couldn't locate the top of the tree. Try setting TOP."
639 function findmakefile()
641 TOPFILE=build/core/envsetup.mk
642 # We redirect cd to /dev/null in case it's aliased to
643 # a command that prints something as a side-effect
647 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
649 if [ -f "$T/Android.mk" ]; then
661 # If we're sitting in the root of the build tree, just do a
663 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
666 # Find the closest Android.mk file.
668 local M=$(findmakefile)
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."
676 ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@
688 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
689 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
690 for DIR in $DIRS ; do
691 DIR=`echo $DIR | sed -e 's:/$::'`
692 if [ -f $DIR/Android.mk ]; then
693 TO_CHOP=`(cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
694 TO_CHOP=`expr $TO_CHOP + 1`
695 START=`PWD= /bin/pwd`
696 MFILE=`echo $START | cut -c${TO_CHOP}-`
697 if [ "$MFILE" = "" ] ; then
698 MFILE=$DIR/Android.mk
700 MFILE=$MFILE/$DIR/Android.mk
702 MAKEFILE="$MAKEFILE $MFILE"
704 if [ "$DIR" = snod ]; then
706 elif [ "$DIR" = showcommands ]; then
707 ARGS="$ARGS showcommands"
708 elif [ "$DIR" = dist ]; then
710 elif [ "$DIR" = incrementaljavac ]; then
711 ARGS="$ARGS incrementaljavac"
713 echo "No Android.mk in $DIR."
718 ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS all_modules $ARGS
720 echo "Couldn't locate the top of the tree. Try setting TOP."
730 echo "Couldn't locate the top of the tree. Try setting TOP."
736 TOPFILE=build/core/envsetup.mk
737 # We redirect cd to /dev/null in case it's aliased to
738 # a command that prints something as a side-effect
742 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
744 if [ -f "$T/Android.mk" ]; then
751 echo "can't find Android.mk"
758 local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
761 echo "usage: pid name"
765 # systemstack - dump the current stack trace of all threads in the system process
766 # to the usual ANR traces file
767 function systemstack()
769 adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server)
774 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
775 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
776 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
777 local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
778 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
779 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
788 if [ "$PORT" ] ; then
796 if [ "$PROG" ] ; then
797 if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
802 adb forward "tcp$PORT" "tcp$PORT"
803 adb shell gdbserver $PORT --attach $PID &
807 echo "If you haven't done so already, do this first on the device:"
808 echo " gdbserver $PORT /system/bin/$EXE"
810 echo " gdbserver $PORT --attach $PID"
814 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
815 echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS"
816 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
817 echo >>"$OUT_ROOT/gdbclient.cmds" ""
819 arm-linux-androideabi-gdb -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
821 echo "Unable to determine build system output dir."
830 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 "$@"
837 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 "$@"
844 find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
849 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 "$@"
854 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;
861 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
866 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 "$@"
873 find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
878 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 "$@"
886 get_abs_build_var ANDROID_PREBUILTS
889 function tracedmdump()
893 echo "Couldn't locate the top of the tree. Try setting TOP."
896 local prebuiltdir=$(getprebuilt)
897 local KERNEL=$T/prebuilt/android-arm/kernel/vmlinux-qemu
900 if [ ! "$TRACE" ] ; then
901 echo "usage: tracedmdump tracename"
905 if [ ! -r "$KERNEL" ] ; then
906 echo "Error: cannot find kernel: '$KERNEL'"
910 local BASETRACE=$(basename $TRACE)
911 if [ "$BASETRACE" = "$TRACE" ] ; then
912 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
915 echo "post-processing traces..."
916 rm -f $TRACE/qtrace.dexlist
918 if [ $? -ne 0 ]; then
920 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
924 echo "generating dexlist output..."
925 /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
926 echo "generating dmtrace data..."
927 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
928 echo "generating html file..."
929 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
930 echo "done, see $TRACE/dmtrace.html for details"
932 echo " traceview $TRACE/dmtrace"
935 # communicate with a running device or emulator, set up necessary state,
936 # and run the hat command.
939 # process standard adb options
941 if [ "$1" = "-d" -o "$1" = "-e" ]; then
944 elif [ "$1" = "-s" ]; then
948 local adbOptions=${adbTarget}
949 echo adbOptions = ${adbOptions}
954 if [ "$targetPid" = "" ]; then
955 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
959 # confirm hat is available
960 if [ -z $(which hat) ]; then
961 echo "hat is not available in this configuration."
965 # issue "am" command to cause the hprof dump
966 local devFile=/sdcard/hprof-$targetPid
967 echo "Poking $targetPid and waiting for data..."
968 adb ${adbOptions} shell am dumpheap $targetPid $devFile
969 echo "Press enter when logcat shows \"hprof: heap dump completed\""
973 local localFile=/tmp/$$-hprof
975 echo "Retrieving file $devFile..."
976 adb ${adbOptions} pull $devFile $localFile
978 adb ${adbOptions} shell rm $devFile
980 echo "Running hat on $localFile"
981 echo "View the output by pointing your browser at http://localhost:7000/"
986 function getbugreports()
988 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
990 if [ ! "$reports" ]; then
991 echo "Could not locate any bugreports."
996 for report in ${reports[@]}
998 echo "/sdcard/bugreports/${report}"
999 adb pull /sdcard/bugreports/${report} ${report}
1004 function startviewserver()
1007 if [ $# -gt 0 ]; then
1010 adb shell service call window 1 i32 $port
1013 function stopviewserver()
1015 adb shell service call window 2
1018 function isviewserverstarted()
1020 adb shell service call window 3
1025 adb shell input keyevent 3
1030 adb shell input keyevent 4
1035 adb shell input keyevent 82
1038 function smoketest()
1040 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
1041 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1046 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1050 (cd "$T" && mmm tests/SmokeTest) &&
1051 adb uninstall com.android.smoketest > /dev/null &&
1052 adb uninstall com.android.smoketest.tests > /dev/null &&
1053 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1054 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1055 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1058 # simple shortcut to the runtest command
1063 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1066 ("$T"/development/testrunner/runtest.py $@)
1070 if [[ -z "$1" ]]; then
1071 echo "Usage: godir <regex>"
1075 if [[ ! -f $T/filelist ]]; then
1076 echo -n "Creating index..."
1077 (cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
1082 lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
1083 if [[ ${#lines[@]} = 0 ]]; then
1089 if [[ ${#lines[@]} > 1 ]]; then
1090 while [[ -z "$pathname" ]]; do
1093 for line in ${lines[@]}; do
1094 printf "%6s %s\n" "[$index]" $line
1095 index=$(($index + 1))
1098 echo -n "Select one: "
1101 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1102 echo "Invalid choice"
1105 pathname=${lines[$(($choice-1))]}
1108 pathname=${lines[0]}
1113 # Force JAVA_HOME to point to java 1.6 if it isn't already set
1114 function set_java_home() {
1115 if [ ! "$JAVA_HOME" ]; then
1118 export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
1121 export JAVA_HOME=/usr/lib/jvm/java-6-sun
1127 if [ "x$SHELL" != "x/bin/bash" ]; then
1128 case `ps -o command -p $$` in
1132 echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
1137 # Execute the contents of any vendorsetup.sh files we can find.
1138 for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`