Scott Anderson | 1a5fc95 | 2012-03-07 17:15:06 -0800 | [diff] [blame] | 1 | function hmm() { |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2 | cat <<EOF |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 3 | Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment: |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 4 | - lunch: lunch <product_name>-<build_variant> |
Ying Wang | f05c4f7 | 2013-01-31 11:16:57 -0800 | [diff] [blame] | 5 | - tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6 | - croot: Changes directory to the top of the tree. |
| 7 | - m: Makes from the top of the tree. |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 8 | - mm: Builds all of the modules in the current directory, but not their dependencies. |
| 9 | - mmm: Builds all of the modules in the supplied directories, but not their dependencies. |
| 10 | - mma: Builds all of the modules in the current directory, and their dependencies. |
| 11 | - mmma: Builds all of the modules in the supplied directories, and their dependencies. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 12 | - cgrep: Greps on all local C/C++ files. |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame^] | 13 | - ggrep: Greps on all local Gradle files. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 14 | - jgrep: Greps on all local Java files. |
| 15 | - resgrep: Greps on all local res/*.xml files. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 16 | - godir: Go to the directory containing a file. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 17 | |
| 18 | Look at the source to view more functions. The complete list is: |
| 19 | EOF |
| 20 | T=$(gettop) |
| 21 | local A |
| 22 | A="" |
| 23 | for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do |
| 24 | A="$A $i" |
| 25 | done |
| 26 | echo $A |
| 27 | } |
| 28 | |
| 29 | # Get the value of a build variable as an absolute path. |
| 30 | function get_abs_build_var() |
| 31 | { |
| 32 | T=$(gettop) |
| 33 | if [ ! "$T" ]; then |
| 34 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 35 | return |
| 36 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 37 | (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
Brian Carlstrom | 177285a | 2010-04-06 13:22:02 -0700 | [diff] [blame] | 38 | make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | # Get the exact value of a build variable. |
| 42 | function get_build_var() |
| 43 | { |
| 44 | T=$(gettop) |
| 45 | if [ ! "$T" ]; then |
| 46 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 47 | return |
| 48 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 49 | CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
| 50 | make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-$1 |
| 51 | } |
| 52 | |
| 53 | # check to see if the supplied product is one we can build |
| 54 | function check_product() |
| 55 | { |
| 56 | T=$(gettop) |
| 57 | if [ ! "$T" ]; then |
| 58 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 59 | return |
| 60 | fi |
| 61 | CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 62 | TARGET_PRODUCT=$1 \ |
| 63 | TARGET_BUILD_VARIANT= \ |
| 64 | TARGET_BUILD_TYPE= \ |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 65 | TARGET_BUILD_APPS= \ |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 66 | get_build_var TARGET_DEVICE > /dev/null |
| 67 | # hide successful answers, but allow the errors to show |
| 68 | } |
| 69 | |
| 70 | VARIANT_CHOICES=(user userdebug eng) |
| 71 | |
| 72 | # check to see if the supplied variant is valid |
| 73 | function check_variant() |
| 74 | { |
| 75 | for v in ${VARIANT_CHOICES[@]} |
| 76 | do |
| 77 | if [ "$v" = "$1" ] |
| 78 | then |
| 79 | return 0 |
| 80 | fi |
| 81 | done |
| 82 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | function setpaths() |
| 86 | { |
| 87 | T=$(gettop) |
| 88 | if [ ! "$T" ]; then |
| 89 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 90 | return |
| 91 | fi |
| 92 | |
| 93 | ################################################################## |
| 94 | # # |
| 95 | # Read me before you modify this code # |
| 96 | # # |
| 97 | # This function sets ANDROID_BUILD_PATHS to what it is adding # |
| 98 | # to PATH, and the next time it is run, it removes that from # |
| 99 | # PATH. This is required so lunch can be run more than once # |
| 100 | # and still have working paths. # |
| 101 | # # |
| 102 | ################################################################## |
| 103 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 104 | # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces |
| 105 | # due to "C:\Program Files" being in the path. |
| 106 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 107 | # out with the old |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 108 | if [ -n "$ANDROID_BUILD_PATHS" ] ; then |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 109 | export PATH=${PATH/$ANDROID_BUILD_PATHS/} |
| 110 | fi |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 111 | if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 112 | export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/} |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 113 | # strip leading ':', if any |
| 114 | export PATH=${PATH/:%/} |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 115 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 116 | |
| 117 | # and in with the new |
| 118 | CODE_REVIEWS= |
| 119 | prebuiltdir=$(getprebuilt) |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 120 | gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS) |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 121 | |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 122 | # defined in core/config.mk |
| 123 | targetgccversion=$(get_build_var TARGET_GCC_VERSION) |
Ben Cheng | 1526670 | 2012-12-10 16:04:39 -0800 | [diff] [blame] | 124 | export TARGET_GCC_VERSION=$targetgccversion |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 125 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 126 | # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it. |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 127 | export ANDROID_EABI_TOOLCHAIN= |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 128 | local ARCH=$(get_build_var TARGET_ARCH) |
| 129 | case $ARCH in |
Ben Cheng | 054ffd2 | 2012-12-11 14:01:10 -0800 | [diff] [blame] | 130 | x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 131 | ;; |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 132 | arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 133 | ;; |
Ben Cheng | 054ffd2 | 2012-12-11 14:01:10 -0800 | [diff] [blame] | 134 | mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 135 | ;; |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 136 | *) |
| 137 | echo "Can't find toolchain for unknown architecture: $ARCH" |
| 138 | toolchaindir=xxxxxxxxx |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 139 | ;; |
| 140 | esac |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 141 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
| 142 | export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 143 | fi |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 144 | |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 145 | unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 146 | case $ARCH in |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 147 | arm) |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 148 | toolchaindir=arm/arm-eabi-$targetgccversion/bin |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 149 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
| 150 | export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir" |
| 151 | ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir" |
| 152 | fi |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 153 | ;; |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 154 | mips) toolchaindir=mips/mips-eabi-4.4.3/bin |
| 155 | ;; |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 156 | *) |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 157 | # No need to set ARM_EABI_TOOLCHAIN for other ARCHs |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 158 | ;; |
| 159 | esac |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 160 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 161 | export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN |
| 162 | export ANDROID_QTOOLS=$T/development/emulator/qtools |
Ying Wang | 564f912 | 2013-03-29 17:40:14 -0700 | [diff] [blame] | 163 | export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 164 | export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN$ARM_EABI_TOOLCHAIN_PATH$CODE_REVIEWS:$ANDROID_DEV_SCRIPTS: |
| 165 | export PATH=$ANDROID_BUILD_PATHS$PATH |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 166 | |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 167 | unset ANDROID_JAVA_TOOLCHAIN |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 168 | unset ANDROID_PRE_BUILD_PATHS |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 169 | if [ -n "$JAVA_HOME" ]; then |
| 170 | export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 171 | export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN: |
| 172 | export PATH=$ANDROID_PRE_BUILD_PATHS$PATH |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 173 | fi |
| 174 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 175 | unset ANDROID_PRODUCT_OUT |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 176 | export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT) |
| 177 | export OUT=$ANDROID_PRODUCT_OUT |
| 178 | |
Jeff Brown | 8fd5cce | 2011-03-24 17:03:06 -0700 | [diff] [blame] | 179 | unset ANDROID_HOST_OUT |
| 180 | export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT) |
| 181 | |
Ben Cheng | 057fde1 | 2011-11-28 13:55:14 -0800 | [diff] [blame] | 182 | # needed for processing samples collected by perf counters |
| 183 | unset OPROFILE_EVENTS_DIR |
| 184 | export OPROFILE_EVENTS_DIR=$T/external/oprofile/events |
| 185 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 186 | # needed for building linux on MacOS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 187 | # TODO: fix the path |
| 188 | #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include |
| 189 | } |
| 190 | |
| 191 | function printconfig() |
| 192 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 193 | T=$(gettop) |
| 194 | if [ ! "$T" ]; then |
| 195 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 196 | return |
| 197 | fi |
| 198 | get_build_var report_config |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | function set_stuff_for_environment() |
| 202 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 203 | settitle |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 204 | set_java_home |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 205 | setpaths |
| 206 | set_sequence_number |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 207 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 208 | export ANDROID_BUILD_TOP=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | function set_sequence_number() |
| 212 | { |
Joe Onorato | aee4daa | 2010-06-23 14:03:13 -0700 | [diff] [blame] | 213 | export BUILD_ENV_SEQUENCE_NUMBER=10 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | function settitle() |
| 217 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 218 | if [ "$STAY_OFF_MY_LAWN" = "" ]; then |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 219 | local arch=$(gettargetarch) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 220 | local product=$TARGET_PRODUCT |
| 221 | local variant=$TARGET_BUILD_VARIANT |
| 222 | local apps=$TARGET_BUILD_APPS |
| 223 | if [ -z "$apps" ]; then |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 224 | export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\"" |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 225 | else |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 226 | export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\"" |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 227 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 228 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 231 | function addcompletions() |
| 232 | { |
| 233 | local T dir f |
| 234 | |
| 235 | # Keep us from trying to run in something that isn't bash. |
| 236 | if [ -z "${BASH_VERSION}" ]; then |
| 237 | return |
| 238 | fi |
| 239 | |
| 240 | # Keep us from trying to run in bash that's too old. |
| 241 | if [ ${BASH_VERSINFO[0]} -lt 3 ]; then |
| 242 | return |
| 243 | fi |
| 244 | |
| 245 | dir="sdk/bash_completion" |
| 246 | if [ -d ${dir} ]; then |
Kenny Root | 7546d61 | 2011-07-18 13:11:34 -0700 | [diff] [blame] | 247 | for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 248 | echo "including $f" |
| 249 | . $f |
| 250 | done |
| 251 | fi |
| 252 | } |
| 253 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 254 | function choosetype() |
| 255 | { |
| 256 | echo "Build type choices are:" |
| 257 | echo " 1. release" |
| 258 | echo " 2. debug" |
| 259 | echo |
| 260 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 261 | local DEFAULT_NUM DEFAULT_VALUE |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 262 | DEFAULT_NUM=1 |
| 263 | DEFAULT_VALUE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 264 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 265 | export TARGET_BUILD_TYPE= |
| 266 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 267 | while [ -z $TARGET_BUILD_TYPE ] |
| 268 | do |
| 269 | echo -n "Which would you like? ["$DEFAULT_NUM"] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 270 | if [ -z "$1" ] ; then |
| 271 | read ANSWER |
| 272 | else |
| 273 | echo $1 |
| 274 | ANSWER=$1 |
| 275 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 276 | case $ANSWER in |
| 277 | "") |
| 278 | export TARGET_BUILD_TYPE=$DEFAULT_VALUE |
| 279 | ;; |
| 280 | 1) |
| 281 | export TARGET_BUILD_TYPE=release |
| 282 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 283 | release) |
| 284 | export TARGET_BUILD_TYPE=release |
| 285 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 286 | 2) |
| 287 | export TARGET_BUILD_TYPE=debug |
| 288 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 289 | debug) |
| 290 | export TARGET_BUILD_TYPE=debug |
| 291 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 292 | *) |
| 293 | echo |
| 294 | echo "I didn't understand your response. Please try again." |
| 295 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 296 | ;; |
| 297 | esac |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 298 | if [ -n "$1" ] ; then |
| 299 | break |
| 300 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 301 | done |
| 302 | |
| 303 | set_stuff_for_environment |
| 304 | } |
| 305 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 306 | # |
| 307 | # This function isn't really right: It chooses a TARGET_PRODUCT |
| 308 | # based on the list of boards. Usually, that gets you something |
| 309 | # that kinda works with a generic product, but really, you should |
| 310 | # pick a product by name. |
| 311 | # |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 312 | function chooseproduct() |
| 313 | { |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 314 | if [ "x$TARGET_PRODUCT" != x ] ; then |
| 315 | default_value=$TARGET_PRODUCT |
| 316 | else |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 317 | default_value=full |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 318 | fi |
| 319 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 320 | export TARGET_PRODUCT= |
| 321 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 322 | while [ -z "$TARGET_PRODUCT" ] |
| 323 | do |
Joe Onorato | 8849aed | 2009-04-29 15:56:47 -0700 | [diff] [blame] | 324 | echo -n "Which product would you like? [$default_value] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 325 | if [ -z "$1" ] ; then |
| 326 | read ANSWER |
| 327 | else |
| 328 | echo $1 |
| 329 | ANSWER=$1 |
| 330 | fi |
| 331 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 332 | if [ -z "$ANSWER" ] ; then |
| 333 | export TARGET_PRODUCT=$default_value |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 334 | else |
| 335 | if check_product $ANSWER |
| 336 | then |
| 337 | export TARGET_PRODUCT=$ANSWER |
| 338 | else |
| 339 | echo "** Not a valid product: $ANSWER" |
| 340 | fi |
| 341 | fi |
| 342 | if [ -n "$1" ] ; then |
| 343 | break |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 344 | fi |
| 345 | done |
| 346 | |
| 347 | set_stuff_for_environment |
| 348 | } |
| 349 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 350 | function choosevariant() |
| 351 | { |
| 352 | echo "Variant choices are:" |
| 353 | local index=1 |
| 354 | local v |
| 355 | for v in ${VARIANT_CHOICES[@]} |
| 356 | do |
| 357 | # The product name is the name of the directory containing |
| 358 | # the makefile we found, above. |
| 359 | echo " $index. $v" |
| 360 | index=$(($index+1)) |
| 361 | done |
| 362 | |
| 363 | local default_value=eng |
| 364 | local ANSWER |
| 365 | |
| 366 | export TARGET_BUILD_VARIANT= |
| 367 | while [ -z "$TARGET_BUILD_VARIANT" ] |
| 368 | do |
| 369 | echo -n "Which would you like? [$default_value] " |
| 370 | if [ -z "$1" ] ; then |
| 371 | read ANSWER |
| 372 | else |
| 373 | echo $1 |
| 374 | ANSWER=$1 |
| 375 | fi |
| 376 | |
| 377 | if [ -z "$ANSWER" ] ; then |
| 378 | export TARGET_BUILD_VARIANT=$default_value |
| 379 | elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then |
| 380 | if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 381 | export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 382 | fi |
| 383 | else |
| 384 | if check_variant $ANSWER |
| 385 | then |
| 386 | export TARGET_BUILD_VARIANT=$ANSWER |
| 387 | else |
| 388 | echo "** Not a valid variant: $ANSWER" |
| 389 | fi |
| 390 | fi |
| 391 | if [ -n "$1" ] ; then |
| 392 | break |
| 393 | fi |
| 394 | done |
| 395 | } |
| 396 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 397 | function choosecombo() |
| 398 | { |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 399 | choosetype $1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 400 | |
| 401 | echo |
| 402 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 403 | chooseproduct $2 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 404 | |
| 405 | echo |
| 406 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 407 | choosevariant $3 |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 408 | |
| 409 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 410 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 411 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 412 | } |
| 413 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 414 | # Clear this variable. It will be built up again when the vendorsetup.sh |
| 415 | # files are included at the end of this file. |
| 416 | unset LUNCH_MENU_CHOICES |
| 417 | function add_lunch_combo() |
| 418 | { |
| 419 | local new_combo=$1 |
| 420 | local c |
| 421 | for c in ${LUNCH_MENU_CHOICES[@]} ; do |
| 422 | if [ "$new_combo" = "$c" ] ; then |
| 423 | return |
| 424 | fi |
| 425 | done |
| 426 | LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo) |
| 427 | } |
| 428 | |
| 429 | # add the default one here |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 430 | add_lunch_combo aosp_arm-eng |
| 431 | add_lunch_combo aosp_x86-eng |
| 432 | add_lunch_combo aosp_mips-eng |
Bruce Beare | ba366c4 | 2011-02-15 16:46:08 -0800 | [diff] [blame] | 433 | add_lunch_combo vbox_x86-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 434 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 435 | function print_lunch_menu() |
| 436 | { |
| 437 | local uname=$(uname) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 438 | echo |
| 439 | echo "You're building on" $uname |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 440 | echo |
| 441 | echo "Lunch menu... pick a combo:" |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 442 | |
| 443 | local i=1 |
| 444 | local choice |
| 445 | for choice in ${LUNCH_MENU_CHOICES[@]} |
| 446 | do |
| 447 | echo " $i. $choice" |
| 448 | i=$(($i+1)) |
| 449 | done |
| 450 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 451 | echo |
| 452 | } |
| 453 | |
| 454 | function lunch() |
| 455 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 456 | local answer |
| 457 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 458 | if [ "$1" ] ; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 459 | answer=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 460 | else |
| 461 | print_lunch_menu |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 462 | echo -n "Which would you like? [aosp_arm-eng] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 463 | read answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 464 | fi |
| 465 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 466 | local selection= |
| 467 | |
| 468 | if [ -z "$answer" ] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 469 | then |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 470 | selection=aosp_arm-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 471 | elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") |
| 472 | then |
| 473 | if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] |
| 474 | then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 475 | selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 476 | fi |
| 477 | elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") |
| 478 | then |
| 479 | selection=$answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 480 | fi |
| 481 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 482 | if [ -z "$selection" ] |
| 483 | then |
| 484 | echo |
| 485 | echo "Invalid lunch combo: $answer" |
| 486 | return 1 |
| 487 | fi |
| 488 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 489 | export TARGET_BUILD_APPS= |
| 490 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 491 | local product=$(echo -n $selection | sed -e "s/-.*$//") |
| 492 | check_product $product |
| 493 | if [ $? -ne 0 ] |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 494 | then |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 495 | echo |
| 496 | echo "** Don't have a product spec for: '$product'" |
| 497 | echo "** Do you have the right repo manifest?" |
| 498 | product= |
| 499 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 500 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 501 | local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//") |
| 502 | check_variant $variant |
| 503 | if [ $? -ne 0 ] |
| 504 | then |
| 505 | echo |
| 506 | echo "** Invalid variant: '$variant'" |
| 507 | echo "** Must be one of ${VARIANT_CHOICES[@]}" |
| 508 | variant= |
| 509 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 510 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 511 | if [ -z "$product" -o -z "$variant" ] |
| 512 | then |
| 513 | echo |
| 514 | return 1 |
| 515 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 516 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 517 | export TARGET_PRODUCT=$product |
| 518 | export TARGET_BUILD_VARIANT=$variant |
| 519 | export TARGET_BUILD_TYPE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 520 | |
| 521 | echo |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 522 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 523 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 524 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 525 | } |
| 526 | |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 527 | # Tab completion for lunch. |
| 528 | function _lunch() |
| 529 | { |
| 530 | local cur prev opts |
| 531 | COMPREPLY=() |
| 532 | cur="${COMP_WORDS[COMP_CWORD]}" |
| 533 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 534 | |
| 535 | COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) ) |
| 536 | return 0 |
| 537 | } |
| 538 | complete -F _lunch lunch |
| 539 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 540 | # Configures the build to build unbundled apps. |
| 541 | # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME) |
| 542 | function tapas() |
| 543 | { |
Ying Wang | f05c4f7 | 2013-01-31 11:16:57 -0800 | [diff] [blame] | 544 | local arch=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5)$')) |
Jeff Hamilton | 293f939 | 2011-11-18 17:15:25 -0600 | [diff] [blame] | 545 | local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$')) |
Ying Wang | f05c4f7 | 2013-01-31 11:16:57 -0800 | [diff] [blame] | 546 | local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5)$')) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 547 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 548 | if [ $(echo $arch | wc -w) -gt 1 ]; then |
| 549 | echo "tapas: Error: Multiple build archs supplied: $arch" |
| 550 | return |
| 551 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 552 | if [ $(echo $variant | wc -w) -gt 1 ]; then |
| 553 | echo "tapas: Error: Multiple build variants supplied: $variant" |
| 554 | return |
| 555 | fi |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 556 | |
| 557 | local product=full |
| 558 | case $arch in |
| 559 | x86) product=full_x86;; |
| 560 | mips) product=full_mips;; |
Ying Wang | f05c4f7 | 2013-01-31 11:16:57 -0800 | [diff] [blame] | 561 | armv5) product=generic_armv5;; |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 562 | esac |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 563 | if [ -z "$variant" ]; then |
| 564 | variant=eng |
| 565 | fi |
Ying Wang | c048c9b | 2010-06-24 15:08:33 -0700 | [diff] [blame] | 566 | if [ -z "$apps" ]; then |
| 567 | apps=all |
| 568 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 569 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 570 | export TARGET_PRODUCT=$product |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 571 | export TARGET_BUILD_VARIANT=$variant |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 572 | export TARGET_BUILD_TYPE=release |
| 573 | export TARGET_BUILD_APPS=$apps |
| 574 | |
| 575 | set_stuff_for_environment |
| 576 | printconfig |
| 577 | } |
| 578 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 579 | function gettop |
| 580 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 581 | local TOPFILE=build/core/envsetup.mk |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 582 | if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then |
| 583 | echo $TOP |
| 584 | else |
| 585 | if [ -f $TOPFILE ] ; then |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 586 | # The following circumlocution (repeated below as well) ensures |
| 587 | # that we record the true directory name and not one that is |
| 588 | # faked up with symlink names. |
| 589 | PWD= /bin/pwd |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 590 | else |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 591 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 592 | T= |
| 593 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 594 | \cd .. |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 595 | T=`PWD= /bin/pwd` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 596 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 597 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 598 | if [ -f "$T/$TOPFILE" ]; then |
| 599 | echo $T |
| 600 | fi |
| 601 | fi |
| 602 | fi |
| 603 | } |
| 604 | |
| 605 | function m() |
| 606 | { |
| 607 | T=$(gettop) |
| 608 | if [ "$T" ]; then |
Joe Onorato | fa72a60 | 2013-01-11 12:49:04 -0800 | [diff] [blame] | 609 | make -C $T -f build/core/main.mk $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 610 | else |
| 611 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 612 | fi |
| 613 | } |
| 614 | |
| 615 | function findmakefile() |
| 616 | { |
| 617 | TOPFILE=build/core/envsetup.mk |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 618 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 619 | T= |
| 620 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 11b15b1 | 2012-10-11 15:05:07 -0700 | [diff] [blame] | 621 | T=`PWD= /bin/pwd` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 622 | if [ -f "$T/Android.mk" ]; then |
| 623 | echo $T/Android.mk |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 624 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 625 | return |
| 626 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 627 | \cd .. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 628 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 629 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | function mm() |
| 633 | { |
| 634 | # If we're sitting in the root of the build tree, just do a |
| 635 | # normal make. |
| 636 | if [ -f build/core/envsetup.mk -a -f Makefile ]; then |
| 637 | make $@ |
| 638 | else |
| 639 | # Find the closest Android.mk file. |
| 640 | T=$(gettop) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 641 | local M=$(findmakefile) |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 642 | local MODULES= |
| 643 | local GET_INSTALL_PATH= |
| 644 | local ARGS= |
Robert Greenwalt | 3c794d7 | 2009-07-15 15:07:44 -0700 | [diff] [blame] | 645 | # Remove the path to top as the makefilepath needs to be relative |
| 646 | local M=`echo $M|sed 's:'$T'/::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 647 | if [ ! "$T" ]; then |
| 648 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 649 | elif [ ! "$M" ]; then |
| 650 | echo "Couldn't locate a makefile from the current directory." |
| 651 | else |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 652 | for ARG in $@; do |
| 653 | case $ARG in |
| 654 | GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;; |
| 655 | esac |
| 656 | done |
| 657 | if [ -n "$GET_INSTALL_PATH" ]; then |
| 658 | MODULES= |
| 659 | ARGS=GET-INSTALL-PATH |
| 660 | else |
| 661 | MODULES=all_modules |
| 662 | ARGS=$@ |
| 663 | fi |
| 664 | ONE_SHOT_MAKEFILE=$M make -C $T -f build/core/main.mk $MODULES $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 665 | fi |
| 666 | fi |
| 667 | } |
| 668 | |
| 669 | function mmm() |
| 670 | { |
| 671 | T=$(gettop) |
| 672 | if [ "$T" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 673 | local MAKEFILE= |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 674 | local MODULES= |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 675 | local ARGS= |
| 676 | local DIR TO_CHOP |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 677 | local GET_INSTALL_PATH= |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 678 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 679 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 680 | for DIR in $DIRS ; do |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 681 | MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` |
| 682 | if [ "$MODULES" = "" ]; then |
| 683 | MODULES=all_modules |
| 684 | fi |
| 685 | DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 686 | if [ -f $DIR/Android.mk ]; then |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 687 | local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '` |
| 688 | local TO_CHOP=`expr $TO_CHOP + 1` |
| 689 | local START=`PWD= /bin/pwd` |
| 690 | local MFILE=`echo $START | cut -c${TO_CHOP}-` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 691 | if [ "$MFILE" = "" ] ; then |
| 692 | MFILE=$DIR/Android.mk |
| 693 | else |
| 694 | MFILE=$MFILE/$DIR/Android.mk |
| 695 | fi |
| 696 | MAKEFILE="$MAKEFILE $MFILE" |
| 697 | else |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 698 | case $DIR in |
| 699 | showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";; |
| 700 | GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;; |
| 701 | *) echo "No Android.mk in $DIR."; return 1;; |
| 702 | esac |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 703 | fi |
| 704 | done |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 705 | if [ -n "$GET_INSTALL_PATH" ]; then |
| 706 | ARGS=$GET_INSTALL_PATH |
| 707 | MODULES= |
| 708 | fi |
Joe Onorato | fa72a60 | 2013-01-11 12:49:04 -0800 | [diff] [blame] | 709 | ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 710 | else |
| 711 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 712 | fi |
| 713 | } |
| 714 | |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 715 | function mma() |
| 716 | { |
| 717 | if [ -f build/core/envsetup.mk -a -f Makefile ]; then |
| 718 | make $@ |
| 719 | else |
| 720 | T=$(gettop) |
| 721 | if [ ! "$T" ]; then |
| 722 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 723 | fi |
| 724 | local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'` |
| 725 | make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD" |
| 726 | fi |
| 727 | } |
| 728 | |
| 729 | function mmma() |
| 730 | { |
| 731 | T=$(gettop) |
| 732 | if [ "$T" ]; then |
| 733 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 734 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 735 | local MY_PWD=`PWD= /bin/pwd` |
| 736 | if [ "$MY_PWD" = "$T" ]; then |
| 737 | MY_PWD= |
| 738 | else |
| 739 | MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'` |
| 740 | fi |
| 741 | local DIR= |
| 742 | local MODULE_PATHS= |
| 743 | local ARGS= |
| 744 | for DIR in $DIRS ; do |
| 745 | if [ -d $DIR ]; then |
| 746 | if [ "$MY_PWD" = "" ]; then |
| 747 | MODULE_PATHS="$MODULE_PATHS $DIR" |
| 748 | else |
| 749 | MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR" |
| 750 | fi |
| 751 | else |
| 752 | case $DIR in |
| 753 | showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";; |
| 754 | *) echo "Couldn't find directory $DIR"; return 1;; |
| 755 | esac |
| 756 | fi |
| 757 | done |
| 758 | make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS" |
| 759 | else |
| 760 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 761 | fi |
| 762 | } |
| 763 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 764 | function croot() |
| 765 | { |
| 766 | T=$(gettop) |
| 767 | if [ "$T" ]; then |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 768 | \cd $(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 769 | else |
| 770 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 771 | fi |
| 772 | } |
| 773 | |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 774 | function cproj() |
| 775 | { |
| 776 | TOPFILE=build/core/envsetup.mk |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 777 | local HERE=$PWD |
| 778 | T= |
| 779 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 780 | T=$PWD |
| 781 | if [ -f "$T/Android.mk" ]; then |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 782 | \cd $T |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 783 | return |
| 784 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 785 | \cd .. |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 786 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 787 | \cd $HERE |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 788 | echo "can't find Android.mk" |
| 789 | } |
| 790 | |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 791 | # simplified version of ps; output in the form |
| 792 | # <pid> <procname> |
| 793 | function qpid() { |
| 794 | local prepend='' |
| 795 | local append='' |
| 796 | if [ "$1" = "--exact" ]; then |
| 797 | prepend=' ' |
| 798 | append='$' |
| 799 | shift |
| 800 | elif [ "$1" = "--help" -o "$1" = "-h" ]; then |
| 801 | echo "usage: qpid [[--exact] <process name|pid>" |
| 802 | return 255 |
| 803 | fi |
| 804 | |
| 805 | local EXE="$1" |
| 806 | if [ "$EXE" ] ; then |
Mathias Agopian | 4458327 | 2013-08-27 14:15:50 -0700 | [diff] [blame] | 807 | qpid | \grep "$prepend$EXE$append" |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 808 | else |
| 809 | adb shell ps \ |
| 810 | | tr -d '\r' \ |
| 811 | | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/' |
| 812 | fi |
| 813 | } |
| 814 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 815 | function pid() |
| 816 | { |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 817 | local prepend='' |
| 818 | local append='' |
| 819 | if [ "$1" = "--exact" ]; then |
| 820 | prepend=' ' |
| 821 | append='$' |
| 822 | shift |
| 823 | fi |
| 824 | local EXE="$1" |
| 825 | if [ "$EXE" ] ; then |
| 826 | local PID=`adb shell ps \ |
| 827 | | tr -d '\r' \ |
Mathias Agopian | 4458327 | 2013-08-27 14:15:50 -0700 | [diff] [blame] | 828 | | \grep "$prepend$EXE$append" \ |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 829 | | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'` |
| 830 | echo "$PID" |
| 831 | else |
| 832 | echo "usage: pid [--exact] <process name>" |
| 833 | return 255 |
| 834 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 837 | # systemstack - dump the current stack trace of all threads in the system process |
| 838 | # to the usual ANR traces file |
| 839 | function systemstack() |
| 840 | { |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 841 | stacks system_server |
| 842 | } |
| 843 | |
| 844 | function stacks() |
| 845 | { |
| 846 | if [[ $1 =~ ^[0-9]+$ ]] ; then |
| 847 | local PID="$1" |
| 848 | elif [ "$1" ] ; then |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 849 | local PIDLIST="$(pid $1)" |
| 850 | if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then |
| 851 | local PID="$PIDLIST" |
| 852 | elif [ "$PIDLIST" ] ; then |
| 853 | echo "more than one process: $1" |
| 854 | else |
| 855 | echo "no such process: $1" |
| 856 | fi |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 857 | else |
| 858 | echo "usage: stacks [pid|process name]" |
| 859 | fi |
| 860 | |
| 861 | if [ "$PID" ] ; then |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 862 | # Determine whether the process is native |
| 863 | if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then |
| 864 | # Dump stacks of Dalvik process |
| 865 | local TRACES=/data/anr/traces.txt |
| 866 | local ORIG=/data/anr/traces.orig |
| 867 | local TMP=/data/anr/traces.tmp |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 868 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 869 | # Keep original traces to avoid clobbering |
| 870 | adb shell mv $TRACES $ORIG |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 871 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 872 | # Make sure we have a usable file |
| 873 | adb shell touch $TRACES |
| 874 | adb shell chmod 666 $TRACES |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 875 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 876 | # Dump stacks and wait for dump to finish |
| 877 | adb shell kill -3 $PID |
| 878 | adb shell notify $TRACES >/dev/null |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 879 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 880 | # Restore original stacks, and show current output |
| 881 | adb shell mv $TRACES $TMP |
| 882 | adb shell mv $ORIG $TRACES |
| 883 | adb shell cat $TMP |
| 884 | else |
| 885 | # Dump stacks of native process |
| 886 | adb shell debuggerd -b $PID |
| 887 | fi |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 888 | fi |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 889 | } |
| 890 | |
John Michelau | 5020025 | 2012-11-09 11:48:04 -0600 | [diff] [blame] | 891 | function gdbwrapper() |
| 892 | { |
| 893 | $ANDROID_TOOLCHAIN/$GDB -x "$@" |
| 894 | } |
| 895 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 896 | function gdbclient() |
| 897 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 898 | local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT) |
| 899 | local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED) |
| 900 | local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED) |
| 901 | local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED) |
| 902 | local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS) |
Nick Kralevich | 0ab21d3 | 2011-11-11 09:02:01 -0800 | [diff] [blame] | 903 | local ARCH=$(get_build_var TARGET_ARCH) |
| 904 | local GDB |
| 905 | case "$ARCH" in |
Jean-Baptiste Queru | feec98b | 2012-05-16 13:18:39 -0700 | [diff] [blame] | 906 | x86) GDB=i686-linux-android-gdb;; |
Nick Kralevich | 0ab21d3 | 2011-11-11 09:02:01 -0800 | [diff] [blame] | 907 | arm) GDB=arm-linux-androideabi-gdb;; |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 908 | mips) GDB=mipsel-linux-android-gdb;; |
Nick Kralevich | 0ab21d3 | 2011-11-11 09:02:01 -0800 | [diff] [blame] | 909 | *) echo "Unknown arch $ARCH"; return 1;; |
| 910 | esac |
| 911 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 912 | if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then |
| 913 | local EXE="$1" |
| 914 | if [ "$EXE" ] ; then |
| 915 | EXE=$1 |
| 916 | else |
| 917 | EXE="app_process" |
| 918 | fi |
| 919 | |
| 920 | local PORT="$2" |
| 921 | if [ "$PORT" ] ; then |
| 922 | PORT=$2 |
| 923 | else |
| 924 | PORT=":5039" |
| 925 | fi |
| 926 | |
Chris Craik | 20c136a | 2012-11-09 18:02:19 -0800 | [diff] [blame] | 927 | local PID="$3" |
| 928 | if [ "$PID" ] ; then |
| 929 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
Grace Kloba | e9d04bf | 2011-04-30 11:04:05 -0700 | [diff] [blame] | 930 | PID=`pid $3` |
Chris Craik | 20c136a | 2012-11-09 18:02:19 -0800 | [diff] [blame] | 931 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
| 932 | # that likely didn't work because of returning multiple processes |
| 933 | # try again, filtering by root processes (don't contain colon) |
Mathias Agopian | 4458327 | 2013-08-27 14:15:50 -0700 | [diff] [blame] | 934 | PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'` |
Chris Craik | 20c136a | 2012-11-09 18:02:19 -0800 | [diff] [blame] | 935 | if [[ ! "$PID" =~ ^[0-9]+$ ]] |
| 936 | then |
| 937 | echo "Couldn't resolve '$3' to single PID" |
| 938 | return 1 |
| 939 | else |
| 940 | echo "" |
| 941 | echo "WARNING: multiple processes matching '$3' observed, using root process" |
| 942 | echo "" |
| 943 | fi |
| 944 | fi |
Grace Kloba | e9d04bf | 2011-04-30 11:04:05 -0700 | [diff] [blame] | 945 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 946 | adb forward "tcp$PORT" "tcp$PORT" |
| 947 | adb shell gdbserver $PORT --attach $PID & |
| 948 | sleep 2 |
| 949 | else |
| 950 | echo "" |
| 951 | echo "If you haven't done so already, do this first on the device:" |
| 952 | echo " gdbserver $PORT /system/bin/$EXE" |
| 953 | echo " or" |
Chris Craik | 20c136a | 2012-11-09 18:02:19 -0800 | [diff] [blame] | 954 | echo " gdbserver $PORT --attach <PID>" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 955 | echo "" |
| 956 | fi |
| 957 | |
| 958 | echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS" |
Chris Dearman | 6858d51 | 2012-02-02 14:16:52 -0800 | [diff] [blame] | 959 | 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" |
Ben Cheng | 7239816 | 2013-06-24 14:36:21 -0700 | [diff] [blame] | 960 | echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 961 | echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT" |
| 962 | echo >>"$OUT_ROOT/gdbclient.cmds" "" |
| 963 | |
John Michelau | 5020025 | 2012-11-09 11:48:04 -0600 | [diff] [blame] | 964 | gdbwrapper "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 965 | else |
| 966 | echo "Unable to determine build system output dir." |
| 967 | fi |
| 968 | |
| 969 | } |
| 970 | |
| 971 | case `uname -s` in |
| 972 | Darwin) |
| 973 | function sgrep() |
| 974 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 975 | 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 "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | ;; |
| 979 | *) |
| 980 | function sgrep() |
| 981 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 982 | 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 "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 983 | } |
| 984 | ;; |
| 985 | esac |
| 986 | |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 987 | function gettargetarch |
| 988 | { |
| 989 | get_build_var TARGET_ARCH |
| 990 | } |
| 991 | |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame^] | 992 | function ggrep() |
| 993 | { |
| 994 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" -print0 | xargs -0 grep --color -n "$@" |
| 995 | } |
| 996 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 997 | function jgrep() |
| 998 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 999 | find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | function cgrep() |
| 1003 | { |
Mike Dodd | 0c26d34 | 2011-04-07 13:29:06 -0700 | [diff] [blame] | 1004 | 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 "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | function resgrep() |
| 1008 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 1009 | 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; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1010 | } |
| 1011 | |
Jeff Sharkey | 50b61e9 | 2013-03-08 10:20:47 -0800 | [diff] [blame] | 1012 | function mangrep() |
| 1013 | { |
| 1014 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@" |
| 1015 | } |
| 1016 | |
Alex Klyubin | ba5fc8e | 2013-05-06 14:11:48 -0700 | [diff] [blame] | 1017 | function sepgrep() |
| 1018 | { |
| 1019 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@" |
| 1020 | } |
| 1021 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1022 | case `uname -s` in |
| 1023 | Darwin) |
| 1024 | function mgrep() |
| 1025 | { |
Ying Wang | 324c2b2 | 2012-08-17 15:03:20 -0700 | [diff] [blame] | 1026 | find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | function treegrep() |
| 1030 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 1031 | 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 "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | ;; |
| 1035 | *) |
| 1036 | function mgrep() |
| 1037 | { |
Ying Wang | 324c2b2 | 2012-08-17 15:03:20 -0700 | [diff] [blame] | 1038 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
| 1041 | function treegrep() |
| 1042 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 1043 | 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 "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | ;; |
| 1047 | esac |
| 1048 | |
| 1049 | function getprebuilt |
| 1050 | { |
| 1051 | get_abs_build_var ANDROID_PREBUILTS |
| 1052 | } |
| 1053 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1054 | function tracedmdump() |
| 1055 | { |
| 1056 | T=$(gettop) |
| 1057 | if [ ! "$T" ]; then |
| 1058 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1059 | return |
| 1060 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1061 | local prebuiltdir=$(getprebuilt) |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 1062 | local arch=$(gettargetarch) |
| 1063 | local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1064 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1065 | local TRACE=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1066 | if [ ! "$TRACE" ] ; then |
| 1067 | echo "usage: tracedmdump tracename" |
| 1068 | return |
| 1069 | fi |
| 1070 | |
Jack Veenstra | 60116fc | 2009-04-09 18:12:34 -0700 | [diff] [blame] | 1071 | if [ ! -r "$KERNEL" ] ; then |
| 1072 | echo "Error: cannot find kernel: '$KERNEL'" |
| 1073 | return |
| 1074 | fi |
| 1075 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1076 | local BASETRACE=$(basename $TRACE) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1077 | if [ "$BASETRACE" = "$TRACE" ] ; then |
| 1078 | TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE |
| 1079 | fi |
| 1080 | |
| 1081 | echo "post-processing traces..." |
| 1082 | rm -f $TRACE/qtrace.dexlist |
| 1083 | post_trace $TRACE |
| 1084 | if [ $? -ne 0 ]; then |
| 1085 | echo "***" |
| 1086 | echo "*** Error: malformed trace. Did you remember to exit the emulator?" |
| 1087 | echo "***" |
| 1088 | return |
| 1089 | fi |
| 1090 | echo "generating dexlist output..." |
| 1091 | /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 |
| 1092 | echo "generating dmtrace data..." |
| 1093 | q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return |
| 1094 | echo "generating html file..." |
| 1095 | dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return |
| 1096 | echo "done, see $TRACE/dmtrace.html for details" |
| 1097 | echo "or run:" |
| 1098 | echo " traceview $TRACE/dmtrace" |
| 1099 | } |
| 1100 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1101 | # communicate with a running device or emulator, set up necessary state, |
| 1102 | # and run the hat command. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1103 | function runhat() |
| 1104 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1105 | # process standard adb options |
| 1106 | local adbTarget="" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1107 | if [ "$1" = "-d" -o "$1" = "-e" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1108 | adbTarget=$1 |
| 1109 | shift 1 |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1110 | elif [ "$1" = "-s" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1111 | adbTarget="$1 $2" |
| 1112 | shift 2 |
| 1113 | fi |
| 1114 | local adbOptions=${adbTarget} |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1115 | #echo adbOptions = ${adbOptions} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1116 | |
| 1117 | # runhat options |
| 1118 | local targetPid=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1119 | |
| 1120 | if [ "$targetPid" = "" ]; then |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1121 | echo "Usage: runhat [ -d | -e | -s serial ] target-pid" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1122 | return |
| 1123 | fi |
| 1124 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1125 | # confirm hat is available |
| 1126 | if [ -z $(which hat) ]; then |
| 1127 | echo "hat is not available in this configuration." |
| 1128 | return |
| 1129 | fi |
| 1130 | |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1131 | # issue "am" command to cause the hprof dump |
Christopher Ferris | 764b4f8 | 2013-05-20 16:30:10 -0700 | [diff] [blame] | 1132 | local sdcard=$(adb ${adbOptions} shell echo -n '$EXTERNAL_STORAGE') |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1133 | local devFile=$sdcard/hprof-$targetPid |
| 1134 | #local devFile=/data/local/hprof-$targetPid |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1135 | echo "Poking $targetPid and waiting for data..." |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1136 | echo "Storing data at $devFile" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1137 | adb ${adbOptions} shell am dumpheap $targetPid $devFile |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1138 | echo "Press enter when logcat shows \"hprof: heap dump completed\"" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1139 | echo -n "> " |
| 1140 | read |
| 1141 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1142 | local localFile=/tmp/$$-hprof |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1143 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1144 | echo "Retrieving file $devFile..." |
| 1145 | adb ${adbOptions} pull $devFile $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1146 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1147 | adb ${adbOptions} shell rm $devFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1148 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1149 | echo "Running hat on $localFile" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1150 | echo "View the output by pointing your browser at http://localhost:7000/" |
| 1151 | echo "" |
Dianne Hackborn | 6e4e1bb | 2011-11-10 15:19:51 -0800 | [diff] [blame] | 1152 | hat -JXmx512m $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | function getbugreports() |
| 1156 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1157 | local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1158 | |
| 1159 | if [ ! "$reports" ]; then |
| 1160 | echo "Could not locate any bugreports." |
| 1161 | return |
| 1162 | fi |
| 1163 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1164 | local report |
| 1165 | for report in ${reports[@]} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1166 | do |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1167 | echo "/sdcard/bugreports/${report}" |
| 1168 | adb pull /sdcard/bugreports/${report} ${report} |
| 1169 | gunzip ${report} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1170 | done |
| 1171 | } |
| 1172 | |
Victoria Lease | 1b296b4 | 2012-08-21 15:44:06 -0700 | [diff] [blame] | 1173 | function getsdcardpath() |
| 1174 | { |
| 1175 | adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\} |
| 1176 | } |
| 1177 | |
| 1178 | function getscreenshotpath() |
| 1179 | { |
| 1180 | echo "$(getsdcardpath)/Pictures/Screenshots" |
| 1181 | } |
| 1182 | |
| 1183 | function getlastscreenshot() |
| 1184 | { |
| 1185 | local screenshot_path=$(getscreenshotpath) |
| 1186 | local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1` |
| 1187 | if [ "$screenshot" = "" ]; then |
| 1188 | echo "No screenshots found." |
| 1189 | return |
| 1190 | fi |
| 1191 | echo "${screenshot}" |
| 1192 | adb ${adbOptions} pull ${screenshot_path}/${screenshot} |
| 1193 | } |
| 1194 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1195 | function startviewserver() |
| 1196 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1197 | local port=4939 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1198 | if [ $# -gt 0 ]; then |
| 1199 | port=$1 |
| 1200 | fi |
| 1201 | adb shell service call window 1 i32 $port |
| 1202 | } |
| 1203 | |
| 1204 | function stopviewserver() |
| 1205 | { |
| 1206 | adb shell service call window 2 |
| 1207 | } |
| 1208 | |
| 1209 | function isviewserverstarted() |
| 1210 | { |
| 1211 | adb shell service call window 3 |
| 1212 | } |
| 1213 | |
Romain Guy | b84049a | 2010-10-04 16:56:11 -0700 | [diff] [blame] | 1214 | function key_home() |
| 1215 | { |
| 1216 | adb shell input keyevent 3 |
| 1217 | } |
| 1218 | |
| 1219 | function key_back() |
| 1220 | { |
| 1221 | adb shell input keyevent 4 |
| 1222 | } |
| 1223 | |
| 1224 | function key_menu() |
| 1225 | { |
| 1226 | adb shell input keyevent 82 |
| 1227 | } |
| 1228 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1229 | function smoketest() |
| 1230 | { |
| 1231 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1232 | echo "Couldn't locate output files. Try running 'lunch' first." >&2 |
| 1233 | return |
| 1234 | fi |
| 1235 | T=$(gettop) |
| 1236 | if [ ! "$T" ]; then |
| 1237 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1238 | return |
| 1239 | fi |
| 1240 | |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1241 | (\cd "$T" && mmm tests/SmokeTest) && |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1242 | adb uninstall com.android.smoketest > /dev/null && |
| 1243 | adb uninstall com.android.smoketest.tests > /dev/null && |
| 1244 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk && |
| 1245 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk && |
| 1246 | adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner |
| 1247 | } |
| 1248 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1249 | # simple shortcut to the runtest command |
| 1250 | function runtest() |
| 1251 | { |
| 1252 | T=$(gettop) |
| 1253 | if [ ! "$T" ]; then |
| 1254 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1255 | return |
| 1256 | fi |
Brett Chabot | 3fb149d | 2009-10-21 20:05:26 -0700 | [diff] [blame] | 1257 | ("$T"/development/testrunner/runtest.py $@) |
Brett Chabot | 762748c | 2009-03-27 10:25:11 -0700 | [diff] [blame] | 1258 | } |
| 1259 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1260 | function godir () { |
| 1261 | if [[ -z "$1" ]]; then |
| 1262 | echo "Usage: godir <regex>" |
| 1263 | return |
| 1264 | fi |
Brian Carlstrom | b9915a6 | 2010-01-29 16:39:32 -0800 | [diff] [blame] | 1265 | T=$(gettop) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1266 | if [[ ! -f $T/filelist ]]; then |
| 1267 | echo -n "Creating index..." |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1268 | (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1269 | echo " Done" |
| 1270 | echo "" |
| 1271 | fi |
| 1272 | local lines |
Jeff Hamilton | 293f939 | 2011-11-18 17:15:25 -0600 | [diff] [blame] | 1273 | lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1274 | if [[ ${#lines[@]} = 0 ]]; then |
| 1275 | echo "Not found" |
| 1276 | return |
| 1277 | fi |
| 1278 | local pathname |
| 1279 | local choice |
| 1280 | if [[ ${#lines[@]} > 1 ]]; then |
| 1281 | while [[ -z "$pathname" ]]; do |
| 1282 | local index=1 |
| 1283 | local line |
| 1284 | for line in ${lines[@]}; do |
| 1285 | printf "%6s %s\n" "[$index]" $line |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 1286 | index=$(($index + 1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1287 | done |
| 1288 | echo |
| 1289 | echo -n "Select one: " |
| 1290 | unset choice |
| 1291 | read choice |
| 1292 | if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then |
| 1293 | echo "Invalid choice" |
| 1294 | continue |
| 1295 | fi |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 1296 | pathname=${lines[$(($choice-1))]} |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1297 | done |
| 1298 | else |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1299 | pathname=${lines[0]} |
| 1300 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1301 | \cd $T/$pathname |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1302 | } |
| 1303 | |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 1304 | # Force JAVA_HOME to point to java 1.6 if it isn't already set |
| 1305 | function set_java_home() { |
Andy McFadden | bd96094 | 2010-06-24 12:52:51 -0700 | [diff] [blame] | 1306 | if [ ! "$JAVA_HOME" ]; then |
| 1307 | case `uname -s` in |
| 1308 | Darwin) |
| 1309 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home |
| 1310 | ;; |
| 1311 | *) |
| 1312 | export JAVA_HOME=/usr/lib/jvm/java-6-sun |
| 1313 | ;; |
| 1314 | esac |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 1315 | fi |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 1316 | } |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 1317 | |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 1318 | # Print colored exit condition |
| 1319 | function pez { |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 1320 | "$@" |
| 1321 | local retval=$? |
| 1322 | if [ $retval -ne 0 ] |
| 1323 | then |
| 1324 | echo -e "\e[0;31mFAILURE\e[00m" |
| 1325 | else |
| 1326 | echo -e "\e[0;32mSUCCESS\e[00m" |
| 1327 | fi |
| 1328 | return $retval |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 1329 | } |
| 1330 | |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1331 | if [ "x$SHELL" != "x/bin/bash" ]; then |
| 1332 | case `ps -o command -p $$` in |
| 1333 | *bash*) |
| 1334 | ;; |
| 1335 | *) |
| 1336 | echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results" |
| 1337 | ;; |
| 1338 | esac |
| 1339 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1340 | |
| 1341 | # Execute the contents of any vendorsetup.sh files we can find. |
Guilhem IMBERTON | 58570e7 | 2012-10-04 14:26:57 +0200 | [diff] [blame] | 1342 | for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \ |
| 1343 | `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1344 | do |
| 1345 | echo "including $f" |
| 1346 | . $f |
| 1347 | done |
| 1348 | unset f |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 1349 | |
| 1350 | addcompletions |