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