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