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