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|arm64|x86_64|mips64] [eng|userdebug|user]
6 - croot: Changes directory to the top of the tree.
7 - cout: Changes directory to out.
8 - m: Makes from the top of the tree.
9 - mm: Builds all of the modules in the current directory, but not their dependencies.
10 - mmm: Builds all of the modules in the supplied directories, but not their dependencies.
11 To limit the modules being built use the syntax: mmm dir/:target1,target2.
12 - mma: Builds all of the modules in the current directory, and their dependencies.
13 - mmma: Builds all of the modules in the supplied directories, and their dependencies.
14 - mmap: Builds all of the modules in the current directory, and its dependencies, then pushes the package to the device.
15 - mmp: Builds all of the modules in the current directory and pushes them to the device.
16 - mmmp: Builds all of the modules in the supplied directories and pushes them to the device.
17 - mms: Short circuit builder. Quickly re-build the kernel, rootfs, boot and system images
18 without deep dependencies. Requires the full build to have run before.
19 - provision: Flash device with all required partitions. Options will be passed on to fastboot.
20 - cgrep: Greps on all local C/C++ files.
21 - ggrep: Greps on all local Gradle files.
22 - jgrep: Greps on all local Java files.
23 - resgrep: Greps on all local res/*.xml files.
24 - mangrep: Greps on all local AndroidManifest.xml files.
25 - mgrep: Greps on all local Makefiles files.
26 - sepgrep: Greps on all local sepolicy files.
27 - sgrep: Greps on all local source files.
28 - godir: Go to the directory containing a file.
29 - cmremote: Add git remote for CM Gerrit Review
30 - cmgerrit: A Git wrapper that fetches/pushes patch from/to CM Gerrit Review
31 - aospremote: Add git remote for matching AOSP repository
32 - cafremote: Add git remote for matching CodeAurora repository.
33 - cmrebase: Rebase a Gerrit change and push it again
34 - mka: Builds using SCHED_BATCH on all processors
35 - mkap: Builds the module(s) using mka and pushes them to the device.
36 - cmka: Cleans and builds using mka.
37 - repolastsync: Prints date and time of last repo sync.
38 - reposync: Parallel repo sync using ionice and SCHED_BATCH
39 - repopick: Utility to fetch changes from Gerrit.
40 - installboot: Installs a boot.img to the connected device.
41 - installrecovery: Installs a recovery.img to the connected device.
42 - repodiff: Diff 2 different branches or tags within the same repo
45 - SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
46 ASAN_OPTIONS=detect_leaks=0 will be set by default until the
47 build is leak-check clean.
49 Look at the source to view more functions. The complete list is:
52 for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
57 # Get all the build variables needed by this script in a single call to the build system.
58 function build_build_var_cache()
61 # Grep out the variable names from the script.
62 cached_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
63 cached_abs_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
64 # Call the build system to dump the "<val>=<value>" pairs as a shell script.
65 build_dicts_script=`\cd $T; export CALLED_FROM_SETUP=true; export BUILD_SYSTEM=build/core; \
66 command make --no-print-directory -f build/core/config.mk \
68 DUMP_MANY_VARS="$cached_vars" \
69 DUMP_MANY_ABS_VARS="$cached_abs_vars" \
70 DUMP_VAR_PREFIX="var_cache_" \
71 DUMP_ABS_VAR_PREFIX="abs_var_cache_"`
75 unset build_dicts_script
78 # Excute the script to store the "<val>=<value>" pairs as shell variables.
79 eval "$build_dicts_script"
81 unset build_dicts_script
86 BUILD_VAR_CACHE_READY="true"
89 # Delete the build var cache, so that we can still call into the build system
90 # to get build variables not listed in this script.
91 function destroy_build_var_cache()
93 unset BUILD_VAR_CACHE_READY
94 for v in $cached_vars; do
98 for v in $cached_abs_vars; do
99 unset abs_var_cache_$v
101 unset cached_abs_vars
104 # Get the value of a build variable as an absolute path.
105 function get_abs_build_var()
107 if [ "$BUILD_VAR_CACHE_READY" = "true" ]
109 eval echo \"\${abs_var_cache_$1}\"
115 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
118 (\cd $T; export CALLED_FROM_SETUP=true; export BUILD_SYSTEM=build/core; \
119 command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1)
122 # Get the exact value of a build variable.
123 function get_build_var()
125 if [ "$BUILD_VAR_CACHE_READY" = "true" ]
127 eval echo \"\${var_cache_$1}\"
133 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
136 (\cd $T; export CALLED_FROM_SETUP=true; export BUILD_SYSTEM=build/core; \
137 command make --no-print-directory -f build/core/config.mk dumpvar-$1)
140 # check to see if the supplied product is one we can build
141 function check_product()
145 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
149 if (echo -n $1 | grep -q -e "^cm_") ; then
150 CM_BUILD=$(echo -n $1 | sed -e 's/^cm_//g')
151 export BUILD_NUMBER=$((date +%s%N ; echo $CM_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10)
158 TARGET_BUILD_VARIANT= \
161 get_build_var TARGET_DEVICE > /dev/null
162 # hide successful answers, but allow the errors to show
165 VARIANT_CHOICES=(user userdebug eng)
167 # check to see if the supplied variant is valid
168 function check_variant()
170 for v in ${VARIANT_CHOICES[@]}
184 echo "Couldn't locate the top of the tree. Try setting TOP."
188 ##################################################################
190 # Read me before you modify this code #
192 # This function sets ANDROID_BUILD_PATHS to what it is adding #
193 # to PATH, and the next time it is run, it removes that from #
194 # PATH. This is required so lunch can be run more than once #
195 # and still have working paths. #
197 ##################################################################
199 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
200 # due to "C:\Program Files" being in the path.
203 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
204 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
206 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
207 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
208 # strip leading ':', if any
209 export PATH=${PATH/:%/}
212 # and in with the new
213 prebuiltdir=$(getprebuilt)
214 gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
216 # defined in core/config.mk
217 targetgccversion=$(get_build_var TARGET_GCC_VERSION)
218 targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
219 export TARGET_GCC_VERSION=$targetgccversion
221 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
222 export ANDROID_TOOLCHAIN=
223 export ANDROID_TOOLCHAIN_2ND_ARCH=
224 local ARCH=$(get_build_var TARGET_ARCH)
226 x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
228 x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
230 arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
232 arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;
233 toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin
235 mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin
238 echo "Can't find toolchain for unknown architecture: $ARCH"
239 toolchaindir=xxxxxxxxx
242 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
243 export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
246 if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then
247 export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
250 export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin
251 export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN:$ANDROID_TOOLCHAIN_2ND_ARCH:$ANDROID_DEV_SCRIPTS:
253 # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH
254 # to ensure that the corresponding 'emulator' binaries are used.
257 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
260 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
263 ANDROID_EMULATOR_PREBUILTS=
266 if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
267 ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS:
268 export ANDROID_EMULATOR_PREBUILTS
271 export PATH=$ANDROID_BUILD_PATHS$PATH
272 export PYTHONPATH=$T/development/python-packages:$PYTHONPATH
274 unset ANDROID_JAVA_TOOLCHAIN
275 unset ANDROID_PRE_BUILD_PATHS
276 if [ -n "$JAVA_HOME" ]; then
277 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
278 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
279 export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
282 unset ANDROID_PRODUCT_OUT
283 export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
284 export OUT=$ANDROID_PRODUCT_OUT
286 unset ANDROID_HOST_OUT
287 export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
289 if [ -n "$ANDROID_CCACHE_DIR" ]; then
290 export CCACHE_DIR=$ANDROID_CCACHE_DIR
293 # needed for building linux on MacOS
295 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
298 function printconfig()
302 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
305 get_build_var report_config
308 function set_stuff_for_environment()
315 # With this environment variable new GCC can apply colors to warnings/errors
316 export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
317 export ASAN_OPTIONS=detect_leaks=0
320 function set_sequence_number()
322 export BUILD_ENV_SEQUENCE_NUMBER=10
327 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
328 local arch=$(gettargetarch)
329 local product=$TARGET_PRODUCT
330 local variant=$TARGET_BUILD_VARIANT
331 local apps=$TARGET_BUILD_APPS
332 if [ -z "$PROMPT_COMMAND" ]; then
334 PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}: ${PWD}\007\""
335 elif [ -z "$(echo $PROMPT_COMMAND | grep '033]0;')" ]; then
336 # Prompts exist, but no hardstatus
337 PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}: ${PWD}\007\";${PROMPT_COMMAND}"
339 if [ ! -z "$ANDROID_PROMPT_PREFIX" ]; then
340 PROMPT_COMMAND="$(echo $PROMPT_COMMAND | sed -e 's/$ANDROID_PROMPT_PREFIX //g')"
343 if [ -z "$apps" ]; then
344 ANDROID_PROMPT_PREFIX="[${arch}-${product}-${variant}]"
346 ANDROID_PROMPT_PREFIX="[$arch $apps $variant]"
348 export ANDROID_PROMPT_PREFIX
350 # Inject build data into hardstatus
351 export PROMPT_COMMAND="$(echo $PROMPT_COMMAND | sed -e 's/\\033]0;\(.*\)\\007/\\033]0;$ANDROID_PROMPT_PREFIX \1\\007/g')"
355 function check_bash_version()
357 # Keep us from trying to run in something that isn't bash.
358 if [ -z "${BASH_VERSION}" ]; then
362 # Keep us from trying to run in bash that's too old.
363 if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
370 function choosetype()
372 echo "Build type choices are:"
377 local DEFAULT_NUM DEFAULT_VALUE
379 DEFAULT_VALUE=release
381 export TARGET_BUILD_TYPE=
383 while [ -z $TARGET_BUILD_TYPE ]
385 echo -n "Which would you like? ["$DEFAULT_NUM"] "
386 if [ -z "$1" ] ; then
394 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
397 export TARGET_BUILD_TYPE=release
400 export TARGET_BUILD_TYPE=release
403 export TARGET_BUILD_TYPE=debug
406 export TARGET_BUILD_TYPE=debug
410 echo "I didn't understand your response. Please try again."
414 if [ -n "$1" ] ; then
419 build_build_var_cache
420 set_stuff_for_environment
421 destroy_build_var_cache
425 # This function isn't really right: It chooses a TARGET_PRODUCT
426 # based on the list of boards. Usually, that gets you something
427 # that kinda works with a generic product, but really, you should
428 # pick a product by name.
430 function chooseproduct()
432 if [ "x$TARGET_PRODUCT" != x ] ; then
433 default_value=$TARGET_PRODUCT
435 default_value=aosp_arm
438 export TARGET_BUILD_APPS=
439 export TARGET_PRODUCT=
441 while [ -z "$TARGET_PRODUCT" ]
443 echo -n "Which product would you like? [$default_value] "
444 if [ -z "$1" ] ; then
451 if [ -z "$ANSWER" ] ; then
452 export TARGET_PRODUCT=$default_value
454 if check_product $ANSWER
456 export TARGET_PRODUCT=$ANSWER
458 echo "** Not a valid product: $ANSWER"
461 if [ -n "$1" ] ; then
466 build_build_var_cache
467 set_stuff_for_environment
468 destroy_build_var_cache
471 function choosevariant()
473 echo "Variant choices are:"
476 for v in ${VARIANT_CHOICES[@]}
478 # The product name is the name of the directory containing
479 # the makefile we found, above.
484 local default_value=eng
487 export TARGET_BUILD_VARIANT=
488 while [ -z "$TARGET_BUILD_VARIANT" ]
490 echo -n "Which would you like? [$default_value] "
491 if [ -z "$1" ] ; then
498 if [ -z "$ANSWER" ] ; then
499 export TARGET_BUILD_VARIANT=$default_value
500 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
501 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
502 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
505 if check_variant $ANSWER
507 export TARGET_BUILD_VARIANT=$ANSWER
509 echo "** Not a valid variant: $ANSWER"
512 if [ -n "$1" ] ; then
518 function choosecombo()
531 build_build_var_cache
532 set_stuff_for_environment
534 destroy_build_var_cache
537 # Clear this variable. It will be built up again when the vendorsetup.sh
538 # files are included at the end of this file.
539 unset LUNCH_MENU_CHOICES
540 function add_lunch_combo()
544 for c in ${LUNCH_MENU_CHOICES[@]} ; do
545 if [ "$new_combo" = "$c" ] ; then
549 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
552 # add the default one here
553 add_lunch_combo aosp_arm-eng
554 add_lunch_combo aosp_arm64-eng
555 add_lunch_combo aosp_mips-eng
556 add_lunch_combo aosp_mips64-eng
557 add_lunch_combo aosp_x86-eng
558 add_lunch_combo aosp_x86_64-eng
560 function print_lunch_menu()
564 echo "You're building on" $uname
565 if [ "$(uname)" = "Darwin" ] ; then
566 echo " (ohai, koush!)"
569 if [ "z${CM_DEVICES_ONLY}" != "z" ]; then
570 echo "Breakfast menu... pick a combo:"
572 echo "Lunch menu... pick a combo:"
577 for choice in ${LUNCH_MENU_CHOICES[@]}
583 if [ "z${CM_DEVICES_ONLY}" != "z" ]; then
584 echo "... and don't forget the bacon!"
593 if [ $? -eq 0 ]; then
596 echo "No such item in brunch menu. Try 'breakfast'"
606 CM_DEVICES_ONLY="true"
607 unset LUNCH_MENU_CHOICES
608 add_lunch_combo full-eng
609 for f in `/bin/ls vendor/cm/vendorsetup.sh 2> /dev/null`
616 if [ $# -eq 0 ]; then
617 # No arguments, so let's have the full menu
620 echo "z$target" | grep -q "-"
621 if [ $? -eq 0 ]; then
622 # A buildtype was specified, assume a full device name
625 # This is probably just the CM model name
626 if [ -z "$variant" ]; then
629 lunch cm_$target-$variant
640 LUNCH_MENU_CHOICES=($(for l in ${LUNCH_MENU_CHOICES[@]}; do echo "$l"; done | sort))
646 echo -n "Which would you like? [aosp_arm-eng] "
654 selection=aosp_arm-eng
655 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
657 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
659 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
661 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
666 if [ -z "$selection" ]
669 echo "Invalid lunch combo: $answer"
673 export TARGET_BUILD_APPS=
675 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
676 check_variant $variant
680 echo "** Invalid variant: '$variant'"
681 echo "** Must be one of ${VARIANT_CHOICES[@]}"
685 local product=$(echo -n $selection | sed -e "s/-.*$//")
686 check_product $product
689 # if we can't find a product, try to grab it off the CM github
692 build/tools/roomservice.py $product
694 check_product $product
696 build/tools/roomservice.py $product true
698 TARGET_PRODUCT=$product \
699 TARGET_BUILD_VARIANT=$variant \
700 build_build_var_cache
705 echo "** Don't have a product spec for: '$product'"
706 echo "** Do you have the right repo manifest?"
710 if [ -z "$product" -o -z "$variant" ]
716 export TARGET_PRODUCT=$product
717 export TARGET_BUILD_VARIANT=$variant
718 export TARGET_BUILD_TYPE=release
724 set_stuff_for_environment
726 destroy_build_var_cache
729 # Tab completion for lunch.
734 cur="${COMP_WORDS[COMP_CWORD]}"
735 prev="${COMP_WORDS[COMP_CWORD-1]}"
737 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
740 complete -F _lunch lunch 2>/dev/null
742 # Configures the build to build unbundled apps.
743 # Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
746 local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)"
747 local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
748 local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
749 local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5|arm64|x86_64|mips64|ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
751 if [ $(echo $arch | wc -w) -gt 1 ]; then
752 echo "tapas: Error: Multiple build archs supplied: $arch"
755 if [ $(echo $variant | wc -w) -gt 1 ]; then
756 echo "tapas: Error: Multiple build variants supplied: $variant"
759 if [ $(echo $density | wc -w) -gt 1 ]; then
760 echo "tapas: Error: Multiple densities supplied: $density"
764 local product=aosp_arm
766 x86) product=aosp_x86;;
767 mips) product=aosp_mips;;
768 armv5) product=generic_armv5;;
769 arm64) product=aosp_arm64;;
770 x86_64) product=aosp_x86_64;;
771 mips64) product=aosp_mips64;;
773 if [ -z "$variant" ]; then
776 if [ -z "$apps" ]; then
779 if [ -z "$density" ]; then
783 export TARGET_PRODUCT=$product
784 export TARGET_BUILD_VARIANT=$variant
785 export TARGET_BUILD_DENSITY=$density
786 export TARGET_BUILD_TYPE=release
787 export TARGET_BUILD_APPS=$apps
789 build_build_var_cache
790 set_stuff_for_environment
792 destroy_build_var_cache
798 MODVERSION=$(get_build_var CM_VERSION)
799 ZIPFILE=cm-$MODVERSION.zip
800 ZIPPATH=$OUT/$ZIPFILE
801 if [ ! -f $ZIPPATH ] ; then
802 echo "Nothing to eat"
805 adb start-server # Prevent unexpected starting server message from adb get-state in the next line
806 if [ $(adb get-state) != device -a $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
807 echo "No device is online. Waiting for one..."
808 echo "Please connect USB and/or enable USB debugging"
809 until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
812 echo "Device Found.."
814 if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD");
816 # if adbd isn't root we can't write to /cache/recovery/
820 cat << EOF > /tmp/command
821 --sideload_auto_reboot
823 if adb push /tmp/command /cache/recovery/ ; then
824 echo "Rebooting into recovery for sideload installation"
826 adb wait-for-sideload
827 adb sideload $ZIPPATH
831 echo "Nothing to eat"
836 echo "The connected device does not appear to be $CM_BUILD, run away!"
848 local TOPFILE=build/core/envsetup.mk
849 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
850 # The following circumlocution ensures we remove symlinks from TOP.
851 (cd $TOP; PWD= /bin/pwd)
853 if [ -f $TOPFILE ] ; then
854 # The following circumlocution (repeated below as well) ensures
855 # that we record the true directory name and not one that is
856 # faked up with symlink names.
861 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
866 if [ -f "$T/$TOPFILE" ]; then
873 # Return driver for "make", if any (eg. static analyzer)
877 test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
878 if [ -n "$WITH_STATIC_ANALYZER" ]; then
880 $T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \
881 --use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \
890 local DRV=$(getdriver $T)
892 $DRV make -C $T -f build/core/main.mk $@
894 echo "Couldn't locate the top of the tree. Try setting TOP."
899 function findmakefile()
901 TOPFILE=build/core/envsetup.mk
904 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
906 if [ -f "$T/Android.mk" ]; then
919 local DRV=$(getdriver $T)
920 # If we're sitting in the root of the build tree, just do a
922 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
925 # Find the closest Android.mk file.
926 local M=$(findmakefile)
928 local GET_INSTALL_PATH=
929 # Remove the path to top as the makefilepath needs to be relative
930 local M=`echo $M|sed 's:'$T'/::'`
932 echo "Couldn't locate the top of the tree. Try setting TOP."
934 elif [ ! "$M" ]; then
935 echo "Couldn't locate a makefile from the current directory."
940 GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
943 if [ -n "$GET_INSTALL_PATH" ]; then
945 # set all args to 'GET-INSTALL-PATH'
946 set -- GET-INSTALL-PATH
950 ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES "$@"
958 local DRV=$(getdriver $T)
964 local GET_INSTALL_PATH=
966 if [ "$(__detect_shell)" = "zsh" ]; then
967 set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
968 set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
970 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
971 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
974 for DIR in $DIRS ; do
975 MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
976 if [ "$MODULES" = "" ]; then
979 DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
980 if [ -f $DIR/Android.mk ]; then
981 local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
982 local TO_CHOP=`expr $TO_CHOP + 1`
983 local START=`PWD= /bin/pwd`
984 local MFILE=`echo $START | cut -c${TO_CHOP}-`
985 if [ "$MFILE" = "" ] ; then
986 MFILE=$DIR/Android.mk
988 MFILE=$MFILE/$DIR/Android.mk
990 MAKEFILE="$MAKEFILE $MFILE"
993 showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
994 GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
995 *) if [ -d $DIR ]; then
996 echo "No Android.mk in $DIR.";
998 echo "Couldn't locate the directory $DIR";
1004 if [ -n "$GET_INSTALL_PATH" ]; then
1005 ARGS=$GET_INSTALL_PATH
1008 ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
1010 echo "Couldn't locate the top of the tree. Try setting TOP."
1018 local DRV=$(getdriver $T)
1019 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
1023 echo "Couldn't locate the top of the tree. Try setting TOP."
1026 local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
1027 local MODULES_IN_PATHS=MODULES-IN-$MY_PWD
1028 # Convert "/" to "-".
1029 MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
1030 $DRV make -C $T -f build/core/main.mk $@ $MODULES_IN_PATHS
1037 local DRV=$(getdriver $T)
1039 if [ "$(__detect_shell)" = "zsh" ]; then
1040 set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
1041 set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
1043 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
1044 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
1046 local MY_PWD=`PWD= /bin/pwd`
1047 if [ "$MY_PWD" = "$T" ]; then
1050 MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'`
1053 local MODULES_IN_PATHS=
1055 for DIR in $DIRS ; do
1056 if [ -d $DIR ]; then
1057 # Remove the leading ./ and trailing / if any exists.
1060 if [ "$MY_PWD" != "" ]; then
1063 MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$DIR"
1066 showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
1067 *) echo "Couldn't find directory $DIR"; return 1;;
1071 # Convert "/" to "-".
1072 MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
1073 $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS $MODULES_IN_PATHS
1075 echo "Couldn't locate the top of the tree. Try setting TOP."
1086 echo "Couldn't locate the top of the tree. Try setting TOP."
1095 echo "Couldn't locate out directory. Try setting OUT."
1101 TOPFILE=build/core/envsetup.mk
1104 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
1106 if [ -f "$T/Android.mk" ]; then
1113 echo "can't find Android.mk"
1116 # simplified version of ps; output in the form
1121 if [ "$1" = "--exact" ]; then
1125 elif [ "$1" = "--help" -o "$1" = "-h" ]; then
1126 echo "usage: qpid [[--exact] <process name|pid>"
1131 if [ "$EXE" ] ; then
1132 qpid | \grep "$prepend$EXE$append"
1136 | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
1144 if [ "$1" = "--exact" ]; then
1150 if [ "$EXE" ] ; then
1151 local PID=`adb shell ps \
1153 | \grep "$prepend$EXE$append" \
1154 | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
1157 echo "usage: pid [--exact] <process name>"
1162 # coredump_setup - enable core dumps globally for any process
1163 # that has the core-file-size limit set correctly
1165 # NOTE: You must call also coredump_enable for a specific process
1166 # if its core-file-size limit is not set already.
1167 # NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
1169 function coredump_setup()
1171 echo "Getting root...";
1173 adb wait-for-device;
1175 echo "Remounting root partition read-write...";
1176 adb shell mount -w -o remount -t rootfs rootfs;
1178 adb wait-for-device;
1179 adb shell mkdir -p /cores;
1180 adb shell mount -t tmpfs tmpfs /cores;
1181 adb shell chmod 0777 /cores;
1183 echo "Granting SELinux permission to dump in /cores...";
1184 adb shell restorecon -R /cores;
1186 echo "Set core pattern.";
1187 adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
1192 # coredump_enable - enable core dumps for the specified process
1193 # $1 = PID of process (e.g., $(pid mediaserver))
1195 # NOTE: coredump_setup must have been called as well for a core
1196 # dump to actually be generated.
1198 function coredump_enable()
1201 if [ -z "$PID" ]; then
1202 printf "Expecting a PID!\n";
1205 echo "Setting core limit for $PID to infinite...";
1206 adb shell prlimit $PID 4 -1 -1
1209 # core - send SIGV and pull the core for process
1210 # $1 = PID of process (e.g., $(pid mediaserver))
1212 # NOTE: coredump_setup must be called once per boot for core dumps to be
1219 if [ -z "$PID" ]; then
1220 printf "Expecting a PID!\n";
1224 local CORENAME=core.$PID;
1225 local COREPATH=/cores/$CORENAME;
1231 while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
1232 printf "\tSending SIG%s to %d...\n" $SIG $PID;
1233 adb shell kill -$SIG $PID;
1237 adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
1238 echo "Done: core is under $COREPATH on device.";
1241 # systemstack - dump the current stack trace of all threads in the system process
1242 # to the usual ANR traces file
1243 function systemstack()
1245 stacks system_server
1250 if [[ $1 =~ ^[0-9]+$ ]] ; then
1252 elif [ "$1" ] ; then
1253 local PIDLIST="$(pid $1)"
1254 if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
1255 local PID="$PIDLIST"
1256 elif [ "$PIDLIST" ] ; then
1257 echo "more than one process: $1"
1259 echo "no such process: $1"
1262 echo "usage: stacks [pid|process name]"
1265 if [ "$PID" ] ; then
1266 # Determine whether the process is native
1267 if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
1268 # Dump stacks of Dalvik process
1269 local TRACES=/data/anr/traces.txt
1270 local ORIG=/data/anr/traces.orig
1271 local TMP=/data/anr/traces.tmp
1273 # Keep original traces to avoid clobbering
1274 adb shell mv $TRACES $ORIG
1276 # Make sure we have a usable file
1277 adb shell touch $TRACES
1278 adb shell chmod 666 $TRACES
1280 # Dump stacks and wait for dump to finish
1281 adb shell kill -3 $PID
1282 adb shell notify $TRACES >/dev/null
1284 # Restore original stacks, and show current output
1285 adb shell mv $TRACES $TMP
1286 adb shell mv $ORIG $TRACES
1289 # Dump stacks of native process
1290 local USE64BIT="$(is64bit $PID)"
1291 adb shell debuggerd$USE64BIT -b $PID
1296 # Read the ELF header from /proc/$PID/exe to determine if the process is
1301 if [ "$PID" ] ; then
1302 if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -ps)" -eq "02" ]] ; then
1312 function dddclient()
1314 local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
1315 local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
1316 local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
1317 local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED)
1318 local OUT_EXE_SYMBOLS=$(get_symbols_directory)
1319 local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
1320 local ARCH=$(get_build_var TARGET_ARCH)
1323 arm) GDB=arm-linux-androideabi-gdb;;
1324 arm64) GDB=arm-linux-androideabi-gdb; GDB64=aarch64-linux-android-gdb;;
1325 mips|mips64) GDB=mips64el-linux-android-gdb;;
1326 x86) GDB=x86_64-linux-android-gdb;;
1327 x86_64) GDB=x86_64-linux-android-gdb;;
1328 *) echo "Unknown arch $ARCH"; return 1;;
1331 if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
1333 if [ "$EXE" ] ; then
1335 if [[ $EXE =~ ^[^/].* ]] ; then
1336 EXE="system/bin/"$EXE
1343 if [ "$PORT" ] ; then
1350 if [ "$PID" ] ; then
1351 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
1353 if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
1354 # that likely didn't work because of returning multiple processes
1355 # try again, filtering by root processes (don't contain colon)
1356 PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'`
1357 if [[ ! "$PID" =~ ^[0-9]+$ ]]
1359 echo "Couldn't resolve '$3' to single PID"
1363 echo "WARNING: multiple processes matching '$3' observed, using root process"
1368 adb forward "tcp$PORT" "tcp$PORT"
1369 local USE64BIT="$(is64bit $PID)"
1370 adb shell gdbserver$USE64BIT $PORT --attach $PID &
1374 echo "If you haven't done so already, do this first on the device:"
1375 echo " gdbserver $PORT /system/bin/$EXE"
1377 echo " gdbserver $PORT --attach <PID>"
1381 OUT_SO_SYMBOLS=$OUT_SO_SYMBOLS$USE64BIT
1382 OUT_VENDOR_SO_SYMBOLS=$OUT_VENDOR_SO_SYMBOLS$USE64BIT
1384 echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
1385 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:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl"
1386 echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb"
1387 echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
1388 # Enable special debugging for ART processes.
1389 if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then
1390 echo >> "$OUT_ROOT/gdbclient.cmds" "art-on"
1392 echo >>"$OUT_ROOT/gdbclient.cmds" ""
1396 if [ "$USE64BIT" != "" ] ; then
1397 WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB64
1398 # 32-bit exe / 32-bit platform
1399 elif [ "$(get_build_var TARGET_2ND_ARCH)" = "" ]; then
1400 WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB
1401 # 32-bit exe / 64-bit platform
1403 WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB
1406 ddd --debugger $WHICH_GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
1408 echo "Unable to determine build system output dir."
1416 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl|vts)' \
1417 -exec grep --color -n "$@" {} +
1424 find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \
1425 -exec grep --color -n "$@" {} +
1430 function gettargetarch
1432 get_build_var TARGET_ARCH
1437 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" \
1438 -exec grep --color -n "$@" {} +
1443 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" \
1444 -exec grep --color -n "$@" {} +
1449 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' -o -name '*.hpp' \) \
1450 -exec grep --color -n "$@" {} +
1455 for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do
1456 find $dir -type f -name '*\.xml' -exec grep --color -n "$@" {} +
1462 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' \
1463 -exec grep --color -n "$@" {} +
1468 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d \
1469 -exec grep --color -n -r --exclude-dir=\.git "$@" {} +
1474 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" \
1475 -exec grep --color -n "$@" {} +
1482 find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' \
1483 -exec grep --color -n "$@" {} +
1488 find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' \
1489 -exec grep --color -n -i "$@" {} +
1496 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f \
1497 -exec grep --color -n "$@" {} +
1502 find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f \
1503 -exec grep --color -n -i "$@" {} +
1509 function getprebuilt
1511 get_abs_build_var ANDROID_PREBUILTS
1514 function tracedmdump()
1518 echo "Couldn't locate the top of the tree. Try setting TOP."
1521 local prebuiltdir=$(getprebuilt)
1522 local arch=$(gettargetarch)
1523 local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
1526 if [ ! "$TRACE" ] ; then
1527 echo "usage: tracedmdump tracename"
1531 if [ ! -r "$KERNEL" ] ; then
1532 echo "Error: cannot find kernel: '$KERNEL'"
1536 local BASETRACE=$(basename $TRACE)
1537 if [ "$BASETRACE" = "$TRACE" ] ; then
1538 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
1541 echo "post-processing traces..."
1542 rm -f $TRACE/qtrace.dexlist
1544 if [ $? -ne 0 ]; then
1546 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
1550 echo "generating dexlist output..."
1551 /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
1552 echo "generating dmtrace data..."
1553 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
1554 echo "generating html file..."
1555 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
1556 echo "done, see $TRACE/dmtrace.html for details"
1558 echo " traceview $TRACE/dmtrace"
1561 # communicate with a running device or emulator, set up necessary state,
1562 # and run the hat command.
1565 # process standard adb options
1567 if [ "$1" = "-d" -o "$1" = "-e" ]; then
1570 elif [ "$1" = "-s" ]; then
1574 local adbOptions=${adbTarget}
1575 #echo adbOptions = ${adbOptions}
1580 if [ "$targetPid" = "" ]; then
1581 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
1585 # confirm hat is available
1586 if [ -z $(which hat) ]; then
1587 echo "hat is not available in this configuration."
1591 # issue "am" command to cause the hprof dump
1592 local devFile=/data/local/tmp/hprof-$targetPid
1593 echo "Poking $targetPid and waiting for data..."
1594 echo "Storing data at $devFile"
1595 adb ${adbOptions} shell am dumpheap $targetPid $devFile
1596 echo "Press enter when logcat shows \"hprof: heap dump completed\""
1600 local localFile=/tmp/$$-hprof
1602 echo "Retrieving file $devFile..."
1603 adb ${adbOptions} pull $devFile $localFile
1605 adb ${adbOptions} shell rm $devFile
1607 echo "Running hat on $localFile"
1608 echo "View the output by pointing your browser at http://localhost:7000/"
1610 hat -JXmx512m $localFile
1613 function getbugreports()
1615 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
1617 if [ ! "$reports" ]; then
1618 echo "Could not locate any bugreports."
1623 for report in ${reports[@]}
1625 echo "/sdcard/bugreports/${report}"
1626 adb pull /sdcard/bugreports/${report} ${report}
1631 function getsdcardpath()
1633 adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
1636 function getscreenshotpath()
1638 echo "$(getsdcardpath)/Pictures/Screenshots"
1641 function getlastscreenshot()
1643 local screenshot_path=$(getscreenshotpath)
1644 local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
1645 if [ "$screenshot" = "" ]; then
1646 echo "No screenshots found."
1649 echo "${screenshot}"
1650 adb ${adbOptions} pull ${screenshot_path}/${screenshot}
1653 function startviewserver()
1656 if [ $# -gt 0 ]; then
1659 adb shell service call window 1 i32 $port
1662 function stopviewserver()
1664 adb shell service call window 2
1667 function isviewserverstarted()
1669 adb shell service call window 3
1674 adb shell input keyevent 3
1679 adb shell input keyevent 4
1684 adb shell input keyevent 82
1687 function smoketest()
1689 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
1690 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1695 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1699 (\cd "$T" && mmm tests/SmokeTest) &&
1700 adb uninstall com.android.smoketest > /dev/null &&
1701 adb uninstall com.android.smoketest.tests > /dev/null &&
1702 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1703 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1704 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1707 # simple shortcut to the runtest command
1712 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1715 ("$T"/development/testrunner/runtest.py $@)
1719 if [[ -z "$1" ]]; then
1720 echo "Usage: godir <regex>"
1724 if [ ! "$OUT_DIR" = "" ]; then
1726 FILELIST=$OUT_DIR/filelist
1728 FILELIST=$T/filelist
1730 if [[ ! -f $FILELIST ]]; then
1731 echo -n "Creating index..."
1732 (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST)
1737 lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq))
1738 if [[ ${#lines[@]} = 0 ]]; then
1744 if [[ ${#lines[@]} > 1 ]]; then
1745 while [[ -z "$pathname" ]]; do
1748 for line in ${lines[@]}; do
1749 printf "%6s %s\n" "[$index]" $line
1750 index=$(($index + 1))
1753 echo -n "Select one: "
1756 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1757 echo "Invalid choice"
1760 pathname=${lines[$(($choice-1))]}
1763 pathname=${lines[0]}
1770 if ! git rev-parse --git-dir &> /dev/null
1772 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
1775 git remote rm cmremote 2> /dev/null
1776 GERRIT_REMOTE=$(git config --get remote.github.projectname)
1777 CMUSER=$(git config --get review.review.cyanogenmod.org.username)
1780 git remote add cmremote ssh://review.cyanogenmod.org:29418/$GERRIT_REMOTE
1782 git remote add cmremote ssh://$CMUSER@review.cyanogenmod.org:29418/$GERRIT_REMOTE
1784 echo "Remote 'cmremote' created"
1787 function aospremote()
1789 if ! git rev-parse --git-dir &> /dev/null
1791 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
1794 git remote rm aosp 2> /dev/null
1795 PROJECT=$(pwd -P | sed "s#$ANDROID_BUILD_TOP\/##")
1796 if (echo $PROJECT | grep -qv "^device")
1800 git remote add aosp https://android.googlesource.com/$PFX$PROJECT
1801 echo "Remote 'aosp' created"
1804 function cafremote()
1806 if ! git rev-parse --git-dir &> /dev/null
1808 echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
1811 git remote rm caf 2> /dev/null
1812 PROJECT=$(pwd -P | sed "s#$ANDROID_BUILD_TOP\/##")
1813 if (echo $PROJECT | grep -qv "^device")
1817 git remote add caf git://codeaurora.org/$PFX$PROJECT
1818 echo "Remote 'caf' created"
1821 function installboot()
1823 if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ];
1825 echo "No recovery.fstab found. Build recovery first."
1828 if [ ! -e "$OUT/boot.img" ];
1830 echo "No boot.img found. Run make bootimage first."
1833 PARTITION=`grep "^\/boot" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}`
1834 if [ -z "$PARTITION" ];
1836 # Try for RECOVERY_FSTAB_VERSION = 2
1837 PARTITION=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}`
1838 PARTITION_TYPE=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}`
1839 if [ -z "$PARTITION" ];
1841 echo "Unable to determine boot partition."
1849 adb wait-for-online shell mount /system 2>&1 > /dev/null
1850 adb wait-for-online remount
1851 if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD");
1853 adb push $OUT/boot.img /cache/
1854 for i in $OUT/system/lib/modules/*;
1856 adb push $i /system/lib/modules/
1858 adb shell dd if=/cache/boot.img of=$PARTITION
1859 adb shell chmod 644 /system/lib/modules/*
1860 echo "Installation complete."
1862 echo "The connected device does not appear to be $CM_BUILD, run away!"
1866 function installrecovery()
1868 if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ];
1870 echo "No recovery.fstab found. Build recovery first."
1873 if [ ! -e "$OUT/recovery.img" ];
1875 echo "No recovery.img found. Run make recoveryimage first."
1878 PARTITION=`grep "^\/recovery" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}`
1879 if [ -z "$PARTITION" ];
1881 # Try for RECOVERY_FSTAB_VERSION = 2
1882 PARTITION=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}`
1883 PARTITION_TYPE=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}`
1884 if [ -z "$PARTITION" ];
1886 echo "Unable to determine recovery partition."
1894 adb wait-for-online shell mount /system 2>&1 >> /dev/null
1895 adb wait-for-online remount
1896 if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD");
1898 adb push $OUT/recovery.img /cache/
1899 adb shell dd if=/cache/recovery.img of=$PARTITION
1900 echo "Installation complete."
1902 echo "The connected device does not appear to be $CM_BUILD, run away!"
1906 function makerecipe() {
1909 echo "No branch name provided."
1913 sed -i s/'default revision=.*'/'default revision="refs\/heads\/'$1'"'/ default.xml
1914 git commit -a -m "$1"
1919 if [ "$REPO_REMOTE" = "github" ]
1923 git push cmremote HEAD:refs/heads/'$1'
1928 function cmgerrit() {
1930 if [ "$(__detect_shell)" = "zsh" ]; then
1931 # zsh does not define FUNCNAME, derive from funcstack
1932 local FUNCNAME=$funcstack[1]
1935 if [ $# -eq 0 ]; then
1939 local user=`git config --get review.review.cyanogenmod.org.username`
1940 local review=`git config --get remote.github.review`
1941 local project=`git config --get remote.github.projectname`
1946 if [ $# -eq 0 ]; then
1949 $FUNCNAME COMMAND [OPTIONS] [CHANGE-ID[/PATCH-SET]][{@|^|~|:}ARG] [-- ARGS]
1952 fetch Just fetch the change as FETCH_HEAD
1953 help Show this help, or for a specific command
1954 pull Pull a change into current branch
1955 push Push HEAD or a local branch to Gerrit for a specific branch
1957 Any other Git commands that support refname would work as:
1958 git fetch URL CHANGE && git COMMAND OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
1960 See '$FUNCNAME help COMMAND' for more information on a specific command.
1963 $FUNCNAME checkout -b topic 1234/5
1965 git fetch http://DOMAIN/p/PROJECT refs/changes/34/1234/5 \\
1966 && git checkout -b topic FETCH_HEAD
1967 will checkout a new branch 'topic' base on patch-set 5 of change 1234.
1968 Patch-set 1 will be fetched if omitted.
1973 __cmg_*) echo "For internal use only." ;;
1975 if [ "$FUNCNAME" = "cmgerrit" ]; then
1976 echo "'$FUNCNAME $1' is deprecated."
1979 help) $FUNCNAME help ;;
1980 fetch|pull) cat <<EOF
1981 usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET]
1984 git $1 OPTIONS http://DOMAIN/p/PROJECT \\
1985 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1}
1989 will $1 patch-set 1 of change 1234
1993 usage: $FUNCNAME push [OPTIONS] [LOCAL_BRANCH:]REMOTE_BRANCH
1996 git push OPTIONS ssh://USER@DOMAIN:29418/PROJECT \\
1997 {LOCAL_BRANCH|HEAD}:refs/for/REMOTE_BRANCH
2000 $FUNCNAME push fix6789:gingerbread
2001 will push local branch 'fix6789' to Gerrit for branch 'gingerbread'.
2002 HEAD will be pushed from local if omitted.
2006 $FUNCNAME __cmg_err_not_supported $1 && return
2008 usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET][{@|^|~|:}ARG] [-- ARGS]
2011 git fetch http://DOMAIN/p/PROJECT \\
2012 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1} \\
2013 && git $1 OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
2019 $FUNCNAME __cmg_err_no_arg $command $# && return 1
2020 local change_id patchset_id hash
2031 hash=$(($change_id % 100))
2033 [0-9]) hash="0$hash" ;;
2035 echo "refs/changes/$hash/$change_id/$patchset_id"
2038 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
2039 $FUNCNAME __cmg_err_not_repo && return 1
2042 git $command $@ http://$review/p/$project \
2043 $($FUNCNAME __cmg_get_ref $change) || return 1
2046 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
2047 $FUNCNAME __cmg_err_not_repo && return 1
2048 if [ -z "$user" ]; then
2049 echo >&2 "Gerrit username not found."
2052 local local_branch remote_branch
2055 local_branch=${1%:*}
2056 remote_branch=${1##*:}
2064 git push $@ ssh://$user@$review:29418/$project \
2065 $local_branch:refs/for/$remote_branch || return 1
2068 if [ "$FUNCNAME" = "cmgerrit" ]; then
2069 echo >&2 "'$FUNCNAME $command' is deprecated."
2073 if [ $# -lt 2 ]; then
2074 echo >&2 "'$FUNCNAME $command' missing argument."
2075 elif [ $2 -eq 0 ]; then
2076 if [ -n "$3" ]; then
2079 echo >&2 "'$FUNCNAME $1' missing argument."
2086 if [ -z "$review" -o -z "$project" ]; then
2087 echo >&2 "Not currently in any reviewable repository."
2092 __cmg_err_not_supported)
2093 $FUNCNAME __cmg_err_no_arg $command $# && return
2095 #TODO: filter more git commands that don't use refname
2096 init|add|rm|mv|status|clone|remote|bisect|config|stash)
2097 echo >&2 "'$FUNCNAME $1' is not supported."
2102 #TODO: other special cases?
2104 $FUNCNAME __cmg_err_not_supported $command && return 1
2105 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
2106 $FUNCNAME __cmg_err_not_repo && return 1
2108 local change pre_args refs_arg post_args
2111 pre_args=${args%%-- *}
2112 post_args="-- ${args#*-- }"
2114 *) pre_args="$args" ;;
2118 if [ ${#args[@]} -gt 0 ]; then
2119 change=${args[${#args[@]}-1]}
2121 if [ ${#args[@]} -gt 1 ]; then
2123 for ((i=1; i<${#args[@]}-1; i++)); do
2124 pre_args="$pre_args ${args[$i]}"
2130 $FUNCNAME help $command
2134 if [ -z "$refs_arg" ]; then
2135 refs_arg="@${change#*@}"
2136 change=${change%%@*}
2140 if [ -z "$refs_arg" ]; then
2141 refs_arg="~${change#*~}"
2142 change=${change%%~*}
2146 if [ -z "$refs_arg" ]; then
2147 refs_arg="^${change#*^}"
2148 change=${change%%^*}
2152 if [ -z "$refs_arg" ]; then
2153 refs_arg=":${change#*:}"
2154 change=${change%%:*}
2160 $FUNCNAME fetch $change \
2161 && git $command $pre_args FETCH_HEAD$refs_arg $post_args \
2167 function cmrebase() {
2171 local dir="$(gettop)/$repo"
2173 if [ -z $repo ] || [ -z $refs ]; then
2174 echo "CyanogenMod Gerrit Rebase Usage: "
2175 echo " cmrebase <path to project> <patch IDs on Gerrit>"
2176 echo " The patch IDs appear on the Gerrit commands that are offered."
2177 echo " They consist on a series of numbers and slashes, after the text"
2178 echo " refs/changes. For example, the ID in the following command is 26/8126/2"
2180 echo " git[...]ges_apps_Camera refs/changes/26/8126/2 && git cherry-pick FETCH_HEAD"
2185 if [ ! -d $dir ]; then
2186 echo "Directory $dir doesn't exist in tree."
2190 repo=$(cat .git/config | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g)
2191 echo "Starting branch..."
2192 repo start tmprebase .
2193 echo "Bringing it up to date..."
2195 echo "Fetching change..."
2196 git fetch "http://review.cyanogenmod.org/p/$repo" "refs/changes/$refs" && git cherry-pick FETCH_HEAD
2197 if [ "$?" != "0" ]; then
2198 echo "Error cherry-picking. Not uploading!"
2203 echo "Cleaning up..."
2204 repo abandon tmprebase .
2213 make -C $T -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
2216 mk_timer schedtool -B -n 1 -e ionice -n 1 make -C $T -j$(cat /proc/cpuinfo | grep "^processor" | wc -l) "$@"
2221 echo "Couldn't locate the top of the tree. Try setting TOP."
2226 if [ ! -z "$1" ]; then
2229 bacon|otapackage|systemimage)
2249 echo "Couldn't locate the top of the tree. Try setting TOP."
2255 local NUM_CPUS=$(sysctl hw.ncpu|cut -d" " -f2)
2256 ONE_SHOT_MAKEFILE="__none__" \
2257 make -C $T -j $NUM_CPUS "$@"
2260 local NUM_CPUS=$(cat /proc/cpuinfo | grep "^processor" | wc -l)
2261 ONE_SHOT_MAKEFILE="__none__" \
2262 mk_timer schedtool -B -n 1 -e ionice -n 1 \
2263 make -C $T -j $NUM_CPUS "$@"
2269 function repolastsync() {
2270 RLSPATH="$ANDROID_BUILD_TOP/.repo/.repo_fetchtimes.json"
2271 RLSLOCAL=$(date -d "$(stat -c %z $RLSPATH)" +"%e %b %Y, %T %Z")
2272 RLSUTC=$(date -d "$(stat -c %z $RLSPATH)" -u +"%e %b %Y, %T %Z")
2273 echo "Last repo sync: $RLSLOCAL / $RLSUTC"
2276 function reposync() {
2282 schedtool -B -n 1 -e ionice -n 1 `which repo` sync -j 4 "$@"
2287 function repodiff() {
2288 if [ -z "$*" ]; then
2289 echo "Usage: repodiff <ref-from> [[ref-to] [--numstat]]"
2292 diffopts=$* repo forall -c \
2293 'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;'
2296 # Return success if adb is up and not in recovery
2297 function _adb_connected {
2299 if [[ "$(adb get-state)" == device &&
2300 "$(adb shell test -e /sbin/recovery; echo $?)" == 0 ]]
2309 # Credit for color strip sed: http://goo.gl/BoIcm
2315 adb start-server # Prevent unexpected starting server message from adb get-state in the next line
2316 if ! _adb_connected; then
2317 echo "No device is online. Waiting for one..."
2318 echo "Please connect USB and/or enable USB debugging"
2319 until _adb_connected; do
2322 echo "Device Found."
2325 if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" = "true" ];
2327 # retrieve IP and PORT info if we're using a TCP connection
2328 TCPIPPORT=$(adb devices | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \
2329 | head -1 | awk '{print $1}')
2330 adb root &> /dev/null
2332 if [ -n "$TCPIPPORT" ]
2334 # adb root just killed our connection
2336 adb connect "$TCPIPPORT"
2338 adb wait-for-device &> /dev/null
2340 adb remount &> /dev/null
2343 ($func $*|tee $OUT/.log;return ${PIPESTATUS[0]})
2345 if [ $ret -ne 0 ]; then
2346 rm -f $OUT/.log;return $ret
2350 if [ `uname` = "Linux" ]; then
2351 LOC="$(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Install: ' | cut -d ':' -f 2)"
2353 LOC="$(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Install: ' | cut -d ':' -f 2)"
2357 if [ `uname` = "Linux" ]; then
2358 LOC="$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Copy: ' | cut -d ':' -f 2)"
2360 LOC="$LOC $(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Copy: ' | cut -d ':' -f 2)"
2363 # If any files are going to /data, push an octal file permissions reader to device
2364 if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then
2365 CHKPERM="/data/local/tmp/chkfileperm.sh"
2370 if [ -e $FILE ]; then
2371 ls -l $FILE | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' | cut -d ' ' -f1
2374 ) > $OUT/.chkfileperm.sh
2375 echo "Pushing file permissions checker to device"
2376 adb push $OUT/.chkfileperm.sh $CHKPERM
2377 adb shell chmod 755 $CHKPERM
2378 rm -f $OUT/.chkfileperm.sh
2382 for FILE in $(echo $LOC | tr " " "\n"); do
2383 # Make sure file is in $OUT/system or $OUT/data
2385 $OUT/system/*|$OUT/data/*)
2386 # Get target file name (i.e. /system/bin/adb)
2387 TARGET=$(echo $FILE | sed "s#$OUT##")
2394 # fs_config only sets permissions and se labels for files pushed to /system
2395 if [ -n "$CHKPERM" ]; then
2396 OLDPERM=$(adb shell $CHKPERM $TARGET)
2397 OLDPERM=$(echo $OLDPERM | tr -d '\r' | tr -d '\n')
2398 OLDOWN=$(adb shell ls -al $TARGET | awk '{print $2}')
2399 OLDGRP=$(adb shell ls -al $TARGET | awk '{print $3}')
2401 echo "Pushing: $TARGET"
2402 adb push $FILE $TARGET
2403 if [ -n "$OLDPERM" ]; then
2404 echo "Setting file permissions: $OLDPERM, $OLDOWN":"$OLDGRP"
2405 adb shell chown "$OLDOWN":"$OLDGRP" $TARGET
2406 adb shell chmod "$OLDPERM" $TARGET
2408 echo "$TARGET did not exist previously, you should set file permissions manually"
2410 adb shell restorecon "$TARGET"
2412 /system/priv-app/SystemUI/SystemUI.apk|/system/framework/*)
2413 # Only need to stop services once
2414 if ! $stop_n_start; then
2418 echo "Pushing: $TARGET"
2419 adb push $FILE $TARGET
2422 echo "Pushing: $TARGET"
2423 adb push $FILE $TARGET
2427 if [ -n "$CHKPERM" ]; then
2428 adb shell rm $CHKPERM
2430 if $stop_n_start; then
2436 echo "The connected device does not appear to be $CM_BUILD, run away!"
2440 alias mmp='dopush mm'
2441 alias mmmp='dopush mmm'
2442 alias mmap='dopush mma'
2443 alias mkap='dopush mka'
2444 alias cmkap='dopush cmka'
2446 function repopick() {
2448 $T/build/tools/repopick.py $@
2451 function fixup_common_out_dir() {
2452 common_out_dir=$(get_build_var OUT_DIR)/target/common
2453 target_device=$(get_build_var TARGET_DEVICE)
2454 if [ ! -z $CM_FIXUP_COMMON_OUT ]; then
2455 if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then
2456 mv ${common_out_dir} ${common_out_dir}-${target_device}
2457 ln -s ${common_out_dir}-${target_device} ${common_out_dir}
2459 [ -L ${common_out_dir} ] && rm ${common_out_dir}
2460 mkdir -p ${common_out_dir}-${target_device}
2461 ln -s ${common_out_dir}-${target_device} ${common_out_dir}
2464 [ -L ${common_out_dir} ] && rm ${common_out_dir}
2465 mkdir -p ${common_out_dir}
2469 # Force JAVA_HOME to point to java 1.7/1.8 if it isn't already set.
2470 function set_java_home() {
2471 # Clear the existing JAVA_HOME value if we set it ourselves, so that
2472 # we can reset it later, depending on the version of java the build
2475 # If we don't do this, the JAVA_HOME value set by the first call to
2476 # build/envsetup.sh will persist forever.
2477 if [ -n "$ANDROID_SET_JAVA_HOME" ]; then
2481 if [ ! "$JAVA_HOME" ]; then
2482 if [ -n "$LEGACY_USE_JAVA7" ]; then
2483 echo Warning: Support for JDK 7 will be dropped. Switch to JDK 8.
2486 export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
2489 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
2495 export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
2498 export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
2503 # Keep track of the fact that we set JAVA_HOME ourselves, so that
2504 # we can change it on the next envsetup.sh, if required.
2505 export ANDROID_SET_JAVA_HOME=true
2509 # Print colored exit condition
2513 if [ $retval -ne 0 ]
2515 echo $'\E'"[0;31mFAILURE\e[00m"
2517 echo $'\E'"[0;32mSUCCESS\e[00m"
2522 function get_make_command()
2529 local start_time=$(date +"%s")
2532 local end_time=$(date +"%s")
2533 local tdiff=$(($end_time-$start_time))
2534 local hours=$(($tdiff / 3600 ))
2535 local mins=$((($tdiff % 3600) / 60))
2536 local secs=$(($tdiff % 60))
2537 local ncolors=$(tput colors 2>/dev/null)
2538 if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
2539 color_failed=$'\E'"[0;31m"
2540 color_success=$'\E'"[0;32m"
2541 color_reset=$'\E'"[00m"
2548 if [ $ret -eq 0 ] ; then
2549 echo -n "${color_success}#### make completed successfully "
2551 echo -n "${color_failed}#### make failed to build some targets "
2553 if [ $hours -gt 0 ] ; then
2554 printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
2555 elif [ $mins -gt 0 ] ; then
2556 printf "(%02g:%02g (mm:ss))" $mins $secs
2557 elif [ $secs -gt 0 ] ; then
2558 printf "(%s seconds)" $secs
2560 echo " ####${color_reset}"
2565 function provision()
2567 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
2568 echo "Couldn't locate output files. Try running 'lunch' first." >&2
2571 if [ ! -e "$ANDROID_PRODUCT_OUT/provision-device" ]; then
2572 echo "There is no provisioning script for the device." >&2
2576 # Check if user really wants to do this.
2577 if [ "$1" = "--no-confirmation" ]; then
2580 echo "This action will reflash your device."
2582 echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED."
2584 echo -n "Are you sure you want to do this (yes/no)? "
2586 if [[ "${REPLY}" != "yes" ]] ; then
2587 echo "Not taking any action. Exiting." >&2
2591 "$ANDROID_PRODUCT_OUT/provision-device" "$@"
2596 mk_timer $(get_make_command) "$@"
2599 function __detect_shell() {
2600 case `ps -o command -p $$` in
2616 if ! __detect_shell > /dev/null; then
2617 echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results"
2620 # Execute the contents of any vendorsetup.sh files we can find.
2621 for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
2622 `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
2623 `test -d product && find -L product -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
2631 check_bash_version && {
2632 dirs="sdk/bash_completion vendor/cm/bash_completion"
2633 for dir in $dirs; do
2634 if [ -d ${dir} ]; then
2635 for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
2643 export ANDROID_BUILD_TOP=$(gettop)