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 \
58 TARGET_BUILD_VARIANT= \
61 get_build_var TARGET_DEVICE > /dev/null
62 # hide successful answers, but allow the errors to show
65 VARIANT_CHOICES=(user userdebug eng)
67 # check to see if the supplied variant is valid
68 function check_variant()
70 for v in ${VARIANT_CHOICES[@]}
84 echo "Couldn't locate the top of the tree. Try setting TOP."
88 ##################################################################
90 # Read me before you modify this code #
92 # This function sets ANDROID_BUILD_PATHS to what it is adding #
93 # to PATH, and the next time it is run, it removes that from #
94 # PATH. This is required so lunch can be run more than once #
95 # and still have working paths. #
97 ##################################################################
99 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
100 # due to "C:\Program Files" being in the path.
103 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
104 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
106 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
107 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
108 # strip trailing ':', if any
109 export PATH=${PATH/%:/}
112 # and in with the new
114 prebuiltdir=$(getprebuilt)
116 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
117 export ANDROID_EABI_TOOLCHAIN=
118 toolchaindir=toolchain/arm-linux-androideabi-4.4.x/bin
119 if [ -d "$prebuiltdir/$toolchaindir" ]; then
120 export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
123 export ARM_EABI_TOOLCHAIN=
124 toolchaindir=toolchain/arm-eabi-4.4.3/bin
125 if [ -d "$prebuiltdir/$toolchaindir" ]; then
126 export ARM_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
129 export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
130 export ANDROID_QTOOLS=$T/development/emulator/qtools
131 export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS
132 export PATH=$PATH$ANDROID_BUILD_PATHS
134 unset ANDROID_JAVA_TOOLCHAIN
135 unset ANDROID_PRE_BUILD_PATHS
136 if [ -n "$JAVA_HOME" ]; then
137 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
138 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
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 processing samples collected by perf counters
150 unset OPROFILE_EVENTS_DIR
151 export OPROFILE_EVENTS_DIR=$T/external/oprofile/events
153 # needed for building linux on MacOS
155 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
158 function printconfig()
162 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
165 get_build_var report_config
168 function set_stuff_for_environment()
175 export ANDROID_BUILD_TOP=$(gettop)
178 function set_sequence_number()
180 export BUILD_ENV_SEQUENCE_NUMBER=10
185 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
186 local product=$TARGET_PRODUCT
187 local variant=$TARGET_BUILD_VARIANT
188 local apps=$TARGET_BUILD_APPS
189 if [ -z "$apps" ]; then
190 export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
192 export PROMPT_COMMAND="echo -ne \"\033]0;[$apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
197 function addcompletions()
201 # Keep us from trying to run in something that isn't bash.
202 if [ -z "${BASH_VERSION}" ]; then
206 # Keep us from trying to run in bash that's too old.
207 if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
211 dir="sdk/bash_completion"
212 if [ -d ${dir} ]; then
213 for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
220 function choosetype()
222 echo "Build type choices are:"
227 local DEFAULT_NUM DEFAULT_VALUE
229 DEFAULT_VALUE=release
231 export TARGET_BUILD_TYPE=
233 while [ -z $TARGET_BUILD_TYPE ]
235 echo -n "Which would you like? ["$DEFAULT_NUM"] "
236 if [ -z "$1" ] ; then
244 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
247 export TARGET_BUILD_TYPE=release
250 export TARGET_BUILD_TYPE=release
253 export TARGET_BUILD_TYPE=debug
256 export TARGET_BUILD_TYPE=debug
260 echo "I didn't understand your response. Please try again."
264 if [ -n "$1" ] ; then
269 set_stuff_for_environment
273 # This function isn't really right: It chooses a TARGET_PRODUCT
274 # based on the list of boards. Usually, that gets you something
275 # that kinda works with a generic product, but really, you should
276 # pick a product by name.
278 function chooseproduct()
280 if [ "x$TARGET_PRODUCT" != x ] ; then
281 default_value=$TARGET_PRODUCT
286 export TARGET_PRODUCT=
288 while [ -z "$TARGET_PRODUCT" ]
290 echo -n "Which product would you like? [$default_value] "
291 if [ -z "$1" ] ; then
298 if [ -z "$ANSWER" ] ; then
299 export TARGET_PRODUCT=$default_value
301 if check_product $ANSWER
303 export TARGET_PRODUCT=$ANSWER
305 echo "** Not a valid product: $ANSWER"
308 if [ -n "$1" ] ; then
313 set_stuff_for_environment
316 function choosevariant()
318 echo "Variant choices are:"
321 for v in ${VARIANT_CHOICES[@]}
323 # The product name is the name of the directory containing
324 # the makefile we found, above.
329 local default_value=eng
332 export TARGET_BUILD_VARIANT=
333 while [ -z "$TARGET_BUILD_VARIANT" ]
335 echo -n "Which would you like? [$default_value] "
336 if [ -z "$1" ] ; then
343 if [ -z "$ANSWER" ] ; then
344 export TARGET_BUILD_VARIANT=$default_value
345 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
346 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
347 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
350 if check_variant $ANSWER
352 export TARGET_BUILD_VARIANT=$ANSWER
354 echo "** Not a valid variant: $ANSWER"
357 if [ -n "$1" ] ; then
363 function choosecombo()
376 set_stuff_for_environment
380 # Clear this variable. It will be built up again when the vendorsetup.sh
381 # files are included at the end of this file.
382 unset LUNCH_MENU_CHOICES
383 function add_lunch_combo()
387 for c in ${LUNCH_MENU_CHOICES[@]} ; do
388 if [ "$new_combo" = "$c" ] ; then
392 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
395 # add the default one here
396 add_lunch_combo full-eng
397 add_lunch_combo full_x86-eng
398 add_lunch_combo vbox_x86-eng
400 function print_lunch_menu()
404 echo "You're building on" $uname
406 echo "Lunch menu... pick a combo:"
410 for choice in ${LUNCH_MENU_CHOICES[@]}
427 echo -n "Which would you like? [full-eng] "
436 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
438 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
440 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
442 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
447 if [ -z "$selection" ]
450 echo "Invalid lunch combo: $answer"
454 export TARGET_BUILD_APPS=
456 local product=$(echo -n $selection | sed -e "s/-.*$//")
457 check_product $product
461 echo "** Don't have a product spec for: '$product'"
462 echo "** Do you have the right repo manifest?"
466 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
467 check_variant $variant
471 echo "** Invalid variant: '$variant'"
472 echo "** Must be one of ${VARIANT_CHOICES[@]}"
476 if [ -z "$product" -o -z "$variant" ]
482 export TARGET_PRODUCT=$product
483 export TARGET_BUILD_VARIANT=$variant
484 export TARGET_BUILD_TYPE=release
488 set_stuff_for_environment
492 # Tab completion for lunch.
497 cur="${COMP_WORDS[COMP_CWORD]}"
498 prev="${COMP_WORDS[COMP_CWORD-1]}"
500 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
503 complete -F _lunch lunch
505 # Configures the build to build unbundled apps.
506 # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
509 local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$'))
510 local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng)$'))
512 if [ $(echo $variant | wc -w) -gt 1 ]; then
513 echo "tapas: Error: Multiple build variants supplied: $variant"
516 if [ -z "$variant" ]; then
519 if [ -z "$apps" ]; then
523 export TARGET_PRODUCT=full
524 export TARGET_BUILD_VARIANT=$variant
525 export TARGET_BUILD_TYPE=release
526 export TARGET_BUILD_APPS=$apps
528 set_stuff_for_environment
534 local TOPFILE=build/core/envsetup.mk
535 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
538 if [ -f $TOPFILE ] ; then
539 # The following circumlocution (repeated below as well) ensures
540 # that we record the true directory name and not one that is
541 # faked up with symlink names.
544 # We redirect cd to /dev/null in case it's aliased to
545 # a command that prints something as a side-effect
549 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
554 if [ -f "$T/$TOPFILE" ]; then
567 echo "Couldn't locate the top of the tree. Try setting TOP."
571 function findmakefile()
573 TOPFILE=build/core/envsetup.mk
574 # We redirect cd to /dev/null in case it's aliased to
575 # a command that prints something as a side-effect
579 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
581 if [ -f "$T/Android.mk" ]; then
593 # If we're sitting in the root of the build tree, just do a
595 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
598 # Find the closest Android.mk file.
600 local M=$(findmakefile)
601 # Remove the path to top as the makefilepath needs to be relative
602 local M=`echo $M|sed 's:'$T'/::'`
604 echo "Couldn't locate the top of the tree. Try setting TOP."
605 elif [ ! "$M" ]; then
606 echo "Couldn't locate a makefile from the current directory."
608 ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@
621 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
622 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
623 for DIR in $DIRS ; do
624 MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
625 if [ "$MODULES" = "" ]; then
628 DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
629 if [ -f $DIR/Android.mk ]; then
630 TO_CHOP=`(cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
631 TO_CHOP=`expr $TO_CHOP + 1`
632 START=`PWD= /bin/pwd`
633 MFILE=`echo $START | cut -c${TO_CHOP}-`
634 if [ "$MFILE" = "" ] ; then
635 MFILE=$DIR/Android.mk
637 MFILE=$MFILE/$DIR/Android.mk
639 MAKEFILE="$MAKEFILE $MFILE"
641 if [ "$DIR" = snod ]; then
643 elif [ "$DIR" = showcommands ]; then
644 ARGS="$ARGS showcommands"
645 elif [ "$DIR" = dist ]; then
647 elif [ "$DIR" = incrementaljavac ]; then
648 ARGS="$ARGS incrementaljavac"
650 echo "No Android.mk in $DIR."
655 ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS $MODULES $ARGS
657 echo "Couldn't locate the top of the tree. Try setting TOP."
664 - m: Makes from the top of the tree.
665 - mm: Builds all of the modules in the current directory.
666 - mmm dir: Same as 'cd dir; mm'
668 Type 'help' for more commands.
678 echo "Couldn't locate the top of the tree. Try setting TOP."
684 TOPFILE=build/core/envsetup.mk
685 # We redirect cd to /dev/null in case it's aliased to
686 # a command that prints something as a side-effect
690 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
692 if [ -f "$T/Android.mk" ]; then
699 echo "can't find Android.mk"
706 local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
709 echo "usage: pid name"
713 # systemstack - dump the current stack trace of all threads in the system process
714 # to the usual ANR traces file
715 function systemstack()
717 adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server)
722 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
723 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
724 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
725 local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
726 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
727 local ARCH=$(get_build_var TARGET_ARCH)
730 x86) GDB=i686-android-linux-gdb;;
731 arm) GDB=arm-linux-androideabi-gdb;;
732 *) echo "Unknown arch $ARCH"; return 1;;
735 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
744 if [ "$PORT" ] ; then
752 if [ "$PROG" ] ; then
753 if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
758 adb forward "tcp$PORT" "tcp$PORT"
759 adb shell gdbserver $PORT --attach $PID &
763 echo "If you haven't done so already, do this first on the device:"
764 echo " gdbserver $PORT /system/bin/$EXE"
766 echo " gdbserver $PORT --attach $PID"
770 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
771 echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS"
772 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
773 echo >>"$OUT_ROOT/gdbclient.cmds" ""
775 $GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
777 echo "Unable to determine build system output dir."
786 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 "$@"
793 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 "$@"
800 find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
805 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 "$@"
810 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;
817 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
822 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 "$@"
829 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 "$@"
834 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 "$@"
842 get_abs_build_var ANDROID_PREBUILTS
845 function tracedmdump()
849 echo "Couldn't locate the top of the tree. Try setting TOP."
852 local prebuiltdir=$(getprebuilt)
853 local KERNEL=$T/prebuilt/android-arm/kernel/vmlinux-qemu
856 if [ ! "$TRACE" ] ; then
857 echo "usage: tracedmdump tracename"
861 if [ ! -r "$KERNEL" ] ; then
862 echo "Error: cannot find kernel: '$KERNEL'"
866 local BASETRACE=$(basename $TRACE)
867 if [ "$BASETRACE" = "$TRACE" ] ; then
868 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
871 echo "post-processing traces..."
872 rm -f $TRACE/qtrace.dexlist
874 if [ $? -ne 0 ]; then
876 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
880 echo "generating dexlist output..."
881 /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
882 echo "generating dmtrace data..."
883 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
884 echo "generating html file..."
885 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
886 echo "done, see $TRACE/dmtrace.html for details"
888 echo " traceview $TRACE/dmtrace"
891 # communicate with a running device or emulator, set up necessary state,
892 # and run the hat command.
895 # process standard adb options
897 if [ "$1" = "-d" -o "$1" = "-e" ]; then
900 elif [ "$1" = "-s" ]; then
904 local adbOptions=${adbTarget}
905 echo adbOptions = ${adbOptions}
910 if [ "$targetPid" = "" ]; then
911 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
915 # confirm hat is available
916 if [ -z $(which hat) ]; then
917 echo "hat is not available in this configuration."
921 # issue "am" command to cause the hprof dump
922 local devFile=/sdcard/hprof-$targetPid
923 echo "Poking $targetPid and waiting for data..."
924 adb ${adbOptions} shell am dumpheap $targetPid $devFile
925 echo "Press enter when logcat shows \"hprof: heap dump completed\""
929 local localFile=/tmp/$$-hprof
931 echo "Retrieving file $devFile..."
932 adb ${adbOptions} pull $devFile $localFile
934 adb ${adbOptions} shell rm $devFile
936 echo "Running hat on $localFile"
937 echo "View the output by pointing your browser at http://localhost:7000/"
939 hat -JXmx512m $localFile
942 function getbugreports()
944 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
946 if [ ! "$reports" ]; then
947 echo "Could not locate any bugreports."
952 for report in ${reports[@]}
954 echo "/sdcard/bugreports/${report}"
955 adb pull /sdcard/bugreports/${report} ${report}
960 function startviewserver()
963 if [ $# -gt 0 ]; then
966 adb shell service call window 1 i32 $port
969 function stopviewserver()
971 adb shell service call window 2
974 function isviewserverstarted()
976 adb shell service call window 3
981 adb shell input keyevent 3
986 adb shell input keyevent 4
991 adb shell input keyevent 82
996 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
997 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1002 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1006 (cd "$T" && mmm tests/SmokeTest) &&
1007 adb uninstall com.android.smoketest > /dev/null &&
1008 adb uninstall com.android.smoketest.tests > /dev/null &&
1009 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1010 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1011 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1014 # simple shortcut to the runtest command
1019 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1022 ("$T"/development/testrunner/runtest.py $@)
1026 if [[ -z "$1" ]]; then
1027 echo "Usage: godir <regex>"
1031 if [[ ! -f $T/filelist ]]; then
1032 echo -n "Creating index..."
1033 (cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
1038 lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
1039 if [[ ${#lines[@]} = 0 ]]; then
1045 if [[ ${#lines[@]} > 1 ]]; then
1046 while [[ -z "$pathname" ]]; do
1049 for line in ${lines[@]}; do
1050 printf "%6s %s\n" "[$index]" $line
1051 index=$(($index + 1))
1054 echo -n "Select one: "
1057 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1058 echo "Invalid choice"
1061 pathname=${lines[$(($choice-1))]}
1064 pathname=${lines[0]}
1069 # Force JAVA_HOME to point to java 1.6 if it isn't already set
1070 function set_java_home() {
1071 if [ ! "$JAVA_HOME" ]; then
1074 export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
1077 export JAVA_HOME=/usr/lib/jvm/java-6-sun
1083 if [ "x$SHELL" != "x/bin/bash" ]; then
1084 case `ps -o command -p $$` in
1088 echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
1093 # Execute the contents of any vendorsetup.sh files we can find.
1094 for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`