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