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: |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 4 | - croot: Changes directory to the top of the tree. |
| 5 | - m: Makes from the top of the tree. |
| 6 | - mm: Builds all of the modules in the current directory. |
| 7 | - mmm: Builds all of the modules in the supplied directories. |
| 8 | - cgrep: Greps on all local C/C++ files. |
| 9 | - jgrep: Greps on all local Java files. |
| 10 | - resgrep: Greps on all local res/*.xml files. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 11 | - godir: Go to the directory containing a file. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 12 | |
| 13 | Look at the source to view more functions. The complete list is: |
| 14 | EOF |
| 15 | T=$(gettop) |
| 16 | local A |
| 17 | A="" |
| 18 | for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do |
| 19 | A="$A $i" |
| 20 | done |
| 21 | echo $A |
| 22 | } |
| 23 | |
| 24 | # Get the value of a build variable as an absolute path. |
| 25 | function get_abs_build_var() |
| 26 | { |
| 27 | T=$(gettop) |
| 28 | if [ ! "$T" ]; then |
| 29 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 30 | return |
| 31 | fi |
Brian Carlstrom | 177285a | 2010-04-06 13:22:02 -0700 | [diff] [blame] | 32 | (cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
| 33 | make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | # Get the exact value of a build variable. |
| 37 | function get_build_var() |
| 38 | { |
| 39 | T=$(gettop) |
| 40 | if [ ! "$T" ]; then |
| 41 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 42 | return |
| 43 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 44 | CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
| 45 | make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-$1 |
| 46 | } |
| 47 | |
| 48 | # check to see if the supplied product is one we can build |
| 49 | function check_product() |
| 50 | { |
| 51 | T=$(gettop) |
| 52 | if [ ! "$T" ]; then |
| 53 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 54 | return |
| 55 | fi |
| 56 | CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 57 | TARGET_PRODUCT=$1 \ |
| 58 | TARGET_BUILD_VARIANT= \ |
| 59 | TARGET_BUILD_TYPE= \ |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 60 | TARGET_BUILD_APPS= \ |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 61 | get_build_var TARGET_DEVICE > /dev/null |
| 62 | # hide successful answers, but allow the errors to show |
| 63 | } |
| 64 | |
| 65 | VARIANT_CHOICES=(user userdebug eng) |
| 66 | |
| 67 | # check to see if the supplied variant is valid |
| 68 | function check_variant() |
| 69 | { |
| 70 | for v in ${VARIANT_CHOICES[@]} |
| 71 | do |
| 72 | if [ "$v" = "$1" ] |
| 73 | then |
| 74 | return 0 |
| 75 | fi |
| 76 | done |
| 77 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | function setpaths() |
| 81 | { |
| 82 | T=$(gettop) |
| 83 | if [ ! "$T" ]; then |
| 84 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 85 | return |
| 86 | fi |
| 87 | |
| 88 | ################################################################## |
| 89 | # # |
| 90 | # Read me before you modify this code # |
| 91 | # # |
| 92 | # This function sets ANDROID_BUILD_PATHS to what it is adding # |
| 93 | # to PATH, and the next time it is run, it removes that from # |
| 94 | # PATH. This is required so lunch can be run more than once # |
| 95 | # and still have working paths. # |
| 96 | # # |
| 97 | ################################################################## |
| 98 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 99 | # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces |
| 100 | # due to "C:\Program Files" being in the path. |
| 101 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 102 | # out with the old |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 103 | if [ -n "$ANDROID_BUILD_PATHS" ] ; then |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 104 | export PATH=${PATH/$ANDROID_BUILD_PATHS/} |
| 105 | fi |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 106 | if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 107 | export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/} |
| 108 | # strip trailing ':', if any |
| 109 | export PATH=${PATH/%:/} |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 110 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 111 | |
| 112 | # and in with the new |
| 113 | CODE_REVIEWS= |
| 114 | prebuiltdir=$(getprebuilt) |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 115 | gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS) |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 116 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 117 | # 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] | 118 | export ANDROID_EABI_TOOLCHAIN= |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame^] | 119 | local ARCH=$(get_build_var TARGET_ARCH) |
| 120 | case $ARCH in |
| 121 | x86) toolchaindir=x86/i686-android-linux-4.4.3/bin |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 122 | ;; |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame^] | 123 | arm) toolchaindir=arm/arm-linux-androideabi-4.6/bin |
| 124 | ;; |
| 125 | *) |
| 126 | echo "Can't find toolchain for unknown architecture: $ARCH" |
| 127 | toolchaindir=xxxxxxxxx |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 128 | ;; |
| 129 | esac |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 130 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
| 131 | export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 132 | fi |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 133 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 134 | export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN |
| 135 | export ANDROID_QTOOLS=$T/development/emulator/qtools |
Jing Yu | 9d396e3 | 2010-07-29 15:07:31 -0700 | [diff] [blame] | 136 | export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 137 | export PATH=$PATH$ANDROID_BUILD_PATHS |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 138 | |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 139 | unset ANDROID_JAVA_TOOLCHAIN |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 140 | unset ANDROID_PRE_BUILD_PATHS |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 141 | if [ -n "$JAVA_HOME" ]; then |
| 142 | export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 143 | export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN: |
| 144 | export PATH=$ANDROID_PRE_BUILD_PATHS$PATH |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 145 | fi |
| 146 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 147 | unset ANDROID_PRODUCT_OUT |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 148 | export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT) |
| 149 | export OUT=$ANDROID_PRODUCT_OUT |
| 150 | |
Jeff Brown | 8fd5cce | 2011-03-24 17:03:06 -0700 | [diff] [blame] | 151 | unset ANDROID_HOST_OUT |
| 152 | export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT) |
| 153 | |
Ben Cheng | 057fde1 | 2011-11-28 13:55:14 -0800 | [diff] [blame] | 154 | # needed for processing samples collected by perf counters |
| 155 | unset OPROFILE_EVENTS_DIR |
| 156 | export OPROFILE_EVENTS_DIR=$T/external/oprofile/events |
| 157 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 158 | # needed for building linux on MacOS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 159 | # TODO: fix the path |
| 160 | #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include |
| 161 | } |
| 162 | |
| 163 | function printconfig() |
| 164 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 165 | T=$(gettop) |
| 166 | if [ ! "$T" ]; then |
| 167 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 168 | return |
| 169 | fi |
| 170 | get_build_var report_config |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | function set_stuff_for_environment() |
| 174 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 175 | settitle |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 176 | set_java_home |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 177 | setpaths |
| 178 | set_sequence_number |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 179 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 180 | export ANDROID_BUILD_TOP=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | function set_sequence_number() |
| 184 | { |
Joe Onorato | aee4daa | 2010-06-23 14:03:13 -0700 | [diff] [blame] | 185 | export BUILD_ENV_SEQUENCE_NUMBER=10 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | function settitle() |
| 189 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 190 | if [ "$STAY_OFF_MY_LAWN" = "" ]; then |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 191 | local product=$TARGET_PRODUCT |
| 192 | local variant=$TARGET_BUILD_VARIANT |
| 193 | local apps=$TARGET_BUILD_APPS |
| 194 | if [ -z "$apps" ]; then |
| 195 | export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\"" |
| 196 | else |
| 197 | export PROMPT_COMMAND="echo -ne \"\033]0;[$apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\"" |
| 198 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 199 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 202 | function addcompletions() |
| 203 | { |
| 204 | local T dir f |
| 205 | |
| 206 | # Keep us from trying to run in something that isn't bash. |
| 207 | if [ -z "${BASH_VERSION}" ]; then |
| 208 | return |
| 209 | fi |
| 210 | |
| 211 | # Keep us from trying to run in bash that's too old. |
| 212 | if [ ${BASH_VERSINFO[0]} -lt 3 ]; then |
| 213 | return |
| 214 | fi |
| 215 | |
| 216 | dir="sdk/bash_completion" |
| 217 | if [ -d ${dir} ]; then |
Kenny Root | 7546d61 | 2011-07-18 13:11:34 -0700 | [diff] [blame] | 218 | 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] | 219 | echo "including $f" |
| 220 | . $f |
| 221 | done |
| 222 | fi |
| 223 | } |
| 224 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 225 | function choosetype() |
| 226 | { |
| 227 | echo "Build type choices are:" |
| 228 | echo " 1. release" |
| 229 | echo " 2. debug" |
| 230 | echo |
| 231 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 232 | local DEFAULT_NUM DEFAULT_VALUE |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 233 | DEFAULT_NUM=1 |
| 234 | DEFAULT_VALUE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 235 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 236 | export TARGET_BUILD_TYPE= |
| 237 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 238 | while [ -z $TARGET_BUILD_TYPE ] |
| 239 | do |
| 240 | echo -n "Which would you like? ["$DEFAULT_NUM"] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 241 | if [ -z "$1" ] ; then |
| 242 | read ANSWER |
| 243 | else |
| 244 | echo $1 |
| 245 | ANSWER=$1 |
| 246 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 247 | case $ANSWER in |
| 248 | "") |
| 249 | export TARGET_BUILD_TYPE=$DEFAULT_VALUE |
| 250 | ;; |
| 251 | 1) |
| 252 | export TARGET_BUILD_TYPE=release |
| 253 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 254 | release) |
| 255 | export TARGET_BUILD_TYPE=release |
| 256 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 257 | 2) |
| 258 | export TARGET_BUILD_TYPE=debug |
| 259 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 260 | debug) |
| 261 | export TARGET_BUILD_TYPE=debug |
| 262 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 263 | *) |
| 264 | echo |
| 265 | echo "I didn't understand your response. Please try again." |
| 266 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 267 | ;; |
| 268 | esac |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 269 | if [ -n "$1" ] ; then |
| 270 | break |
| 271 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 272 | done |
| 273 | |
| 274 | set_stuff_for_environment |
| 275 | } |
| 276 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 277 | # |
| 278 | # This function isn't really right: It chooses a TARGET_PRODUCT |
| 279 | # based on the list of boards. Usually, that gets you something |
| 280 | # that kinda works with a generic product, but really, you should |
| 281 | # pick a product by name. |
| 282 | # |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 283 | function chooseproduct() |
| 284 | { |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 285 | if [ "x$TARGET_PRODUCT" != x ] ; then |
| 286 | default_value=$TARGET_PRODUCT |
| 287 | else |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 288 | default_value=full |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 289 | fi |
| 290 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 291 | export TARGET_PRODUCT= |
| 292 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 293 | while [ -z "$TARGET_PRODUCT" ] |
| 294 | do |
Joe Onorato | 8849aed | 2009-04-29 15:56:47 -0700 | [diff] [blame] | 295 | echo -n "Which product would you like? [$default_value] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 296 | if [ -z "$1" ] ; then |
| 297 | read ANSWER |
| 298 | else |
| 299 | echo $1 |
| 300 | ANSWER=$1 |
| 301 | fi |
| 302 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 303 | if [ -z "$ANSWER" ] ; then |
| 304 | export TARGET_PRODUCT=$default_value |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 305 | else |
| 306 | if check_product $ANSWER |
| 307 | then |
| 308 | export TARGET_PRODUCT=$ANSWER |
| 309 | else |
| 310 | echo "** Not a valid product: $ANSWER" |
| 311 | fi |
| 312 | fi |
| 313 | if [ -n "$1" ] ; then |
| 314 | break |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 315 | fi |
| 316 | done |
| 317 | |
| 318 | set_stuff_for_environment |
| 319 | } |
| 320 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 321 | function choosevariant() |
| 322 | { |
| 323 | echo "Variant choices are:" |
| 324 | local index=1 |
| 325 | local v |
| 326 | for v in ${VARIANT_CHOICES[@]} |
| 327 | do |
| 328 | # The product name is the name of the directory containing |
| 329 | # the makefile we found, above. |
| 330 | echo " $index. $v" |
| 331 | index=$(($index+1)) |
| 332 | done |
| 333 | |
| 334 | local default_value=eng |
| 335 | local ANSWER |
| 336 | |
| 337 | export TARGET_BUILD_VARIANT= |
| 338 | while [ -z "$TARGET_BUILD_VARIANT" ] |
| 339 | do |
| 340 | echo -n "Which would you like? [$default_value] " |
| 341 | if [ -z "$1" ] ; then |
| 342 | read ANSWER |
| 343 | else |
| 344 | echo $1 |
| 345 | ANSWER=$1 |
| 346 | fi |
| 347 | |
| 348 | if [ -z "$ANSWER" ] ; then |
| 349 | export TARGET_BUILD_VARIANT=$default_value |
| 350 | elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then |
| 351 | if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 352 | export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 353 | fi |
| 354 | else |
| 355 | if check_variant $ANSWER |
| 356 | then |
| 357 | export TARGET_BUILD_VARIANT=$ANSWER |
| 358 | else |
| 359 | echo "** Not a valid variant: $ANSWER" |
| 360 | fi |
| 361 | fi |
| 362 | if [ -n "$1" ] ; then |
| 363 | break |
| 364 | fi |
| 365 | done |
| 366 | } |
| 367 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 368 | function choosecombo() |
| 369 | { |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 370 | choosetype $1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 371 | |
| 372 | echo |
| 373 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 374 | chooseproduct $2 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 375 | |
| 376 | echo |
| 377 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 378 | choosevariant $3 |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 379 | |
| 380 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 381 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 382 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 383 | } |
| 384 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 385 | # Clear this variable. It will be built up again when the vendorsetup.sh |
| 386 | # files are included at the end of this file. |
| 387 | unset LUNCH_MENU_CHOICES |
| 388 | function add_lunch_combo() |
| 389 | { |
| 390 | local new_combo=$1 |
| 391 | local c |
| 392 | for c in ${LUNCH_MENU_CHOICES[@]} ; do |
| 393 | if [ "$new_combo" = "$c" ] ; then |
| 394 | return |
| 395 | fi |
| 396 | done |
| 397 | LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo) |
| 398 | } |
| 399 | |
| 400 | # add the default one here |
Jean-Baptiste Queru | 45038e0 | 2010-07-01 09:22:53 -0700 | [diff] [blame] | 401 | add_lunch_combo full-eng |
Jean-Baptiste Queru | 6c2df3e | 2010-07-15 14:04:39 -0700 | [diff] [blame] | 402 | add_lunch_combo full_x86-eng |
Bruce Beare | ba366c4 | 2011-02-15 16:46:08 -0800 | [diff] [blame] | 403 | add_lunch_combo vbox_x86-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 404 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 405 | function print_lunch_menu() |
| 406 | { |
| 407 | local uname=$(uname) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 408 | echo |
| 409 | echo "You're building on" $uname |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 410 | echo |
| 411 | echo "Lunch menu... pick a combo:" |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 412 | |
| 413 | local i=1 |
| 414 | local choice |
| 415 | for choice in ${LUNCH_MENU_CHOICES[@]} |
| 416 | do |
| 417 | echo " $i. $choice" |
| 418 | i=$(($i+1)) |
| 419 | done |
| 420 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 421 | echo |
| 422 | } |
| 423 | |
| 424 | function lunch() |
| 425 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 426 | local answer |
| 427 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 428 | if [ "$1" ] ; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 429 | answer=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 430 | else |
| 431 | print_lunch_menu |
Jean-Baptiste Queru | 0332f0a | 2010-10-22 09:52:09 -0700 | [diff] [blame] | 432 | echo -n "Which would you like? [full-eng] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 433 | read answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 434 | fi |
| 435 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 436 | local selection= |
| 437 | |
| 438 | if [ -z "$answer" ] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 439 | then |
Jean-Baptiste Queru | 0332f0a | 2010-10-22 09:52:09 -0700 | [diff] [blame] | 440 | selection=full-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 441 | elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") |
| 442 | then |
| 443 | if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] |
| 444 | then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 445 | selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 446 | fi |
| 447 | elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") |
| 448 | then |
| 449 | selection=$answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 450 | fi |
| 451 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 452 | if [ -z "$selection" ] |
| 453 | then |
| 454 | echo |
| 455 | echo "Invalid lunch combo: $answer" |
| 456 | return 1 |
| 457 | fi |
| 458 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 459 | export TARGET_BUILD_APPS= |
| 460 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 461 | local product=$(echo -n $selection | sed -e "s/-.*$//") |
| 462 | check_product $product |
| 463 | if [ $? -ne 0 ] |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 464 | then |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 465 | echo |
| 466 | echo "** Don't have a product spec for: '$product'" |
| 467 | echo "** Do you have the right repo manifest?" |
| 468 | product= |
| 469 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 470 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 471 | local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//") |
| 472 | check_variant $variant |
| 473 | if [ $? -ne 0 ] |
| 474 | then |
| 475 | echo |
| 476 | echo "** Invalid variant: '$variant'" |
| 477 | echo "** Must be one of ${VARIANT_CHOICES[@]}" |
| 478 | variant= |
| 479 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 480 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 481 | if [ -z "$product" -o -z "$variant" ] |
| 482 | then |
| 483 | echo |
| 484 | return 1 |
| 485 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 486 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 487 | export TARGET_PRODUCT=$product |
| 488 | export TARGET_BUILD_VARIANT=$variant |
| 489 | export TARGET_BUILD_TYPE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 490 | |
| 491 | echo |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 492 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 493 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 494 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 495 | } |
| 496 | |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 497 | # Tab completion for lunch. |
| 498 | function _lunch() |
| 499 | { |
| 500 | local cur prev opts |
| 501 | COMPREPLY=() |
| 502 | cur="${COMP_WORDS[COMP_CWORD]}" |
| 503 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 504 | |
| 505 | COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) ) |
| 506 | return 0 |
| 507 | } |
| 508 | complete -F _lunch lunch |
| 509 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 510 | # Configures the build to build unbundled apps. |
| 511 | # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME) |
| 512 | function tapas() |
| 513 | { |
Jeff Hamilton | 293f939 | 2011-11-18 17:15:25 -0600 | [diff] [blame] | 514 | local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$')) |
| 515 | local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng)$')) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 516 | |
| 517 | if [ $(echo $variant | wc -w) -gt 1 ]; then |
| 518 | echo "tapas: Error: Multiple build variants supplied: $variant" |
| 519 | return |
| 520 | fi |
| 521 | if [ -z "$variant" ]; then |
| 522 | variant=eng |
| 523 | fi |
Ying Wang | c048c9b | 2010-06-24 15:08:33 -0700 | [diff] [blame] | 524 | if [ -z "$apps" ]; then |
| 525 | apps=all |
| 526 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 527 | |
Jean-Baptiste Queru | 0332f0a | 2010-10-22 09:52:09 -0700 | [diff] [blame] | 528 | export TARGET_PRODUCT=full |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 529 | export TARGET_BUILD_VARIANT=$variant |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 530 | export TARGET_BUILD_TYPE=release |
| 531 | export TARGET_BUILD_APPS=$apps |
| 532 | |
| 533 | set_stuff_for_environment |
| 534 | printconfig |
| 535 | } |
| 536 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 537 | function gettop |
| 538 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 539 | local TOPFILE=build/core/envsetup.mk |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 540 | if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then |
| 541 | echo $TOP |
| 542 | else |
| 543 | if [ -f $TOPFILE ] ; then |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 544 | # The following circumlocution (repeated below as well) ensures |
| 545 | # that we record the true directory name and not one that is |
| 546 | # faked up with symlink names. |
| 547 | PWD= /bin/pwd |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 548 | else |
| 549 | # We redirect cd to /dev/null in case it's aliased to |
| 550 | # a command that prints something as a side-effect |
| 551 | # (like pushd) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 552 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 553 | T= |
| 554 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 555 | cd .. > /dev/null |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 556 | T=`PWD= /bin/pwd` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 557 | done |
| 558 | cd $HERE > /dev/null |
| 559 | if [ -f "$T/$TOPFILE" ]; then |
| 560 | echo $T |
| 561 | fi |
| 562 | fi |
| 563 | fi |
| 564 | } |
| 565 | |
| 566 | function m() |
| 567 | { |
| 568 | T=$(gettop) |
| 569 | if [ "$T" ]; then |
| 570 | make -C $T $@ |
| 571 | else |
| 572 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 573 | fi |
| 574 | } |
| 575 | |
| 576 | function findmakefile() |
| 577 | { |
| 578 | TOPFILE=build/core/envsetup.mk |
| 579 | # We redirect cd to /dev/null in case it's aliased to |
| 580 | # a command that prints something as a side-effect |
| 581 | # (like pushd) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 582 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 583 | T= |
| 584 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 585 | T=$PWD |
| 586 | if [ -f "$T/Android.mk" ]; then |
| 587 | echo $T/Android.mk |
| 588 | cd $HERE > /dev/null |
| 589 | return |
| 590 | fi |
| 591 | cd .. > /dev/null |
| 592 | done |
| 593 | cd $HERE > /dev/null |
| 594 | } |
| 595 | |
| 596 | function mm() |
| 597 | { |
| 598 | # If we're sitting in the root of the build tree, just do a |
| 599 | # normal make. |
| 600 | if [ -f build/core/envsetup.mk -a -f Makefile ]; then |
| 601 | make $@ |
| 602 | else |
| 603 | # Find the closest Android.mk file. |
| 604 | T=$(gettop) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 605 | local M=$(findmakefile) |
Robert Greenwalt | 3c794d7 | 2009-07-15 15:07:44 -0700 | [diff] [blame] | 606 | # Remove the path to top as the makefilepath needs to be relative |
| 607 | local M=`echo $M|sed 's:'$T'/::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 608 | if [ ! "$T" ]; then |
| 609 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 610 | elif [ ! "$M" ]; then |
| 611 | echo "Couldn't locate a makefile from the current directory." |
| 612 | else |
Ying Wang | 0188414 | 2010-07-20 16:18:16 -0700 | [diff] [blame] | 613 | ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 614 | fi |
| 615 | fi |
| 616 | } |
| 617 | |
| 618 | function mmm() |
| 619 | { |
| 620 | T=$(gettop) |
| 621 | if [ "$T" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 622 | local MAKEFILE= |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 623 | local MODULES= |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 624 | local ARGS= |
| 625 | local DIR TO_CHOP |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 626 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 627 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 628 | for DIR in $DIRS ; do |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 629 | MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` |
| 630 | if [ "$MODULES" = "" ]; then |
| 631 | MODULES=all_modules |
| 632 | fi |
| 633 | DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 634 | if [ -f $DIR/Android.mk ]; then |
Brian Carlstrom | c634d2c | 2010-09-17 12:25:50 -0700 | [diff] [blame] | 635 | TO_CHOP=`(cd -P -- $T && pwd -P) | wc -c | tr -d ' '` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 636 | TO_CHOP=`expr $TO_CHOP + 1` |
Gilles Debunne | 8a20f58 | 2010-02-17 15:56:45 -0800 | [diff] [blame] | 637 | START=`PWD= /bin/pwd` |
| 638 | MFILE=`echo $START | cut -c${TO_CHOP}-` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 639 | if [ "$MFILE" = "" ] ; then |
| 640 | MFILE=$DIR/Android.mk |
| 641 | else |
| 642 | MFILE=$MFILE/$DIR/Android.mk |
| 643 | fi |
| 644 | MAKEFILE="$MAKEFILE $MFILE" |
| 645 | else |
| 646 | if [ "$DIR" = snod ]; then |
| 647 | ARGS="$ARGS snod" |
| 648 | elif [ "$DIR" = showcommands ]; then |
| 649 | ARGS="$ARGS showcommands" |
Ying Wang | 0188414 | 2010-07-20 16:18:16 -0700 | [diff] [blame] | 650 | elif [ "$DIR" = dist ]; then |
| 651 | ARGS="$ARGS dist" |
Ying Wang | 015edd2 | 2011-01-20 15:01:56 -0800 | [diff] [blame] | 652 | elif [ "$DIR" = incrementaljavac ]; then |
| 653 | ARGS="$ARGS incrementaljavac" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 654 | else |
| 655 | echo "No Android.mk in $DIR." |
Joe Onorato | 51e6182 | 2009-04-13 15:36:15 -0400 | [diff] [blame] | 656 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 657 | fi |
| 658 | fi |
| 659 | done |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 660 | ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS $MODULES $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 661 | else |
| 662 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 663 | fi |
| 664 | } |
| 665 | |
| 666 | function croot() |
| 667 | { |
| 668 | T=$(gettop) |
| 669 | if [ "$T" ]; then |
| 670 | cd $(gettop) |
| 671 | else |
| 672 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 673 | fi |
| 674 | } |
| 675 | |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 676 | function cproj() |
| 677 | { |
| 678 | TOPFILE=build/core/envsetup.mk |
| 679 | # We redirect cd to /dev/null in case it's aliased to |
| 680 | # a command that prints something as a side-effect |
| 681 | # (like pushd) |
| 682 | local HERE=$PWD |
| 683 | T= |
| 684 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 685 | T=$PWD |
| 686 | if [ -f "$T/Android.mk" ]; then |
| 687 | cd $T |
| 688 | return |
| 689 | fi |
| 690 | cd .. > /dev/null |
| 691 | done |
| 692 | cd $HERE > /dev/null |
| 693 | echo "can't find Android.mk" |
| 694 | } |
| 695 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 696 | function pid() |
| 697 | { |
| 698 | local EXE="$1" |
| 699 | if [ "$EXE" ] ; then |
| 700 | local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'` |
| 701 | echo "$PID" |
| 702 | else |
| 703 | echo "usage: pid name" |
| 704 | fi |
| 705 | } |
| 706 | |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 707 | # systemstack - dump the current stack trace of all threads in the system process |
| 708 | # to the usual ANR traces file |
| 709 | function systemstack() |
| 710 | { |
| 711 | adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server) |
| 712 | } |
| 713 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 714 | function gdbclient() |
| 715 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 716 | local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT) |
| 717 | local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED) |
| 718 | local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED) |
| 719 | local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED) |
| 720 | local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS) |
Nick Kralevich | 0ab21d3 | 2011-11-11 09:02:01 -0800 | [diff] [blame] | 721 | local ARCH=$(get_build_var TARGET_ARCH) |
| 722 | local GDB |
| 723 | case "$ARCH" in |
| 724 | x86) GDB=i686-android-linux-gdb;; |
| 725 | arm) GDB=arm-linux-androideabi-gdb;; |
| 726 | *) echo "Unknown arch $ARCH"; return 1;; |
| 727 | esac |
| 728 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 729 | if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then |
| 730 | local EXE="$1" |
| 731 | if [ "$EXE" ] ; then |
| 732 | EXE=$1 |
| 733 | else |
| 734 | EXE="app_process" |
| 735 | fi |
| 736 | |
| 737 | local PORT="$2" |
| 738 | if [ "$PORT" ] ; then |
| 739 | PORT=$2 |
| 740 | else |
| 741 | PORT=":5039" |
| 742 | fi |
| 743 | |
| 744 | local PID |
| 745 | local PROG="$3" |
| 746 | if [ "$PROG" ] ; then |
Grace Kloba | e9d04bf | 2011-04-30 11:04:05 -0700 | [diff] [blame] | 747 | if [[ "$PROG" =~ ^[0-9]+$ ]] ; then |
| 748 | PID="$3" |
| 749 | else |
| 750 | PID=`pid $3` |
| 751 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 752 | adb forward "tcp$PORT" "tcp$PORT" |
| 753 | adb shell gdbserver $PORT --attach $PID & |
| 754 | sleep 2 |
| 755 | else |
| 756 | echo "" |
| 757 | echo "If you haven't done so already, do this first on the device:" |
| 758 | echo " gdbserver $PORT /system/bin/$EXE" |
| 759 | echo " or" |
| 760 | echo " gdbserver $PORT --attach $PID" |
| 761 | echo "" |
| 762 | fi |
| 763 | |
| 764 | echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS" |
Kenny Root | 9bf081e | 2012-03-26 12:38:16 -0700 | [diff] [blame] | 765 | echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 766 | echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT" |
| 767 | echo >>"$OUT_ROOT/gdbclient.cmds" "" |
| 768 | |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame^] | 769 | $ANDROID_TOOLCHAIN/$GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 770 | else |
| 771 | echo "Unable to determine build system output dir." |
| 772 | fi |
| 773 | |
| 774 | } |
| 775 | |
| 776 | case `uname -s` in |
| 777 | Darwin) |
| 778 | function sgrep() |
| 779 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 780 | 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] | 781 | } |
| 782 | |
| 783 | ;; |
| 784 | *) |
| 785 | function sgrep() |
| 786 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 787 | 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] | 788 | } |
| 789 | ;; |
| 790 | esac |
| 791 | |
| 792 | function jgrep() |
| 793 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 794 | 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] | 795 | } |
| 796 | |
| 797 | function cgrep() |
| 798 | { |
Mike Dodd | 0c26d34 | 2011-04-07 13:29:06 -0700 | [diff] [blame] | 799 | 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] | 800 | } |
| 801 | |
| 802 | function resgrep() |
| 803 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 804 | 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] | 805 | } |
| 806 | |
| 807 | case `uname -s` in |
| 808 | Darwin) |
| 809 | function mgrep() |
| 810 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 811 | find -E . -name .repo -prune -o -name .git -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] | 812 | } |
| 813 | |
| 814 | function treegrep() |
| 815 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 816 | 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] | 817 | } |
| 818 | |
| 819 | ;; |
| 820 | *) |
| 821 | function mgrep() |
| 822 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 823 | find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | function treegrep() |
| 827 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 828 | 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] | 829 | } |
| 830 | |
| 831 | ;; |
| 832 | esac |
| 833 | |
| 834 | function getprebuilt |
| 835 | { |
| 836 | get_abs_build_var ANDROID_PREBUILTS |
| 837 | } |
| 838 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 839 | function tracedmdump() |
| 840 | { |
| 841 | T=$(gettop) |
| 842 | if [ ! "$T" ]; then |
| 843 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 844 | return |
| 845 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 846 | local prebuiltdir=$(getprebuilt) |
Jack Veenstra | 60116fc | 2009-04-09 18:12:34 -0700 | [diff] [blame] | 847 | local KERNEL=$T/prebuilt/android-arm/kernel/vmlinux-qemu |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 848 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 849 | local TRACE=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 850 | if [ ! "$TRACE" ] ; then |
| 851 | echo "usage: tracedmdump tracename" |
| 852 | return |
| 853 | fi |
| 854 | |
Jack Veenstra | 60116fc | 2009-04-09 18:12:34 -0700 | [diff] [blame] | 855 | if [ ! -r "$KERNEL" ] ; then |
| 856 | echo "Error: cannot find kernel: '$KERNEL'" |
| 857 | return |
| 858 | fi |
| 859 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 860 | local BASETRACE=$(basename $TRACE) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 861 | if [ "$BASETRACE" = "$TRACE" ] ; then |
| 862 | TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE |
| 863 | fi |
| 864 | |
| 865 | echo "post-processing traces..." |
| 866 | rm -f $TRACE/qtrace.dexlist |
| 867 | post_trace $TRACE |
| 868 | if [ $? -ne 0 ]; then |
| 869 | echo "***" |
| 870 | echo "*** Error: malformed trace. Did you remember to exit the emulator?" |
| 871 | echo "***" |
| 872 | return |
| 873 | fi |
| 874 | echo "generating dexlist output..." |
| 875 | /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 |
| 876 | echo "generating dmtrace data..." |
| 877 | q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return |
| 878 | echo "generating html file..." |
| 879 | dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return |
| 880 | echo "done, see $TRACE/dmtrace.html for details" |
| 881 | echo "or run:" |
| 882 | echo " traceview $TRACE/dmtrace" |
| 883 | } |
| 884 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 885 | # communicate with a running device or emulator, set up necessary state, |
| 886 | # and run the hat command. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 887 | function runhat() |
| 888 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 889 | # process standard adb options |
| 890 | local adbTarget="" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 891 | if [ "$1" = "-d" -o "$1" = "-e" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 892 | adbTarget=$1 |
| 893 | shift 1 |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 894 | elif [ "$1" = "-s" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 895 | adbTarget="$1 $2" |
| 896 | shift 2 |
| 897 | fi |
| 898 | local adbOptions=${adbTarget} |
| 899 | echo adbOptions = ${adbOptions} |
| 900 | |
| 901 | # runhat options |
| 902 | local targetPid=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 903 | |
| 904 | if [ "$targetPid" = "" ]; then |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 905 | echo "Usage: runhat [ -d | -e | -s serial ] target-pid" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 906 | return |
| 907 | fi |
| 908 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 909 | # confirm hat is available |
| 910 | if [ -z $(which hat) ]; then |
| 911 | echo "hat is not available in this configuration." |
| 912 | return |
| 913 | fi |
| 914 | |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 915 | # issue "am" command to cause the hprof dump |
| 916 | local devFile=/sdcard/hprof-$targetPid |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 917 | echo "Poking $targetPid and waiting for data..." |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 918 | adb ${adbOptions} shell am dumpheap $targetPid $devFile |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 919 | 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] | 920 | echo -n "> " |
| 921 | read |
| 922 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 923 | local localFile=/tmp/$$-hprof |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 924 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 925 | echo "Retrieving file $devFile..." |
| 926 | adb ${adbOptions} pull $devFile $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 927 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 928 | adb ${adbOptions} shell rm $devFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 929 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 930 | echo "Running hat on $localFile" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 931 | echo "View the output by pointing your browser at http://localhost:7000/" |
| 932 | echo "" |
Dianne Hackborn | 6e4e1bb | 2011-11-10 15:19:51 -0800 | [diff] [blame] | 933 | hat -JXmx512m $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | function getbugreports() |
| 937 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 938 | 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] | 939 | |
| 940 | if [ ! "$reports" ]; then |
| 941 | echo "Could not locate any bugreports." |
| 942 | return |
| 943 | fi |
| 944 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 945 | local report |
| 946 | for report in ${reports[@]} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 947 | do |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 948 | echo "/sdcard/bugreports/${report}" |
| 949 | adb pull /sdcard/bugreports/${report} ${report} |
| 950 | gunzip ${report} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 951 | done |
| 952 | } |
| 953 | |
| 954 | function startviewserver() |
| 955 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 956 | local port=4939 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 957 | if [ $# -gt 0 ]; then |
| 958 | port=$1 |
| 959 | fi |
| 960 | adb shell service call window 1 i32 $port |
| 961 | } |
| 962 | |
| 963 | function stopviewserver() |
| 964 | { |
| 965 | adb shell service call window 2 |
| 966 | } |
| 967 | |
| 968 | function isviewserverstarted() |
| 969 | { |
| 970 | adb shell service call window 3 |
| 971 | } |
| 972 | |
Romain Guy | b84049a | 2010-10-04 16:56:11 -0700 | [diff] [blame] | 973 | function key_home() |
| 974 | { |
| 975 | adb shell input keyevent 3 |
| 976 | } |
| 977 | |
| 978 | function key_back() |
| 979 | { |
| 980 | adb shell input keyevent 4 |
| 981 | } |
| 982 | |
| 983 | function key_menu() |
| 984 | { |
| 985 | adb shell input keyevent 82 |
| 986 | } |
| 987 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 988 | function smoketest() |
| 989 | { |
| 990 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 991 | echo "Couldn't locate output files. Try running 'lunch' first." >&2 |
| 992 | return |
| 993 | fi |
| 994 | T=$(gettop) |
| 995 | if [ ! "$T" ]; then |
| 996 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 997 | return |
| 998 | fi |
| 999 | |
| 1000 | (cd "$T" && mmm tests/SmokeTest) && |
| 1001 | adb uninstall com.android.smoketest > /dev/null && |
| 1002 | adb uninstall com.android.smoketest.tests > /dev/null && |
| 1003 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk && |
| 1004 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk && |
| 1005 | adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner |
| 1006 | } |
| 1007 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1008 | # simple shortcut to the runtest command |
| 1009 | function runtest() |
| 1010 | { |
| 1011 | T=$(gettop) |
| 1012 | if [ ! "$T" ]; then |
| 1013 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1014 | return |
| 1015 | fi |
Brett Chabot | 3fb149d | 2009-10-21 20:05:26 -0700 | [diff] [blame] | 1016 | ("$T"/development/testrunner/runtest.py $@) |
Brett Chabot | 762748c | 2009-03-27 10:25:11 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1019 | function godir () { |
| 1020 | if [[ -z "$1" ]]; then |
| 1021 | echo "Usage: godir <regex>" |
| 1022 | return |
| 1023 | fi |
Brian Carlstrom | b9915a6 | 2010-01-29 16:39:32 -0800 | [diff] [blame] | 1024 | T=$(gettop) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1025 | if [[ ! -f $T/filelist ]]; then |
| 1026 | echo -n "Creating index..." |
Brian Carlstrom | 259e5b7 | 2010-01-30 11:45:03 -0800 | [diff] [blame] | 1027 | (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] | 1028 | echo " Done" |
| 1029 | echo "" |
| 1030 | fi |
| 1031 | local lines |
Jeff Hamilton | 293f939 | 2011-11-18 17:15:25 -0600 | [diff] [blame] | 1032 | 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] | 1033 | if [[ ${#lines[@]} = 0 ]]; then |
| 1034 | echo "Not found" |
| 1035 | return |
| 1036 | fi |
| 1037 | local pathname |
| 1038 | local choice |
| 1039 | if [[ ${#lines[@]} > 1 ]]; then |
| 1040 | while [[ -z "$pathname" ]]; do |
| 1041 | local index=1 |
| 1042 | local line |
| 1043 | for line in ${lines[@]}; do |
| 1044 | printf "%6s %s\n" "[$index]" $line |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 1045 | index=$(($index + 1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1046 | done |
| 1047 | echo |
| 1048 | echo -n "Select one: " |
| 1049 | unset choice |
| 1050 | read choice |
| 1051 | if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then |
| 1052 | echo "Invalid choice" |
| 1053 | continue |
| 1054 | fi |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 1055 | pathname=${lines[$(($choice-1))]} |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1056 | done |
| 1057 | else |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1058 | pathname=${lines[0]} |
| 1059 | fi |
| 1060 | cd $T/$pathname |
| 1061 | } |
| 1062 | |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 1063 | # Force JAVA_HOME to point to java 1.6 if it isn't already set |
| 1064 | function set_java_home() { |
Andy McFadden | bd96094 | 2010-06-24 12:52:51 -0700 | [diff] [blame] | 1065 | if [ ! "$JAVA_HOME" ]; then |
| 1066 | case `uname -s` in |
| 1067 | Darwin) |
| 1068 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home |
| 1069 | ;; |
| 1070 | *) |
| 1071 | export JAVA_HOME=/usr/lib/jvm/java-6-sun |
| 1072 | ;; |
| 1073 | esac |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 1074 | fi |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 1075 | } |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 1076 | |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1077 | if [ "x$SHELL" != "x/bin/bash" ]; then |
| 1078 | case `ps -o command -p $$` in |
| 1079 | *bash*) |
| 1080 | ;; |
| 1081 | *) |
| 1082 | echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results" |
| 1083 | ;; |
| 1084 | esac |
| 1085 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1086 | |
| 1087 | # Execute the contents of any vendorsetup.sh files we can find. |
Bruce Beare | 6f8410b | 2010-06-24 13:51:35 -0700 | [diff] [blame] | 1088 | for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null` |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1089 | do |
| 1090 | echo "including $f" |
| 1091 | . $f |
| 1092 | done |
| 1093 | unset f |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 1094 | |
| 1095 | addcompletions |